svn commit: r291054 - stable/9/lib/libc/rpc

Garrett Cooper ngie at FreeBSD.org
Thu Nov 19 03:53:34 UTC 2015


Author: ngie
Date: Thu Nov 19 03:53:31 2015
New Revision: 291054
URL: https://svnweb.freebsd.org/changeset/base/291054

Log:
  MFstable/10 r290899:
  
  MFC r290253:
  
  Remove unnecessary `if (x)` tests before calling `free(x)`; free(3)
  already employs this check
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  stable/9/lib/libc/rpc/clnt_bcast.c
  stable/9/lib/libc/rpc/clnt_vc.c
  stable/9/lib/libc/rpc/getnetconfig.c
  stable/9/lib/libc/rpc/mt_misc.c
  stable/9/lib/libc/rpc/rpc_soc.c
  stable/9/lib/libc/rpc/rpcb_clnt.c
  stable/9/lib/libc/rpc/svc.c
  stable/9/lib/libc/rpc/svc_dg.c
  stable/9/lib/libc/rpc/svc_simple.c
  stable/9/lib/libc/rpc/svc_vc.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/lib/   (props changed)
  stable/9/lib/libc/   (props changed)

Modified: stable/9/lib/libc/rpc/clnt_bcast.c
==============================================================================
--- stable/9/lib/libc/rpc/clnt_bcast.c	Thu Nov 19 03:11:20 2015	(r291053)
+++ stable/9/lib/libc/rpc/clnt_bcast.c	Thu Nov 19 03:53:31 2015	(r291054)
@@ -631,13 +631,10 @@ rpc_broadcast_exp(prog, vers, proc, xarg
 	}			/* 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: stable/9/lib/libc/rpc/clnt_vc.c
==============================================================================
--- stable/9/lib/libc/rpc/clnt_vc.c	Thu Nov 19 03:11:20 2015	(r291053)
+++ stable/9/lib/libc/rpc/clnt_vc.c	Thu Nov 19 03:53:31 2015	(r291054)
@@ -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);

Modified: stable/9/lib/libc/rpc/getnetconfig.c
==============================================================================
--- stable/9/lib/libc/rpc/getnetconfig.c	Thu Nov 19 03:11:20 2015	(r291053)
+++ stable/9/lib/libc/rpc/getnetconfig.c	Thu Nov 19 03:53:31 2015	(r291054)
@@ -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 r
     } 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: stable/9/lib/libc/rpc/mt_misc.c
==============================================================================
--- stable/9/lib/libc/rpc/mt_misc.c	Thu Nov 19 03:11:20 2015	(r291053)
+++ stable/9/lib/libc/rpc/mt_misc.c	Thu Nov 19 03:53:31 2015	(r291054)
@@ -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));

Modified: stable/9/lib/libc/rpc/rpc_soc.c
==============================================================================
--- stable/9/lib/libc/rpc/rpc_soc.c	Thu Nov 19 03:11:20 2015	(r291053)
+++ stable/9/lib/libc/rpc/rpc_soc.c	Thu Nov 19 03:53:31 2015	(r291054)
@@ -472,8 +472,7 @@ clntunix_create(raddr, prog, vers, 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);

Modified: stable/9/lib/libc/rpc/rpcb_clnt.c
==============================================================================
--- stable/9/lib/libc/rpc/rpcb_clnt.c	Thu Nov 19 03:11:20 2015	(r291053)
+++ stable/9/lib/libc/rpc/rpcb_clnt.c	Thu Nov 19 03:53:31 2015	(r291054)
@@ -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, 
 			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: stable/9/lib/libc/rpc/svc.c
==============================================================================
--- stable/9/lib/libc/rpc/svc.c	Thu Nov 19 03:11:20 2015	(r291053)
+++ stable/9/lib/libc/rpc/svc.c	Thu Nov 19 03:53:31 2015	(r291054)
@@ -201,8 +201,7 @@ svc_reg(xprt, prog, vers, dispatch, ncon
 
 	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, ncon
 	}
 	s = mem_alloc(sizeof (struct svc_callout));
 	if (s == NULL) {
-		if (netid)
-			free(netid);
+		free(netid);
 		rwlock_unlock(&svc_lock);
 		return (FALSE);
 	}

Modified: stable/9/lib/libc/rpc/svc_dg.c
==============================================================================
--- stable/9/lib/libc/rpc/svc_dg.c	Thu Nov 19 03:11:20 2015	(r291053)
+++ stable/9/lib/libc/rpc/svc_dg.c	Thu Nov 19 03:53:31 2015	(r291054)
@@ -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);
 }
 

Modified: stable/9/lib/libc/rpc/svc_simple.c
==============================================================================
--- stable/9/lib/libc/rpc/svc_simple.c	Thu Nov 19 03:11:20 2015	(r291053)
+++ stable/9/lib/libc/rpc/svc_simple.c	Thu Nov 19 03:53:31 2015	(r291054)
@@ -164,10 +164,8 @@ rpc_reg(prognum, versnum, procnum, progn
 			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: stable/9/lib/libc/rpc/svc_vc.c
==============================================================================
--- stable/9/lib/libc/rpc/svc_vc.c	Thu Nov 19 03:11:20 2015	(r291053)
+++ stable/9/lib/libc/rpc/svc_vc.c	Thu Nov 19 03:53:31 2015	(r291054)
@@ -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);
 }
 


More information about the svn-src-stable-9 mailing list