chiark / gitweb /
util: modernize get_parent_of_pid() a bit
authorLennart Poettering <lennart@poettering.net>
Fri, 15 Apr 2011 23:45:45 +0000 (01:45 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 16 Apr 2011 00:03:34 +0000 (02:03 +0200)
src/util.c

index 75ad56f..39c9db7 100644 (file)
@@ -456,11 +456,11 @@ int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
         char fn[PATH_MAX], line[LINE_MAX], *p;
         long unsigned ppid;
 
-        assert(pid >= 0);
+        assert(pid > 0);
         assert(_ppid);
 
         assert_se(snprintf(fn, sizeof(fn)-1, "/proc/%lu/stat", (unsigned long) pid) < (int) (sizeof(fn)-1));
-        fn[sizeof(fn)-1] = 0;
+        char_array_0(fn);
 
         if (!(f = fopen(fn, "r")))
                 return -errno;