Call NULL by its name

In variadic functions we still do the cast.  In POSIX, it's not
necessary, since NULL is required to be of type 'void *', and 'void *'
is guaranteed to have the same alignment and representation as 'char *'.
However, since ISO C still doesn't mandate that, and moreover they're
doing dubious stuff by adding nullptr, let's be on the cautious side.
Also, C++ requires that NULL is _not_ 'void *', but either plain 0 or
some magic stuff.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2023-02-01 02:50:14 +01:00
committed by Serge Hallyn
parent 1482224c54
commit 62172f6fb5
31 changed files with 84 additions and 84 deletions

View File

@ -34,7 +34,7 @@
*/
static char **list (char *s)
{
static char **members = 0;
static char **members = NULL;
static int size = 0; /* max members + 1 */
int i;
char **rbuf;
@ -55,9 +55,9 @@ static char **list (char *s)
}
if (!rbuf) {
free (members);
members = 0;
members = NULL;
size = 0;
return (char **) 0;
return NULL;
}
members = rbuf;
}
@ -71,14 +71,14 @@ static char **list (char *s)
*s++ = '\0';
}
}
members[i] = (char *) 0;
members[i] = NULL;
return members;
}
struct group *sgetgrent (const char *buf)
{
static char *grpbuf = 0;
static char *grpbuf = NULL;
static size_t size = 0;
static char *grpfields[NFIELDS];
static struct group grent;
@ -91,9 +91,9 @@ struct group *sgetgrent (const char *buf)
free (grpbuf);
size = strlen (buf) + 1000; /* at least: strlen(buf) + 1 */
grpbuf = malloc (size);
if (!grpbuf) {
if (grpbuf == NULL) {
size = 0;
return 0;
return NULL;
}
}
strcpy (grpbuf, buf);
@ -112,16 +112,16 @@ struct group *sgetgrent (const char *buf)
}
}
if (i < (NFIELDS - 1) || *grpfields[2] == '\0' || cp != NULL) {
return (struct group *) 0;
return NULL;
}
grent.gr_name = grpfields[0];
grent.gr_passwd = grpfields[1];
if (get_gid (grpfields[2], &grent.gr_gid) == 0) {
return (struct group *) 0;
return NULL;
}
grent.gr_mem = list (grpfields[3]);
if (NULL == grent.gr_mem) {
return (struct group *) 0; /* out of memory */
return NULL; /* out of memory */
}
return &grent;