Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 01 Feb 2014 23:11:20 +0400
From:      Boris Samorodov <bsam@passap.ru>
To:        FreeBSD CURRENT <freebsd-current@freebsd.org>
Subject:   [patch: libc/rpc/svc_vc.c] clang analyser: Branch condition evaluates to a garbage value
Message-ID:  <52ED46D8.9050001@passap.ru>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Hi All,

While using clang static analyzer at CURRENT (r261322) I got:
http://gw.wart.ru/2014-02-01-200848-39517-1/report-01bc48.html

There is no need at line 143 to "goto cleanup_svc_vc_create" (neither
xprt nor r are allocated so far). Just "return NULL" should be fine.
BTW, NetBSD do the latter as well.

So I propose a tiny patch (attached).

-- 
WBR, Boris Samorodov (bsam)
FreeBSD Committer, http://www.FreeBSD.org The Power To Serve


[-- Attachment #2 --]
Index: /usr/src/lib/libc/rpc/svc_vc.c
===================================================================
--- /usr/src/lib/libc/rpc/svc_vc.c	(revision 260036)
+++ /usr/src/lib/libc/rpc/svc_vc.c	(working copy)
@@ -141,7 +141,7 @@
 	r = mem_alloc(sizeof(*r));
 	if (r == NULL) {
 		warnx("svc_vc_create: out of memory");
-		goto cleanup_svc_vc_create;
+		return NULL;
 	}
 	r->sendsize = __rpc_get_t_size(si.si_af, si.si_proto, (int)sendsize);
 	r->recvsize = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsize);

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