Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Dec 2009 02:47:29 +0000 (UTC)
From:      Garrett Wollman <wollman@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r200016 - in stable/8/lib/libc: gen rpc stdio yp
Message-ID:  <200912020247.nB22lTxU084418@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: wollman
Date: Wed Dec  2 02:47:29 2009
New Revision: 200016
URL: http://svn.freebsd.org/changeset/base/200016

Log:
  MFC revs 199781,199782,199784,199785,199786:
  
    Eliminate dead stores.
  
    In __mbsconv(), if prec was zero, nconv could have been used
    uninitialized.  Initialize it to a safe value so that there's no
    chance of returning an error if stack garbage happens to be equal to
    (size_t)-1 or (size_t)-2.
  
    In svc_raw_reply(), don't leave stat uninitialized if the MSG_ACCEPTED
    && SUCCESS case succeeds.  The stack garbage might be zero.
  
    In clnt_raw_create(), avoid minor race condition initializing the
    file-scope variable clntraw_private.
  
  Found by:		Clang static analyzer

Modified:
  stable/8/lib/libc/gen/getcap.c
  stable/8/lib/libc/gen/getusershell.c
  stable/8/lib/libc/gen/wordexp.c
  stable/8/lib/libc/rpc/clnt_raw.c
  stable/8/lib/libc/rpc/getnetconfig.c
  stable/8/lib/libc/rpc/key_call.c
  stable/8/lib/libc/rpc/svc_raw.c
  stable/8/lib/libc/stdio/fgetws.c
  stable/8/lib/libc/stdio/fvwrite.c
  stable/8/lib/libc/stdio/vfwprintf.c
  stable/8/lib/libc/yp/yplib.c
Directory Properties:
  stable/8/lib/libc/   (props changed)
  stable/8/lib/libc/stdtime/   (props changed)

Modified: stable/8/lib/libc/gen/getcap.c
==============================================================================
--- stable/8/lib/libc/gen/getcap.c	Wed Dec  2 00:38:11 2009	(r200015)
+++ stable/8/lib/libc/gen/getcap.c	Wed Dec  2 02:47:29 2009	(r200016)
@@ -647,7 +647,7 @@ int
 cgetnext(char **bp, char **db_array)
 {
 	size_t len;
-	int done, hadreaderr, i, savederrno, status;
+	int done, hadreaderr, savederrno, status;
 	char *cp, *line, *rp, *np, buf[BSIZE], nbuf[BSIZE];
 	u_int dummy;
 
@@ -658,7 +658,7 @@ cgetnext(char **bp, char **db_array)
 		(void)cgetclose();
 		return (-1);
 	}
-	for(;;) {
+	for (;;) {
 		if (toprec && !gottoprec) {
 			gottoprec = 1;
 			line = toprec;
@@ -709,7 +709,6 @@ cgetnext(char **bp, char **db_array)
 		/*
 		 * Line points to a name line.
 		 */
-		i = 0;
 		done = 0;
 		np = nbuf;
 		for (;;) {

Modified: stable/8/lib/libc/gen/getusershell.c
==============================================================================
--- stable/8/lib/libc/gen/getusershell.c	Wed Dec  2 00:38:11 2009	(r200015)
+++ stable/8/lib/libc/gen/getusershell.c	Wed Dec  2 02:47:29 2009	(r200016)
@@ -124,7 +124,7 @@ _local_initshells(rv, cb_data, ap)
 	if ((fp = fopen(_PATH_SHELLS, "r")) == NULL)
 		return NS_UNAVAIL;
 
-	sp = cp = line;
+	cp = line;
 	while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) {
 		while (*cp != '#' && *cp != '/' && *cp != '\0')
 			cp++;

Modified: stable/8/lib/libc/gen/wordexp.c
==============================================================================
--- stable/8/lib/libc/gen/wordexp.c	Wed Dec  2 00:38:11 2009	(r200015)
+++ stable/8/lib/libc/gen/wordexp.c	Wed Dec  2 02:47:29 2009	(r200016)
@@ -282,7 +282,7 @@ we_check(const char *words, int flags)
 				if (c == '\0' || level != 0)
 					return (WRDE_SYNTAX);
 			} else
-				c = *--words;
+				--words;
 			break;
 		default:
 			break;

Modified: stable/8/lib/libc/rpc/clnt_raw.c
==============================================================================
--- stable/8/lib/libc/rpc/clnt_raw.c	Wed Dec  2 00:38:11 2009	(r200015)
+++ stable/8/lib/libc/rpc/clnt_raw.c	Wed Dec  2 02:47:29 2009	(r200016)
@@ -92,13 +92,13 @@ clnt_raw_create(prog, vers)
 	rpcprog_t prog;
 	rpcvers_t vers;
 {
-	struct clntraw_private *clp = clntraw_private;
+	struct clntraw_private *clp;
 	struct rpc_msg call_msg;
-	XDR *xdrs = &clp->xdr_stream;
-	CLIENT	*client = &clp->client_object;
+	XDR *xdrs;
+	CLIENT	*client;
 
 	mutex_lock(&clntraw_lock);
-	if (clp == NULL) {
+	if ((clp = clntraw_private) == NULL) {
 		clp = (struct clntraw_private *)calloc(1, sizeof (*clp));
 		if (clp == NULL) {
 			mutex_unlock(&clntraw_lock);
@@ -110,6 +110,9 @@ clnt_raw_create(prog, vers)
 		clp->_raw_buf = __rpc_rawcombuf;
 		clntraw_private = clp;
 	}
+	xdrs = &clp->xdr_stream;
+	client = &clp->client_object;
+
 	/*
 	 * pre-serialize the static part of the call msg and stash it away
 	 */

Modified: stable/8/lib/libc/rpc/getnetconfig.c
==============================================================================
--- stable/8/lib/libc/rpc/getnetconfig.c	Wed Dec  2 00:38:11 2009	(r200015)
+++ stable/8/lib/libc/rpc/getnetconfig.c	Wed Dec  2 02:47:29 2009	(r200016)
@@ -412,13 +412,13 @@ void *handlep;
      * Noone needs these entries anymore, then frees them.
      * Make sure all info in netconfig_info structure has been reinitialized.
      */
-    q = p = ni.head;
+    q = ni.head;
     ni.eof = ni.ref = 0;
     ni.head = NULL;
     ni.tail = NULL;
     mutex_unlock(&ni_lock);
 
-    while (q) {
+    while (q != NULL) {
 	p = q->next;
 	if (q->ncp->nc_lookups != NULL) free(q->ncp->nc_lookups);
 	free(q->ncp);

Modified: stable/8/lib/libc/rpc/key_call.c
==============================================================================
--- stable/8/lib/libc/rpc/key_call.c	Wed Dec  2 00:38:11 2009	(r200015)
+++ stable/8/lib/libc/rpc/key_call.c	Wed Dec  2 02:47:29 2009	(r200016)
@@ -302,7 +302,7 @@ int	vers;
 	void *localhandle;
 	struct netconfig *nconf;
 	struct netconfig *tpconf;
-	struct key_call_private *kcp = key_call_private_main;
+	struct key_call_private *kcp;
 	struct timeval wait_time;
 	struct utsname u;
 	int main_thread;

Modified: stable/8/lib/libc/rpc/svc_raw.c
==============================================================================
--- stable/8/lib/libc/rpc/svc_raw.c	Wed Dec  2 00:38:11 2009	(r200015)
+++ stable/8/lib/libc/rpc/svc_raw.c	Wed Dec  2 02:47:29 2009	(r200016)
@@ -176,9 +176,8 @@ svc_raw_reply(xprt, msg)
 		msg->acpted_rply.ar_results.proc = (xdrproc_t) xdr_void;
 		msg->acpted_rply.ar_results.where = NULL;
 
-		if (!xdr_replymsg(xdrs, msg) ||
-		    !SVCAUTH_WRAP(&SVC_AUTH(xprt), xdrs, xdr_proc, xdr_where))
-			stat = FALSE;
+		stat = xdr_replymsg(xdrs, msg) &&
+		    SVCAUTH_WRAP(&SVC_AUTH(xprt), xdrs, xdr_proc, xdr_where);
 	} else {
 		stat = xdr_replymsg(xdrs, msg);
 	}

Modified: stable/8/lib/libc/stdio/fgetws.c
==============================================================================
--- stable/8/lib/libc/stdio/fgetws.c	Wed Dec  2 00:38:11 2009	(r200015)
+++ stable/8/lib/libc/stdio/fgetws.c	Wed Dec  2 02:47:29 2009	(r200016)
@@ -89,7 +89,7 @@ fgetws(wchar_t * __restrict ws, int n, F
 	if (!__mbsinit(&fp->_mbstate))
 		/* Incomplete character */
 		goto error;
-	*wsp++ = L'\0';
+	*wsp = L'\0';
 	FUNLOCKFILE(fp);
 
 	return (ws);

Modified: stable/8/lib/libc/stdio/fvwrite.c
==============================================================================
--- stable/8/lib/libc/stdio/fvwrite.c	Wed Dec  2 00:38:11 2009	(r200015)
+++ stable/8/lib/libc/stdio/fvwrite.c	Wed Dec  2 02:47:29 2009	(r200016)
@@ -60,7 +60,7 @@ __sfvwrite(fp, uio)
 	char *nl;
 	int nlknown, nldist;
 
-	if ((len = uio->uio_resid) == 0)
+	if (uio->uio_resid == 0)
 		return (0);
 	/* make sure we can write */
 	if (prepwrite(fp) != 0)

Modified: stable/8/lib/libc/stdio/vfwprintf.c
==============================================================================
--- stable/8/lib/libc/stdio/vfwprintf.c	Wed Dec  2 00:38:11 2009	(r200015)
+++ stable/8/lib/libc/stdio/vfwprintf.c	Wed Dec  2 02:47:29 2009	(r200016)
@@ -293,7 +293,7 @@ __mbsconv(char *mbsarg, int prec)
 		 * number of characters to print.
 		 */
 		p = mbsarg;
-		insize = nchars = 0;
+		insize = nchars = nconv = 0;
 		mbs = initial_mbs;
 		while (nchars != (size_t)prec) {
 			nconv = mbrlen(p, MB_CUR_MAX, &mbs);

Modified: stable/8/lib/libc/yp/yplib.c
==============================================================================
--- stable/8/lib/libc/yp/yplib.c	Wed Dec  2 00:38:11 2009	(r200015)
+++ stable/8/lib/libc/yp/yplib.c	Wed Dec  2 02:47:29 2009	(r200016)
@@ -241,7 +241,7 @@ static bool_t
 ypmatch_cache_lookup(struct dom_binding *ypdb, char *map, keydat *key,
     valdat *val)
 {
-	struct ypmatch_ent	*c = ypdb->cache;
+	struct ypmatch_ent	*c;
 
 	ypmatch_cache_expire(ypdb);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912020247.nB22lTxU084418>