]> err.no Git - systemd/commitdiff
util: properly detect ttyname_r() failing
authorLennart Poettering <lennart@poettering.net>
Mon, 16 Aug 2010 19:25:09 +0000 (21:25 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 16 Aug 2010 19:25:09 +0000 (21:25 +0200)
src/util.c

index bc227f52d59e4ff7269f5716d8d2b2df8c806a7c..3bcce2f019bcf6af535d5f4942d135185da4a870 100644 (file)
@@ -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);