summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2015-11-16 01:09:25 +0000
committerngie <ngie@FreeBSD.org>2015-11-16 01:09:25 +0000
commitd1d4e816ce49797ab1f23bb48cf5ee69018df284 (patch)
tree4e5e4d6985ae985e5c979066b6ee48d7ea1f7f54 /lib/libc
parent97443342e5a249ebb1eed68e40fe7e8864ed1781 (diff)
downloadFreeBSD-src-d1d4e816ce49797ab1f23bb48cf5ee69018df284.zip
FreeBSD-src-d1d4e816ce49797ab1f23bb48cf5ee69018df284.tar.gz
MFC r290253:
Remove unnecessary `if (x)` tests before calling `free(x)`; free(3) already employs this check Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/rpc/clnt_bcast.c9
-rw-r--r--lib/libc/rpc/clnt_vc.c3
-rw-r--r--lib/libc/rpc/getnetconfig.c11
-rw-r--r--lib/libc/rpc/mt_misc.c3
-rw-r--r--lib/libc/rpc/rpc_soc.c3
-rw-r--r--lib/libc/rpc/rpcb_clnt.c24
-rw-r--r--lib/libc/rpc/svc.c6
-rw-r--r--lib/libc/rpc/svc_dg.c3
-rw-r--r--lib/libc/rpc/svc_simple.c6
-rw-r--r--lib/libc/rpc/svc_vc.c6
10 files changed, 25 insertions, 49 deletions
diff --git a/lib/libc/rpc/clnt_bcast.c b/lib/libc/rpc/clnt_bcast.c
index 6ee1f90..5f78dce 100644
--- a/lib/libc/rpc/clnt_bcast.c
+++ b/lib/libc/rpc/clnt_bcast.c
@@ -631,13 +631,10 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
} /* The giant for loop */
done_broad:
- if (inbuf)
- (void) free(inbuf);
- if (outbuf)
- (void) free(outbuf);
+ free(inbuf);
+ free(outbuf);
#ifdef PORTMAP
- if (outbuf_pmap)
- (void) free(outbuf_pmap);
+ free(outbuf_pmap);
#endif /* PORTMAP */
for (i = 0; i < fdlistno; i++) {
(void)_close(fdlist[i].fd);
diff --git a/lib/libc/rpc/clnt_vc.c b/lib/libc/rpc/clnt_vc.c
index 117cfba..2c18850 100644
--- a/lib/libc/rpc/clnt_vc.c
+++ b/lib/libc/rpc/clnt_vc.c
@@ -666,8 +666,7 @@ clnt_vc_destroy(cl)
(void)_close(ct->ct_fd);
}
XDR_DESTROY(&(ct->ct_xdrs));
- if (ct->ct_addr.buf)
- free(ct->ct_addr.buf);
+ free(ct->ct_addr.buf);
mem_free(ct, sizeof(struct ct_data));
if (cl->cl_netid && cl->cl_netid[0])
mem_free(cl->cl_netid, strlen(cl->cl_netid) +1);
diff --git a/lib/libc/rpc/getnetconfig.c b/lib/libc/rpc/getnetconfig.c
index 34be6e1..66b9f83 100644
--- a/lib/libc/rpc/getnetconfig.c
+++ b/lib/libc/rpc/getnetconfig.c
@@ -164,8 +164,7 @@ __nc_error()
if ((nc_addr = (int *)thr_getspecific(nc_key)) == NULL) {
nc_addr = (int *)malloc(sizeof (int));
if (thr_setspecific(nc_key, (void *) nc_addr) != 0) {
- if (nc_addr)
- free(nc_addr);
+ free(nc_addr);
return (&nc_error);
}
*nc_addr = 0;
@@ -419,7 +418,7 @@ void *handlep;
while (q != NULL) {
p = q->next;
- if (q->ncp->nc_lookups != NULL) free(q->ncp->nc_lookups);
+ free(q->ncp->nc_lookups);
free(q->ncp);
free(q->linep);
free(q);
@@ -541,8 +540,7 @@ freenetconfigent(netconfigp)
{
if (netconfigp != NULL) {
free(netconfigp->nc_netid); /* holds all netconfigp's strings */
- if (netconfigp->nc_lookups != NULL)
- free(netconfigp->nc_lookups);
+ free(netconfigp->nc_lookups);
free(netconfigp);
}
return;
@@ -631,8 +629,7 @@ struct netconfig *ncp; /* where to put results */
} else {
char *cp; /* tmp string */
- if (ncp->nc_lookups != NULL) /* from last visit */
- free(ncp->nc_lookups);
+ free(ncp->nc_lookups); /* from last visit */
ncp->nc_lookups = NULL;
ncp->nc_nlookups = 0;
while ((cp = tokenp) != NULL) {
diff --git a/lib/libc/rpc/mt_misc.c b/lib/libc/rpc/mt_misc.c
index 7abcaed..54712b0 100644
--- a/lib/libc/rpc/mt_misc.c
+++ b/lib/libc/rpc/mt_misc.c
@@ -106,8 +106,7 @@ __rpc_createerr()
rce_addr = (struct rpc_createerr *)
malloc(sizeof (struct rpc_createerr));
if (thr_setspecific(rce_key, (void *) rce_addr) != 0) {
- if (rce_addr)
- free(rce_addr);
+ free(rce_addr);
return (&rpc_createerr);
}
memset(rce_addr, 0, sizeof (struct rpc_createerr));
diff --git a/lib/libc/rpc/rpc_soc.c b/lib/libc/rpc/rpc_soc.c
index d7702f5..fbcec05 100644
--- a/lib/libc/rpc/rpc_soc.c
+++ b/lib/libc/rpc/rpc_soc.c
@@ -472,8 +472,7 @@ clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz)
if ((raddr->sun_len == 0) ||
((svcaddr = malloc(sizeof(struct netbuf))) == NULL ) ||
((svcaddr->buf = malloc(sizeof(struct sockaddr_un))) == NULL)) {
- if (svcaddr != NULL)
- free(svcaddr);
+ free(svcaddr);
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
return(cl);
diff --git a/lib/libc/rpc/rpcb_clnt.c b/lib/libc/rpc/rpcb_clnt.c
index a0d840e..943d7c8 100644
--- a/lib/libc/rpc/rpcb_clnt.c
+++ b/lib/libc/rpc/rpcb_clnt.c
@@ -183,8 +183,7 @@ delete_cache(addr)
free(cptr->ac_netid);
free(cptr->ac_taddr->buf);
free(cptr->ac_taddr);
- if (cptr->ac_uaddr)
- free(cptr->ac_uaddr);
+ free(cptr->ac_uaddr);
if (prevptr)
prevptr->ac_next = cptr->ac_next;
else
@@ -222,14 +221,10 @@ add_cache(host, netid, taddr, uaddr)
ad_cache->ac_taddr->buf = (char *) malloc(taddr->len);
if (ad_cache->ac_taddr->buf == NULL) {
out:
- if (ad_cache->ac_host)
- free(ad_cache->ac_host);
- if (ad_cache->ac_netid)
- free(ad_cache->ac_netid);
- if (ad_cache->ac_uaddr)
- free(ad_cache->ac_uaddr);
- if (ad_cache->ac_taddr)
- free(ad_cache->ac_taddr);
+ free(ad_cache->ac_host);
+ free(ad_cache->ac_netid);
+ free(ad_cache->ac_uaddr);
+ free(ad_cache->ac_taddr);
free(ad_cache);
return;
}
@@ -262,8 +257,7 @@ out:
free(cptr->ac_netid);
free(cptr->ac_taddr->buf);
free(cptr->ac_taddr);
- if (cptr->ac_uaddr)
- free(cptr->ac_uaddr);
+ free(cptr->ac_uaddr);
if (prevptr) {
prevptr->ac_next = NULL;
@@ -816,10 +810,8 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp)
malloc(remote.len)) == NULL)) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
clnt_geterr(client, &rpc_createerr.cf_error);
- if (address) {
- free(address);
- address = NULL;
- }
+ free(address);
+ address = NULL;
goto error;
}
memcpy(address->buf, remote.buf, remote.len);
diff --git a/lib/libc/rpc/svc.c b/lib/libc/rpc/svc.c
index fff04c0..49b14d3 100644
--- a/lib/libc/rpc/svc.c
+++ b/lib/libc/rpc/svc.c
@@ -201,8 +201,7 @@ svc_reg(xprt, prog, vers, dispatch, nconf)
rwlock_wrlock(&svc_lock);
if ((s = svc_find(prog, vers, &prev, netid)) != NULL) {
- if (netid)
- free(netid);
+ free(netid);
if (s->sc_dispatch == dispatch)
goto rpcb_it; /* he is registering another xptr */
rwlock_unlock(&svc_lock);
@@ -210,8 +209,7 @@ svc_reg(xprt, prog, vers, dispatch, nconf)
}
s = mem_alloc(sizeof (struct svc_callout));
if (s == NULL) {
- if (netid)
- free(netid);
+ free(netid);
rwlock_unlock(&svc_lock);
return (FALSE);
}
diff --git a/lib/libc/rpc/svc_dg.c b/lib/libc/rpc/svc_dg.c
index 980e39f..1591872 100644
--- a/lib/libc/rpc/svc_dg.c
+++ b/lib/libc/rpc/svc_dg.c
@@ -421,8 +421,7 @@ svc_dg_destroy(xprt)
(void) mem_free(xprt->xp_rtaddr.buf, xprt->xp_rtaddr.maxlen);
if (xprt->xp_ltaddr.buf)
(void) mem_free(xprt->xp_ltaddr.buf, xprt->xp_ltaddr.maxlen);
- if (xprt->xp_tp)
- (void) free(xprt->xp_tp);
+ free(xprt->xp_tp);
svc_xprt_free(xprt);
}
diff --git a/lib/libc/rpc/svc_simple.c b/lib/libc/rpc/svc_simple.c
index b97f974..942d07e 100644
--- a/lib/libc/rpc/svc_simple.c
+++ b/lib/libc/rpc/svc_simple.c
@@ -164,10 +164,8 @@ rpc_reg(prognum, versnum, procnum, progname, inproc, outproc, nettype)
if (((xdrbuf = malloc((unsigned)recvsz)) == NULL) ||
((netid = strdup(nconf->nc_netid)) == NULL)) {
warnx(rpc_reg_err, rpc_reg_msg, __no_mem_str);
- if (xdrbuf != NULL)
- free(xdrbuf);
- if (netid != NULL)
- free(netid);
+ free(xdrbuf);
+ free(netid);
SVC_DESTROY(svcxprt);
break;
}
diff --git a/lib/libc/rpc/svc_vc.c b/lib/libc/rpc/svc_vc.c
index f830425..31edb93 100644
--- a/lib/libc/rpc/svc_vc.c
+++ b/lib/libc/rpc/svc_vc.c
@@ -408,10 +408,8 @@ __svc_vc_dodestroy(xprt)
mem_free(xprt->xp_rtaddr.buf, xprt->xp_rtaddr.maxlen);
if (xprt->xp_ltaddr.buf)
mem_free(xprt->xp_ltaddr.buf, xprt->xp_ltaddr.maxlen);
- if (xprt->xp_tp)
- free(xprt->xp_tp);
- if (xprt->xp_netid)
- free(xprt->xp_netid);
+ free(xprt->xp_tp);
+ free(xprt->xp_netid);
svc_xprt_free(xprt);
}
OpenPOWER on IntegriCloud