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:
committed by
Serge Hallyn
parent
1482224c54
commit
62172f6fb5
@@ -103,7 +103,7 @@ void endsgent (void)
|
||||
(void) fclose (shadow);
|
||||
}
|
||||
|
||||
shadow = (FILE *) 0;
|
||||
shadow = NULL;
|
||||
}
|
||||
|
||||
/*@observer@*//*@null@*/struct sgrp *sgetsgent (const char *string)
|
||||
@@ -399,7 +399,7 @@ void endsgent (void)
|
||||
nis_disabled = true;
|
||||
}
|
||||
#endif
|
||||
while ((sgrp = getsgent ()) != (struct sgrp *) 0) {
|
||||
while ((sgrp = getsgent ()) != NULL) {
|
||||
if (strcmp (name, sgrp->sg_name) == 0) {
|
||||
break;
|
||||
}
|
||||
|
@@ -79,7 +79,7 @@ static void endportent (void)
|
||||
(void) fclose (ports);
|
||||
}
|
||||
|
||||
ports = (FILE *) 0;
|
||||
ports = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -172,13 +172,13 @@ static struct port *getportent (void)
|
||||
}
|
||||
*cp = '\0';
|
||||
cp++;
|
||||
port.pt_names[j + 1] = (char *) 0;
|
||||
port.pt_names[j + 1] = NULL;
|
||||
|
||||
/*
|
||||
* Get the list of user names. It is the second colon
|
||||
* separated field, and is a comma separated list of user
|
||||
* names. The entry '*' is used to specify all usernames.
|
||||
* The last entry in the list is a (char *) 0 pointer.
|
||||
* The last entry in the list is a NULL pointer.
|
||||
*/
|
||||
|
||||
if (':' != *cp) {
|
||||
|
@@ -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;
|
||||
|
@@ -94,7 +94,7 @@ void endspent (void)
|
||||
(void) fclose (shadow);
|
||||
}
|
||||
|
||||
shadow = (FILE *) 0;
|
||||
shadow = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -336,9 +336,9 @@ struct spwd *fgetspent (FILE * fp)
|
||||
}
|
||||
|
||||
#ifdef USE_NIS
|
||||
while (fgets (buf, (int) sizeof buf, fp) != (char *) 0)
|
||||
while (fgets (buf, (int) sizeof buf, fp) != NULL)
|
||||
#else
|
||||
if (fgets (buf, (int) sizeof buf, fp) != (char *) 0)
|
||||
if (fgets (buf, (int) sizeof buf, fp) != NULL)
|
||||
#endif
|
||||
{
|
||||
cp = strchr (buf, '\n');
|
||||
@@ -511,7 +511,7 @@ struct spwd *getspnam (const char *name)
|
||||
nis_disabled = true;
|
||||
}
|
||||
#endif
|
||||
while ((sp = getspent ()) != (struct spwd *) 0) {
|
||||
while ((sp = getspent ()) != NULL) {
|
||||
if (strcmp (name, sp->sp_namp) == 0) {
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user