svn commit: r309485 - in stable/10/lib/libc: db/hash gen locale net posix1e resolv rpc softfloat uuid xdr
Ngie Cooper
ngie at FreeBSD.org
Sat Dec 3 17:17:45 UTC 2016
Author: ngie
Date: Sat Dec 3 17:17:42 2016
New Revision: 309485
URL: https://svnweb.freebsd.org/changeset/base/309485
Log:
MFC r297790:
r297790 (by pfg):
libc: replace 0 with NULL for pointers.
While here also cleanup some surrounding code; particularly
drop some malloc() casts.
Found with devel/coccinelle.
Modified:
stable/10/lib/libc/db/hash/hash.c
stable/10/lib/libc/db/hash/hash_buf.c
stable/10/lib/libc/gen/err.c
stable/10/lib/libc/gen/getmntinfo.c
stable/10/lib/libc/gen/opendir.c
stable/10/lib/libc/gen/tls.c
stable/10/lib/libc/locale/xlocale_private.h
stable/10/lib/libc/net/base64.c
stable/10/lib/libc/net/getifaddrs.c
stable/10/lib/libc/net/getservent.c
stable/10/lib/libc/net/rcmd.c
stable/10/lib/libc/posix1e/acl_support_nfs4.c
stable/10/lib/libc/resolv/mtctxres.c
stable/10/lib/libc/resolv/res_init.c
stable/10/lib/libc/resolv/res_mkupdate.c
stable/10/lib/libc/rpc/auth_none.c
stable/10/lib/libc/rpc/clnt_perror.c
stable/10/lib/libc/rpc/mt_misc.c
stable/10/lib/libc/rpc/rpcdname.c
stable/10/lib/libc/softfloat/timesoftfloat.c
stable/10/lib/libc/uuid/uuid_to_string.c
stable/10/lib/libc/xdr/xdr_mem.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/lib/libc/db/hash/hash.c
==============================================================================
--- stable/10/lib/libc/db/hash/hash.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/db/hash/hash.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -771,7 +771,7 @@ next_bucket:
if (__big_keydata(hashp, bufp, key, data, 1))
return (ERROR);
} else {
- if (hashp->cpage == 0)
+ if (hashp->cpage == NULL)
return (ERROR);
key->data = (u_char *)hashp->cpage->page + bp[ndx];
key->size = (ndx > 1 ? bp[ndx - 1] : hashp->BSIZE) - bp[ndx];
Modified: stable/10/lib/libc/db/hash/hash_buf.c
==============================================================================
--- stable/10/lib/libc/db/hash/hash_buf.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/db/hash/hash_buf.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -245,7 +245,7 @@ newbuf(HTAB *hashp, u_int32_t addr, BUFH
*/
for (xbp = bp; xbp->ovfl;) {
next_xbp = xbp->ovfl;
- xbp->ovfl = 0;
+ xbp->ovfl = NULL;
xbp = next_xbp;
/* Check that ovfl pointer is up date. */
@@ -350,7 +350,7 @@ __buf_free(HTAB *hashp, int do_free, int
void
__reclaim_buf(HTAB *hashp, BUFHEAD *bp)
{
- bp->ovfl = 0;
+ bp->ovfl = NULL;
bp->addr = 0;
bp->flags = 0;
BUF_REMOVE(bp);
Modified: stable/10/lib/libc/gen/err.c
==============================================================================
--- stable/10/lib/libc/gen/err.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/gen/err.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -99,7 +99,7 @@ errc(int eval, int code, const char *fmt
void
verrc(int eval, int code, const char *fmt, va_list ap)
{
- if (err_file == 0)
+ if (err_file == NULL)
err_set_file((FILE *)0);
fprintf(err_file, "%s: ", _getprogname());
if (fmt != NULL) {
@@ -124,7 +124,7 @@ errx(int eval, const char *fmt, ...)
void
verrx(int eval, const char *fmt, va_list ap)
{
- if (err_file == 0)
+ if (err_file == NULL)
err_set_file((FILE *)0);
fprintf(err_file, "%s: ", _getprogname());
if (fmt != NULL)
@@ -164,7 +164,7 @@ warnc(int code, const char *fmt, ...)
void
vwarnc(int code, const char *fmt, va_list ap)
{
- if (err_file == 0)
+ if (err_file == NULL)
err_set_file((FILE *)0);
fprintf(err_file, "%s: ", _getprogname());
if (fmt != NULL) {
@@ -186,7 +186,7 @@ warnx(const char *fmt, ...)
void
vwarnx(const char *fmt, va_list ap)
{
- if (err_file == 0)
+ if (err_file == NULL)
err_set_file((FILE *)0);
fprintf(err_file, "%s: ", _getprogname());
if (fmt != NULL)
Modified: stable/10/lib/libc/gen/getmntinfo.c
==============================================================================
--- stable/10/lib/libc/gen/getmntinfo.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/gen/getmntinfo.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -58,7 +58,7 @@ getmntinfo(mntbufp, flags)
if (mntbuf)
free(mntbuf);
bufsize = (mntsize + 1) * sizeof(struct statfs);
- if ((mntbuf = (struct statfs *)malloc(bufsize)) == 0)
+ if ((mntbuf = malloc(bufsize)) == NULL)
return (0);
if ((mntsize = getfsstat(mntbuf, bufsize, flags)) < 0)
return (0);
Modified: stable/10/lib/libc/gen/opendir.c
==============================================================================
--- stable/10/lib/libc/gen/opendir.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/gen/opendir.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -209,7 +209,7 @@ _filldir(DIR *dirp, bool use_current_pos
* On the second pass, save pointers to each one.
* Then sort the pointers and remove duplicate names.
*/
- for (dpv = 0;;) {
+ for (dpv = NULL;;) {
n = 0;
ddptr = buf;
while (ddptr < ddeptr) {
Modified: stable/10/lib/libc/gen/tls.c
==============================================================================
--- stable/10/lib/libc/gen/tls.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/gen/tls.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -284,7 +284,7 @@ _init_tls()
while (*sp++ != 0)
;
aux = (Elf_Auxinfo *) sp;
- phdr = 0;
+ phdr = NULL;
phent = phnum = 0;
for (auxp = aux; auxp->a_type != AT_NULL; auxp++) {
switch (auxp->a_type) {
@@ -301,7 +301,7 @@ _init_tls()
break;
}
}
- if (phdr == 0 || phent != sizeof(Elf_Phdr) || phnum == 0)
+ if (phdr == NULL || phent != sizeof(Elf_Phdr) || phnum == 0)
return;
for (i = 0; (unsigned) i < phnum; i++) {
Modified: stable/10/lib/libc/locale/xlocale_private.h
==============================================================================
--- stable/10/lib/libc/locale/xlocale_private.h Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/locale/xlocale_private.h Sat Dec 3 17:17:42 2016 (r309485)
@@ -155,12 +155,11 @@ __attribute__((unused)) static void
xlocale_release(void *val)
{
struct xlocale_refcounted *obj = val;
- long count = atomic_fetchadd_long(&(obj->retain_count), -1) - 1;
- if (count < 0) {
- if (0 != obj->destructor) {
- obj->destructor(obj);
- }
- }
+ long count;
+
+ count = atomic_fetchadd_long(&(obj->retain_count), -1) - 1;
+ if (count < 0 && obj->destructor != NULL)
+ obj->destructor(obj);
}
/**
Modified: stable/10/lib/libc/net/base64.c
==============================================================================
--- stable/10/lib/libc/net/base64.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/net/base64.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -210,7 +210,7 @@ b64_pton(const char *src, u_char *target
break;
pos = strchr(Base64, ch);
- if (pos == 0) /* A non-base64 character. */
+ if (pos == NULL) /* A non-base64 character. */
return (-1);
switch (state) {
Modified: stable/10/lib/libc/net/getifaddrs.c
==============================================================================
--- stable/10/lib/libc/net/getifaddrs.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/net/getifaddrs.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -85,7 +85,7 @@ getifaddrs(struct ifaddrs **pif)
size_t needed;
char *buf;
char *next;
- struct ifaddrs *cif = 0;
+ struct ifaddrs *cif;
char *p, *p0;
struct rt_msghdr *rtm;
struct if_msghdrl *ifm;
@@ -214,6 +214,7 @@ getifaddrs(struct ifaddrs **pif)
ift = ifa;
idx = 0;
+ cif = NULL;
for (next = buf; next < buf + needed; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)(void *)next;
if (rtm->rtm_version != RTM_VERSION)
Modified: stable/10/lib/libc/net/getservent.c
==============================================================================
--- stable/10/lib/libc/net/getservent.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/net/getservent.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -406,14 +406,14 @@ files_servent(void *retval, void *mdata,
continue;
gotname:
- if (proto == 0 || strcmp(serv->s_proto, proto) == 0)
+ if (proto == NULL || strcmp(serv->s_proto, proto) == 0)
rv = NS_SUCCESS;
break;
case nss_lt_id:
if (port != serv->s_port)
continue;
- if (proto == 0 || strcmp(serv->s_proto, proto) == 0)
+ if (proto == NULL || strcmp(serv->s_proto, proto) == 0)
rv = NS_SUCCESS;
break;
case nss_lt_all:
Modified: stable/10/lib/libc/net/rcmd.c
==============================================================================
--- stable/10/lib/libc/net/rcmd.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/net/rcmd.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -214,7 +214,7 @@ rcmd_af(ahost, rport, locuser, remuser,
}
}
lport--;
- if (fd2p == 0) {
+ if (fd2p == NULL) {
_write(s, "", 1);
lport = 0;
} else {
Modified: stable/10/lib/libc/posix1e/acl_support_nfs4.c
==============================================================================
--- stable/10/lib/libc/posix1e/acl_support_nfs4.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/posix1e/acl_support_nfs4.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -81,7 +81,7 @@ static const char *
format_flag(uint32_t *var, const struct flagnames_struct *flags)
{
- for (; flags->name != 0; flags++) {
+ for (; flags->name != NULL; flags++) {
if ((flags->flag & *var) == 0)
continue;
Modified: stable/10/lib/libc/resolv/mtctxres.c
==============================================================================
--- stable/10/lib/libc/resolv/mtctxres.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/resolv/mtctxres.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -75,7 +75,7 @@ __res_init_ctx(void) {
return (0);
}
- if ((mt = malloc(sizeof (mtctxres_t))) == 0) {
+ if ((mt = malloc(sizeof(mtctxres_t))) == NULL) {
errno = ENOMEM;
return (-1);
}
@@ -94,10 +94,7 @@ __res_init_ctx(void) {
static void
__res_destroy_ctx(void *value) {
- mtctxres_t *mt = (mtctxres_t *)value;
-
- if (mt != 0)
- free(mt);
+ free(value);
}
#endif
@@ -130,9 +127,9 @@ ___mtctxres(void) {
* that fails return a global context.
*/
if (mt_key_initialized) {
- if (((mt = pthread_getspecific(key)) != 0) ||
+ if (((mt = pthread_getspecific(key)) != NULL) ||
(__res_init_ctx() == 0 &&
- (mt = pthread_getspecific(key)) != 0)) {
+ (mt = pthread_getspecific(key)) != NULL)) {
return (mt);
}
}
Modified: stable/10/lib/libc/resolv/res_init.c
==============================================================================
--- stable/10/lib/libc/resolv/res_init.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/resolv/res_init.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -315,7 +315,7 @@ __res_vinit(res_state statp, int preinit
while (*cp != '\0' && *cp != ' ' && *cp != '\t' && *cp != '\n')
cp++;
*cp = '\0';
- *pp++ = 0;
+ *pp++ = NULL;
}
#define MATCH(line, name) \
@@ -391,7 +391,7 @@ __res_vinit(res_state statp, int preinit
while (*cp != '\0' && *cp != ' ' && *cp != '\t')
cp++;
*cp = '\0';
- *pp++ = 0;
+ *pp++ = NULL;
havesearch = 1;
continue;
}
Modified: stable/10/lib/libc/resolv/res_mkupdate.c
==============================================================================
--- stable/10/lib/libc/resolv/res_mkupdate.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/resolv/res_mkupdate.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -1175,7 +1175,7 @@ res_protocolname(int num) {
if (protolist == (struct valuelist *)0)
res_buildprotolist();
pp = cgetprotobynumber(num);
- if (pp == 0) {
+ if (pp == NULL) {
(void) sprintf(number, "%d", num);
return (number);
}
@@ -1190,7 +1190,7 @@ res_servicename(u_int16_t port, const ch
if (servicelist == (struct valuelist *)0)
res_buildservicelist();
ss = cgetservbyport(htons(port), proto);
- if (ss == 0) {
+ if (ss == NULL) {
(void) sprintf(number, "%d", port);
return (number);
}
Modified: stable/10/lib/libc/rpc/auth_none.c
==============================================================================
--- stable/10/lib/libc/rpc/auth_none.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/rpc/auth_none.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -83,9 +83,9 @@ authnone_create(void)
XDR *xdrs;
mutex_lock(&authnone_lock);
- if (ap == 0) {
- ap = (struct authnone_private *)calloc(1, sizeof (*ap));
- if (ap == 0) {
+ if (ap == NULL) {
+ ap = calloc(1, sizeof (*ap));
+ if (ap == NULL) {
mutex_unlock(&authnone_lock);
return (0);
}
Modified: stable/10/lib/libc/rpc/clnt_perror.c
==============================================================================
--- stable/10/lib/libc/rpc/clnt_perror.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/rpc/clnt_perror.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -64,8 +64,8 @@ static char *
_buf()
{
- if (buf == 0)
- buf = (char *)malloc(CLNT_PERROR_BUFLEN);
+ if (buf == NULL)
+ buf = malloc(CLNT_PERROR_BUFLEN);
return (buf);
}
@@ -87,7 +87,7 @@ clnt_sperror(rpch, s)
assert(s != NULL);
str = _buf(); /* side effect: sets CLNT_PERROR_BUFLEN */
- if (str == 0)
+ if (str == NULL)
return (0);
len = CLNT_PERROR_BUFLEN;
strstart = str;
@@ -247,7 +247,7 @@ clnt_spcreateerror(s)
assert(s != NULL);
str = _buf(); /* side effect: sets CLNT_PERROR_BUFLEN */
- if (str == 0)
+ if (str == NULL)
return(0);
len = CLNT_PERROR_BUFLEN;
i = snprintf(str, len, "%s: ", s);
Modified: stable/10/lib/libc/rpc/mt_misc.c
==============================================================================
--- stable/10/lib/libc/rpc/mt_misc.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/rpc/mt_misc.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -95,7 +95,7 @@ rce_key_init(void)
struct rpc_createerr *
__rpc_createerr()
{
- struct rpc_createerr *rce_addr = 0;
+ struct rpc_createerr *rce_addr = NULL;
if (thr_main())
return (&rpc_createerr);
Modified: stable/10/lib/libc/rpc/rpcdname.c
==============================================================================
--- stable/10/lib/libc/rpc/rpcdname.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/rpc/rpcdname.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -43,20 +43,20 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include "un-namespace.h"
-static char *default_domain = 0;
+static char *default_domain;
static char *
get_default_domain(void)
{
char temp[256];
- if (default_domain)
+ if (default_domain != NULL)
return (default_domain);
if (getdomainname(temp, sizeof(temp)) < 0)
return (0);
if ((int) strlen(temp) > 0) {
- default_domain = (char *)malloc((strlen(temp)+(unsigned)1));
- if (default_domain == 0)
+ default_domain = malloc((strlen(temp) + (unsigned)1));
+ if (default_domain == NULL)
return (0);
(void) strcpy(default_domain, temp);
return (default_domain);
@@ -74,7 +74,7 @@ int
__rpc_get_default_domain(domain)
char **domain;
{
- if ((*domain = get_default_domain()) != 0)
+ if ((*domain = get_default_domain()) != NULL)
return (0);
return (-1);
}
Modified: stable/10/lib/libc/softfloat/timesoftfloat.c
==============================================================================
--- stable/10/lib/libc/softfloat/timesoftfloat.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/softfloat/timesoftfloat.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -2068,14 +2068,14 @@ static void
roundingPrecisionName = "80";
}
else {
- roundingPrecisionName = 0;
+ roundingPrecisionName = NULL;
}
#ifdef FLOATX80
floatx80_rounding_precision = roundingPrecision;
#endif
switch ( roundingMode ) {
case 0:
- roundingModeName = 0;
+ roundingModeName = NULL;
roundingCode = float_round_nearest_even;
break;
case ROUND_NEAREST_EVEN:
@@ -2098,7 +2098,7 @@ static void
float_rounding_mode = roundingCode;
switch ( tininessMode ) {
case 0:
- tininessModeName = 0;
+ tininessModeName = NULL;
tininessCode = float_tininess_after_rounding;
break;
case TININESS_BEFORE_ROUNDING:
Modified: stable/10/lib/libc/uuid/uuid_to_string.c
==============================================================================
--- stable/10/lib/libc/uuid/uuid_to_string.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/uuid/uuid_to_string.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -49,7 +49,7 @@ uuid_to_string(const uuid_t *u, char **s
*status = uuid_s_ok;
/* Why allow a NULL-pointer here? */
- if (s == 0)
+ if (s == NULL)
return;
if (u == NULL) {
Modified: stable/10/lib/libc/xdr/xdr_mem.c
==============================================================================
--- stable/10/lib/libc/xdr/xdr_mem.c Sat Dec 3 17:10:37 2016 (r309484)
+++ stable/10/lib/libc/xdr/xdr_mem.c Sat Dec 3 17:17:42 2016 (r309485)
@@ -239,7 +239,7 @@ xdrmem_inline_aligned(xdrs, len)
XDR *xdrs;
u_int len;
{
- int32_t *buf = 0;
+ int32_t *buf = NULL;
if (xdrs->x_handy >= len) {
xdrs->x_handy -= len;
More information about the svn-src-stable-10
mailing list