bddcd9b095
- Every non-const pointer converts automatically to void *. - Every pointer converts automatically to void *. - void * converts to any other pointer. - const void * converts to any other const pointer. - Integer variables convert to each other. I changed the declaration of a few variables in order to allow removing a cast. However, I didn't attempt to edit casts inside comparisons, since they are very delicate. I also kept casts in variadic functions, since they are necessary, and in allocation functions, because I have other plans for them. I also changed a few casts to int that are better as ptrdiff_t. This change has triggered some warnings about const correctness issues, which have also been fixed in this patch (see for example src/login.c). Signed-off-by: Alejandro Colomar <alx@kernel.org>
32 lines
515 B
C
32 lines
515 B
C
/*
|
|
* SPDX-FileCopyrightText: 2009 , Nicolas François
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#ident "$Id$"
|
|
|
|
#include "prototypes.h"
|
|
#include "defines.h"
|
|
|
|
int get_pid (const char *pidstr, pid_t *pid)
|
|
{
|
|
long long int val;
|
|
char *endptr;
|
|
|
|
errno = 0;
|
|
val = strtoll (pidstr, &endptr, 10);
|
|
if ( ('\0' == *pidstr)
|
|
|| ('\0' != *endptr)
|
|
|| (ERANGE == errno)
|
|
|| (/*@+longintegral@*/val != (pid_t)val)/*@=longintegral@*/) {
|
|
return 0;
|
|
}
|
|
|
|
*pid = val;
|
|
return 1;
|
|
}
|
|
|