From: Lennart Poettering Date: Mon, 16 Aug 2010 19:25:09 +0000 (+0200) Subject: util: properly detect ttyname_r() failing X-Git-Tag: v8~75 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=618e02c7b7f8e11fdb954a019342d745937baf55;p=systemd util: properly detect ttyname_r() failing --- diff --git a/src/util.c b/src/util.c index bc227f52..3bcce2f0 100644 --- a/src/util.c +++ b/src/util.c @@ -2531,11 +2531,12 @@ char* getlogname_malloc(void) { int getttyname_malloc(char **r) { char path[PATH_MAX], *p, *c; + int k; assert(r); - if (ttyname_r(STDIN_FILENO, path, sizeof(path)) < 0) - return -errno; + if ((k = ttyname_r(STDIN_FILENO, path, sizeof(path))) != 0) + return -k; char_array_0(path);