lib/: get_pid(): Use the usual -1 as an error code
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
18c428a6c9
commit
4c0c7c52f1
+1
-1
@@ -195,7 +195,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
|
||||
return 0;
|
||||
}
|
||||
buf[len] = '\0';
|
||||
if (get_pid (buf, &pid) == 0) {
|
||||
if (get_pid(buf, &pid) == -1) {
|
||||
if (log) {
|
||||
(void) fprintf (shadow_logfd,
|
||||
"%s: existing lock file %s with an invalid PID '%s'\n",
|
||||
|
||||
+3
-3
@@ -29,11 +29,11 @@ int get_pid (const char *pidstr, pid_t *pid)
|
||||
|| (0 != errno)
|
||||
|| (val < 1)
|
||||
|| (/*@+longintegral@*/val != (pid_t)val)/*@=longintegral@*/) {
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pid = val;
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -82,7 +82,7 @@ int open_pidfd(const char *pidstr)
|
||||
char proc_dir_name[32];
|
||||
pid_t target;
|
||||
|
||||
if (get_pid(pidstr, &target) == 0)
|
||||
if (get_pid(pidstr, &target) == -1)
|
||||
return -ENOENT;
|
||||
|
||||
/* max string length is 6 + 10 + 1 + 1 = 18, allocate 32 bytes */
|
||||
|
||||
+2
-2
@@ -202,7 +202,7 @@ static int user_busy_processes (const char *name, uid_t uid)
|
||||
}
|
||||
|
||||
/* Check if this is a valid PID */
|
||||
if (get_pid (tmp_d_name, &pid) == 0) {
|
||||
if (get_pid(tmp_d_name, &pid) == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ static int user_busy_processes (const char *name, uid_t uid)
|
||||
if (task_dir != NULL) {
|
||||
while ((ent = readdir (task_dir)) != NULL) {
|
||||
pid_t tid;
|
||||
if (get_pid (ent->d_name, &tid) == 0) {
|
||||
if (get_pid(ent->d_name, &tid) == -1) {
|
||||
continue;
|
||||
}
|
||||
if (tid == pid) {
|
||||
|
||||
Reference in New Issue
Block a user