svn commit: r290253 - head/lib/libc/rpc
Garrett Cooper
ngie at FreeBSD.org
Mon Nov 2 01:22:09 UTC 2015
Author: ngie
Date: Mon Nov 2 01:22:06 2015
New Revision: 290253
URL: https://svnweb.freebsd.org/changeset/base/290253
Log:
Remove unnecessary `if (x)` tests before calling `free(x)`; free(3)
already employs this check
MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
Modified:
head/lib/libc/rpc/clnt_bcast.c
head/lib/libc/rpc/clnt_vc.c
head/lib/libc/rpc/getnetconfig.c
head/lib/libc/rpc/mt_misc.c
head/lib/libc/rpc/rpc_soc.c
head/lib/libc/rpc/rpcb_clnt.c
head/lib/libc/rpc/svc.c
head/lib/libc/rpc/svc_dg.c
head/lib/libc/rpc/svc_simple.c
head/lib/libc/rpc/svc_vc.c
Modified: head/lib/libc/rpc/clnt_bcast.c
==============================================================================
--- head/lib/libc/rpc/clnt_bcast.c Mon Nov 2 01:05:34 2015 (r290252)
+++ head/lib/libc/rpc/clnt_bcast.c Mon Nov 2 01:22:06 2015 (r290253)
@@ -636,13 +636,10 @@ rpc_broadcast_exp(rpcprog_t prog, rpcver
} /* 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);
Modified: head/lib/libc/rpc/clnt_vc.c
==============================================================================
--- head/lib/libc/rpc/clnt_vc.c Mon Nov 2 01:05:34 2015 (r290252)
+++ head/lib/libc/rpc/clnt_vc.c Mon Nov 2 01:22:06 2015 (r290253)
@@ -651,8 +651,7 @@ clnt_vc_destroy(CLIENT *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);
Modified: head/lib/libc/rpc/getnetconfig.c
==============================================================================
--- head/lib/libc/rpc/getnetconfig.c Mon Nov 2 01:05:34 2015 (r290252)
+++ head/lib/libc/rpc/getnetconfig.c Mon Nov 2 01:22:06 2015 (r290253)
@@ -164,8 +164,7 @@ __nc_error(void)
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;
@@ -417,7 +416,7 @@ endnetconfig(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);
@@ -537,8 +536,7 @@ freenetconfigent(struct netconfig *netco
{
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;
@@ -628,8 +626,7 @@ parse_ncp(char *stringp, struct netconfi
} 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) {
Modified: head/lib/libc/rpc/mt_misc.c
==============================================================================
--- head/lib/libc/rpc/mt_misc.c Mon Nov 2 01:05:34 2015 (r290252)
+++ head/lib/libc/rpc/mt_misc.c Mon Nov 2 01:22:06 2015 (r290253)
@@ -106,8 +106,7 @@ __rpc_createerr(void)
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));
Modified: head/lib/libc/rpc/rpc_soc.c
==============================================================================
--- head/lib/libc/rpc/rpc_soc.c Mon Nov 2 01:05:34 2015 (r290252)
+++ head/lib/libc/rpc/rpc_soc.c Mon Nov 2 01:22:06 2015 (r290253)
@@ -432,8 +432,7 @@ clntunix_create(struct sockaddr_un *radd
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);
Modified: head/lib/libc/rpc/rpcb_clnt.c
==============================================================================
--- head/lib/libc/rpc/rpcb_clnt.c Mon Nov 2 01:05:34 2015 (r290252)
+++ head/lib/libc/rpc/rpcb_clnt.c Mon Nov 2 01:22:06 2015 (r290253)
@@ -179,8 +179,7 @@ delete_cache(struct netbuf *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
@@ -216,14 +215,10 @@ add_cache(const char *host, const char *
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;
}
@@ -256,8 +251,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;
@@ -798,10 +792,8 @@ __rpcb_findaddr_timed(rpcprog_t program,
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);
Modified: head/lib/libc/rpc/svc.c
==============================================================================
--- head/lib/libc/rpc/svc.c Mon Nov 2 01:05:34 2015 (r290252)
+++ head/lib/libc/rpc/svc.c Mon Nov 2 01:22:06 2015 (r290253)
@@ -198,8 +198,7 @@ svc_reg(SVCXPRT *xprt, const rpcprog_t p
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);
@@ -207,8 +206,7 @@ svc_reg(SVCXPRT *xprt, const rpcprog_t p
}
s = mem_alloc(sizeof (struct svc_callout));
if (s == NULL) {
- if (netid)
- free(netid);
+ free(netid);
rwlock_unlock(&svc_lock);
return (FALSE);
}
Modified: head/lib/libc/rpc/svc_dg.c
==============================================================================
--- head/lib/libc/rpc/svc_dg.c Mon Nov 2 01:05:34 2015 (r290252)
+++ head/lib/libc/rpc/svc_dg.c Mon Nov 2 01:22:06 2015 (r290253)
@@ -406,8 +406,7 @@ svc_dg_destroy(SVCXPRT *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);
}
Modified: head/lib/libc/rpc/svc_simple.c
==============================================================================
--- head/lib/libc/rpc/svc_simple.c Mon Nov 2 01:05:34 2015 (r290252)
+++ head/lib/libc/rpc/svc_simple.c Mon Nov 2 01:22:06 2015 (r290253)
@@ -166,10 +166,8 @@ rpc_reg(rpcprog_t prognum, rpcvers_t ver
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;
}
Modified: head/lib/libc/rpc/svc_vc.c
==============================================================================
--- head/lib/libc/rpc/svc_vc.c Mon Nov 2 01:05:34 2015 (r290252)
+++ head/lib/libc/rpc/svc_vc.c Mon Nov 2 01:22:06 2015 (r290253)
@@ -394,10 +394,8 @@ __svc_vc_dodestroy(SVCXPRT *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);
}
More information about the svn-src-all
mailing list