[systemd-commits] 5 commits - Makefile.am autogen.sh configure.ac shell-completion/bash src/cgtop src/core src/journal src/systemd
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Dec 25 16:55:44 PST 2013
Makefile.am | 2
autogen.sh | 3 +
configure.ac | 2
shell-completion/bash/journalctl | 4 -
src/cgtop/cgtop.c | 2
src/core/dbus-cgroup.c | 2
src/core/execute.c | 2
src/journal/journalctl.c | 108 +++++++++++++++++++++++----------------
src/systemd/sd-bus.h | 2
9 files changed, 75 insertions(+), 52 deletions(-)
New commits:
commit 442e2def7938435481eed34cd7331e34ebc8d9e0
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Dec 26 01:52:01 2013 +0100
journalctl: make sure -b --foobar cannot be misunderstood as --boot=--foobar
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index cb252eb..122b0e6 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -71,7 +71,8 @@ static bool arg_no_tail = false;
static bool arg_quiet = false;
static bool arg_merge = false;
static bool arg_boot = false;
-static char *arg_boot_descriptor = NULL;
+static sd_id128_t arg_boot_id = {};
+static int arg_boot_offset = 0;
static bool arg_dmesg = false;
static const char *arg_cursor = NULL;
static const char *arg_after_cursor = NULL;
@@ -122,6 +123,41 @@ static void pager_open_if_enabled(void) {
pager_open(arg_pager_end);
}
+static int parse_boot_descriptor(const char *x, sd_id128_t *boot_id, int *offset) {
+ sd_id128_t id = SD_ID128_NULL;
+ int off = 0, r;
+
+ if (strlen(x) >= 32) {
+ char *t;
+
+ t = strndupa(x, 32);
+ r = sd_id128_from_string(t, &id);
+ if (r >= 0)
+ x += 32;
+
+ if (*x != '-' && *x != '+' && *x != 0)
+ return -EINVAL;
+
+ if (*x != 0) {
+ r = safe_atoi(x, &off);
+ if (r < 0)
+ return r;
+ }
+ } else {
+ r = safe_atoi(x, &off);
+ if (r < 0)
+ return r;
+ }
+
+ if (boot_id)
+ *boot_id = id;
+
+ if (offset)
+ *offset = off;
+
+ return 0;
+}
+
static int help(void) {
pager_open_if_enabled();
@@ -372,16 +408,23 @@ static int parse_argv(int argc, char *argv[]) {
case 'b':
arg_boot = true;
- if (optarg)
- arg_boot_descriptor = optarg;
- else if (optind < argc) {
- int boot;
+ if (optarg) {
+ r = parse_boot_descriptor(optarg, &arg_boot_id, &arg_boot_offset);
+ if (r < 0) {
+ log_error("Failed to parse boot descriptor '%s'", optarg);
+ return -EINVAL;
+ }
+ } else {
+
+ /* Hmm, no argument? Maybe the next
+ * word on the command line is
+ * supposed to be the argument? Let's
+ * see if there is one and is parsable
+ * as a boot descriptor... */
- if (argv[optind][0] != '-' ||
- safe_atoi(argv[optind], &boot) >= 0) {
- arg_boot_descriptor = argv[optind];
+ if (optind < argc &&
+ parse_boot_descriptor(argv[optind], &arg_boot_id, &arg_boot_offset) >= 0)
optind++;
- }
}
break;
@@ -819,9 +862,6 @@ static int get_relative_boot_id(sd_journal *j, sd_id128_t *boot_id, int relative
assert(j);
assert(boot_id);
- if (relative == 0 && !sd_id128_equal(*boot_id, SD_ID128_NULL))
- return 0;
-
r = sd_journal_query_unique(j, "_BOOT_ID");
if (r < 0)
return r;
@@ -888,58 +928,27 @@ static int get_relative_boot_id(sd_journal *j, sd_id128_t *boot_id, int relative
static int add_boot(sd_journal *j) {
char match[9+32+1] = "_BOOT_ID=";
- char *offset;
- sd_id128_t boot_id = SD_ID128_NULL;
- int r, relative = 0;
+ int r;
assert(j);
if (!arg_boot)
return 0;
- if (!arg_boot_descriptor)
+ if (arg_boot_offset == 0 && sd_id128_equal(arg_boot_id, SD_ID128_NULL))
return add_match_this_boot(j, arg_machine);
- if (strlen(arg_boot_descriptor) >= 32) {
- char tmp = arg_boot_descriptor[32];
- arg_boot_descriptor[32] = '\0';
- r = sd_id128_from_string(arg_boot_descriptor, &boot_id);
- arg_boot_descriptor[32] = tmp;
-
- if (r < 0) {
- log_error("Failed to parse boot ID '%.32s': %s",
- arg_boot_descriptor, strerror(-r));
- return r;
- }
-
- offset = arg_boot_descriptor + 32;
-
- if (*offset && *offset != '-' && *offset != '+') {
- log_error("Relative boot ID offset must start with a '+' or a '-', found '%s' ", offset);
- return -EINVAL;
- }
- } else
- offset = arg_boot_descriptor;
-
- if (*offset) {
- r = safe_atoi(offset, &relative);
- if (r < 0) {
- log_error("Failed to parse relative boot ID number '%s'", offset);
- return -EINVAL;
- }
- }
-
- r = get_relative_boot_id(j, &boot_id, relative);
+ r = get_relative_boot_id(j, &arg_boot_id, arg_boot_offset);
if (r < 0) {
- if (sd_id128_equal(boot_id, SD_ID128_NULL))
- log_error("Failed to look up boot %+d: %s", relative, strerror(-r));
+ if (sd_id128_equal(arg_boot_id, SD_ID128_NULL))
+ log_error("Failed to look up boot %+i: %s", arg_boot_offset, strerror(-r));
else
- log_error("Failed to look up boot ID "SD_ID128_FORMAT_STR"%+d: %s",
- SD_ID128_FORMAT_VAL(boot_id), relative, strerror(-r));
+ log_error("Failed to look up boot ID "SD_ID128_FORMAT_STR"%+i: %s",
+ SD_ID128_FORMAT_VAL(arg_boot_id), arg_boot_offset, strerror(-r));
return r;
}
- sd_id128_to_string(boot_id, match + 9);
+ sd_id128_to_string(arg_boot_id, match + 9);
r = sd_journal_add_match(j, match, sizeof(match) - 1);
if (r < 0) {
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 2e1fa96..21f6ef6 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -308,7 +308,7 @@ int sd_bus_creds_get_well_known_names(sd_bus_creds *c, char ***names);
/* Error structures */
-#define SD_BUS_ERROR_MAKE_CONST(name, message) ((sd_bus_error) {(name), (message), 0})
+#define SD_BUS_ERROR_MAKE_CONST(name, message) ((const sd_bus_error) {(name), (message), 0})
#define SD_BUS_ERROR_NULL SD_BUS_ERROR_MAKE_CONST(NULL, NULL)
void sd_bus_error_free(sd_bus_error *e);
commit b68b76897aca23f613afdc39a760992c711a7671
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Dec 25 19:17:14 2013 +0100
Revert "completion: don't offer completions for journalctl -b"
This reverts commit c756a6d57cdb678b702c68913dae3e11ff0427ae.
diff --git a/shell-completion/bash/journalctl b/shell-completion/bash/journalctl
index 476fe6b..e4b2f4a 100644
--- a/shell-completion/bash/journalctl
+++ b/shell-completion/bash/journalctl
@@ -43,7 +43,7 @@ _journalctl() {
-h --help -l --local --new-id128 -m --merge --no-pager
--no-tail -q --quiet --setup-keys --this-boot --verify
--version --list-catalog --update-catalog --list-boots'
- [ARG]='--boot --this-boot -D --directory --file -F --field
+ [ARG]='-b --boot --this-boot -D --directory --file -F --field
-o --output -u --unit --user-unit'
[ARGUNKNOWN]='-c --cursor --interval -n --lines -p --priority --since --until
--verify-key'
@@ -51,7 +51,7 @@ _journalctl() {
if __contains_word "$prev" ${OPTS[ARG]} ${OPTS[ARGUNKNOWN]}; then
case $prev in
- --boot|--this-boot)
+ --boot|--this-boot|-b)
comps=$(journalctl -F '_BOOT_ID' 2>/dev/null)
;;
--directory|-D)
commit 6cebe83cfa656365348ff21f567d133c7e34a71d
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Dec 25 19:17:10 2013 +0100
Revert "journalctl: remove unexpected behavior of journalctl -b"
This reverts commit cf5bccc2bb9569030cb04debbc4208aaca0fe5b4.
We should fix thinks properly if they aren't perfect, not just break
other things...
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index b347dfa..cb252eb 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -371,7 +371,18 @@ static int parse_argv(int argc, char *argv[]) {
case 'b':
arg_boot = true;
- arg_boot_descriptor = optarg;
+
+ if (optarg)
+ arg_boot_descriptor = optarg;
+ else if (optind < argc) {
+ int boot;
+
+ if (argv[optind][0] != '-' ||
+ safe_atoi(argv[optind], &boot) >= 0) {
+ arg_boot_descriptor = argv[optind];
+ optind++;
+ }
+ }
break;
commit 43a99a7afe3063eebc901452026b13360b69a7b5
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Dec 25 19:00:12 2013 +0100
build-sys: minor fixes found with cppcheck
diff --git a/Makefile.am b/Makefile.am
index b7a4681..162a7be 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5013,4 +5013,4 @@ tests += \
test-libudev-sym
cppcheck:
- cppcheck --enable=all $(top_srcdir)
+ cppcheck --enable=all -q $(top_srcdir)
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
index e5fc262..c56f7a8 100644
--- a/src/cgtop/cgtop.c
+++ b/src/cgtop/cgtop.c
@@ -563,7 +563,7 @@ static int help(void) {
" -d --delay=DELAY Delay between updates\n"
" -n --iterations=N Run for N iterations before exiting\n"
" -b --batch Run in batch mode, accepting no input\n"
- " --depth=DEPTH Maximum traversal depth (default: %d)\n",
+ " --depth=DEPTH Maximum traversal depth (default: %u)\n",
program_invocation_short_name, arg_depth);
return 0;
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index 39865a9..861bb16 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -484,6 +484,8 @@ int bus_cgroup_set_property(
n++;
}
+ if (r < 0)
+ return r;
if (mode != UNIT_CHECK) {
_cleanup_free_ char *buf = NULL;
diff --git a/src/core/execute.c b/src/core/execute.c
index 9b33ec0..6ae9a5e 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1974,7 +1974,7 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
fprintf(f, "%sCPUAffinity:", prefix);
for (i = 0; i < c->cpuset_ncpus; i++)
if (CPU_ISSET_S(i, CPU_ALLOC_SIZE(c->cpuset_ncpus), c->cpuset))
- fprintf(f, " %i", i);
+ fprintf(f, " %u", i);
fputs("\n", f);
}
commit 25ad8664604507aacab593327b8d9d7454f0634d
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Dec 25 18:34:44 2013 +0100
build-sys: the pure/const warning options are probably too much as default, but let's make it available via "autogen.sh a"
diff --git a/autogen.sh b/autogen.sh
index 9ffd724..e6289b3 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -59,6 +59,9 @@ if [ "x$1" = "xc" ]; then
elif [ "x$1" = "xg" ]; then
./configure CFLAGS='-g -Og -ftrapv' --enable-kdbus $args
make clean
+elif [ "x$1" = "xa" ]; then
+ ./configure CFLAGS='-g -O0 -Wsuggest-attribute=pure -Wsuggest-attribute=const -ftrapv' --enable-kdbus $args
+ make clean
else
echo
echo "----------------------------------------------------------------"
diff --git a/configure.ac b/configure.ac
index 86eebce..efca1a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -127,8 +127,6 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
-Winit-self \
-Wdeclaration-after-statement \
-Wfloat-equal \
- -Wsuggest-attribute=pure \
- -Wsuggest-attribute=const \
-Wsuggest-attribute=noreturn \
-Wmissing-prototypes \
-Wstrict-prototypes \
More information about the systemd-commits
mailing list