svn commit: r301802 - stable/9/sys/rpc

Garrett Cooper ngie at FreeBSD.org
Fri Jun 10 17:59:32 UTC 2016


Author: ngie
Date: Fri Jun 10 17:59:30 2016
New Revision: 301802
URL: https://svnweb.freebsd.org/changeset/base/301802

Log:
  MFstable/10 r301801:
  
  MFC r300836:
  
  Quell false positives in svc_vc_create and svc_vc_create_conn with cd and xprt
  
  Both cd and xprt will be non-NULL after their respective malloc(9) wrappers are
  called (mem_alloc and svc_xprt_alloc, which calls mem_alloc) as mem_alloc
  always gets called with M_WAITOK|M_ZERO today. Thus, testing for them being
  non-NULL is incorrect -- it misleads Coverity and it misleads the reader.
  
  Remove some unnecessary NULL initializations as a follow up to help solidify
  the fact that these pointers will be initialized properly in sys/rpc/.. with
  the interfaces the way they are currently.
  
  CID: 1007338, 1007339, 1007340

Modified:
  stable/9/sys/rpc/svc_vc.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/sys/   (props changed)

Modified: stable/9/sys/rpc/svc_vc.c
==============================================================================
--- stable/9/sys/rpc/svc_vc.c	Fri Jun 10 17:57:50 2016	(r301801)
+++ stable/9/sys/rpc/svc_vc.c	Fri Jun 10 17:59:30 2016	(r301802)
@@ -186,11 +186,11 @@ svc_vc_create(SVCPOOL *pool, struct sock
 	SOCKBUF_UNLOCK(&so->so_rcv);
 
 	return (xprt);
+
 cleanup_svc_vc_create:
-	if (xprt) {
-		sx_destroy(&xprt->xp_lock);
-		svc_xprt_free(xprt);
-	}
+	sx_destroy(&xprt->xp_lock);
+	svc_xprt_free(xprt);
+
 	return (NULL);
 }
 
@@ -200,8 +200,8 @@ cleanup_svc_vc_create:
 SVCXPRT *
 svc_vc_create_conn(SVCPOOL *pool, struct socket *so, struct sockaddr *raddr)
 {
-	SVCXPRT *xprt = NULL;
-	struct cf_conn *cd = NULL;
+	SVCXPRT *xprt;
+	struct cf_conn *cd;
 	struct sockaddr* sa = NULL;
 	struct sockopt opt;
 	int one = 1;
@@ -274,12 +274,10 @@ svc_vc_create_conn(SVCPOOL *pool, struct
 
 	return (xprt);
 cleanup_svc_vc_create:
-	if (xprt) {
-		sx_destroy(&xprt->xp_lock);
-		svc_xprt_free(xprt);
-	}
-	if (cd)
-		mem_free(cd, sizeof(*cd));
+	sx_destroy(&xprt->xp_lock);
+	svc_xprt_free(xprt);
+	mem_free(cd, sizeof(*cd));
+
 	return (NULL);
 }
 


More information about the svn-src-all mailing list