X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Funit-printf.c;h=62599d0813bd2478ace3c0a95f51cbff374f9a7d;hb=8c8549db376ce9325e5a7547959ab7d9218505b7;hp=4e18afab8bb62f989d3acd111657f6641a1bbec7;hpb=2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2;p=elogind.git diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c index 4e18afab8..62599d081 100644 --- a/src/core/unit-printf.c +++ b/src/core/unit-printf.c @@ -182,7 +182,7 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char char *printed = NULL; Unit *u = userdata; ExecContext *c; - int r; + int r = 0; assert(u); @@ -208,7 +208,7 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char if (r < 0) return -ENODATA; - asprintf(&printed, "%lu", (unsigned long) uid); + r = asprintf(&printed, UID_FMT, uid); } } @@ -231,10 +231,10 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char if (specifier == 'u') printed = strdup(username); else - asprintf(&printed, "%lu", (unsigned long) uid); + r = asprintf(&printed, UID_FMT, uid); } - if (!printed) + if (r < 0 || !printed) return -ENOMEM; *ret = printed; @@ -369,7 +369,7 @@ int unit_full_printf(Unit *u, const char *format, char **ret) { /* This is similar to unit_name_printf() but also supports * unescaping. Also, adds a couple of additional codes: * - * %f the the instance if set, otherwise the id + * %f the instance if set, otherwise the id * %c cgroup path of unit * %r where units in this slice are placed in the cgroup tree * %R the root of this systemd's instance tree