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
This commit is contained in:
parent
2a923f8f3c
commit
c7f7fdd28b
@ -636,13 +636,10 @@ rpc_broadcast_exp(rpcprog_t prog, rpcvers_t vers, rpcproc_t proc,
|
||||
} /* 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);
|
||||
|
@ -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);
|
||||
|
@ -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 *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;
|
||||
@ -628,8 +626,7 @@ parse_ncp(char *stringp, struct netconfig *ncp)
|
||||
} 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) {
|
||||
|
@ -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));
|
||||
|
@ -432,8 +432,7 @@ clntunix_create(struct sockaddr_un *raddr, u_long prog, u_long vers, int *sockp,
|
||||
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);
|
||||
|
@ -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 *netid, struct netbuf *taddr,
|
||||
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, rpcvers_t version,
|
||||
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);
|
||||
|
@ -198,8 +198,7 @@ svc_reg(SVCXPRT *xprt, const rpcprog_t prog, const rpcvers_t vers,
|
||||
|
||||
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 prog, const rpcvers_t vers,
|
||||
}
|
||||
s = mem_alloc(sizeof (struct svc_callout));
|
||||
if (s == NULL) {
|
||||
if (netid)
|
||||
free(netid);
|
||||
free(netid);
|
||||
rwlock_unlock(&svc_lock);
|
||||
return (FALSE);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -166,10 +166,8 @@ rpc_reg(rpcprog_t prognum, rpcvers_t versnum, rpcproc_t procnum,
|
||||
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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user