[systemd-devel] [systemd-commits] 8 commits - man/custom-html.xsl man/systemd-nspawn.xml src/core src/fsck src/journal src/journal-remote src/libsystemd src/libsystemd-terminal src/shared src/timedate src/tmpfiles units/systemd-backlight at .service.in units/systemd-journal-catalog-update.service.in units/systemd-journal-flush.service.in
Lennart Poettering
lennart at poettering.net
Mon Feb 2 12:21:26 PST 2015
On Sun, 01.02.15 14:28, Zbigniew Jędrzejewski-Szmek (zbyszek at kemper.freedesktop.org) wrote:
>
> if (!switch_root_init) {
> - char sfd[16];
> + char sfd[DECIMAL_STR_MAX(int) + 1];
>
> /* First try to spawn ourselves with the right
> * path, and with full serialization. We do
> @@ -1893,8 +1893,7 @@ finish:
> assert(arg_serialization);
> assert(fds);
>
> - snprintf(sfd, sizeof(sfd), "%i", fileno(arg_serialization));
> - char_array_0(sfd);
> + xsprintf(sfd, "%i",
> - fileno(arg_serialization));
BTW, one minor comment on this: DECIMAL_STR_MAX() actually already
includes space for the trailing NUL, the +1 for sizing this array are
hence unnecesary.
I like the xsprintf() concept!
> diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
> index 74f40b9..1f85536 100644
> --- a/src/timedate/timedatectl.c
> +++ b/src/timedate/timedatectl.c
> @@ -38,6 +38,8 @@
> #include "pager.h"
> #include "time-dst.h"
>
> +#define xstrftime(buf, fmt, tm) assert_se(strftime(buf, sizeof(buf), fmt, tm) > 0)
> +
Maybe move this to time-util.h, even though it currently has a single
user only...
> +typedef enum {
> + CREATION_NORMAL,
> + CREATION_EXISTING,
> + CREATION_FORCE,
> +} CreationMode;
> +
> +static const char* creation_verb(CreationMode mode) {
> + switch(mode) {
> + case CREATION_NORMAL:
> + return "Created";
> + case CREATION_EXISTING:
> + return "Found existing";
> + case CREATION_FORCE:
> + return "Created replacement";
> + }
> + assert_not_reached("Bad creation");
> +}
Maybe a candidate for DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING()?
I recently split up DEFINE_PRIVATE_STRING_TABLE_LOOKUP() so that one
can also just male use of the to_string() part without the
from_string() part...
> --- a/units/systemd-backlight at .service.in
> +++ b/units/systemd-backlight at .service.in
> @@ -19,3 +19,4 @@ Type=oneshot
> RemainAfterExit=yes
> ExecStart=@rootlibexecdir@/systemd-backlight load %i
> ExecStop=@rootlibexecdir@/systemd-backlight save %i
> +TimeoutSec=2min
Our usual default timeout is 90s so far (see def.h), we probably
should stick to that here...
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list