Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Sep 2004 20:10:48 GMT
From:      Giorgos Keramidas <keramida@freebsd.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/71628: [PATCH] cleanup of the usr.sbin/rpcbind code
Message-ID:  <200409122010.i8CKAmSf028200@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/71628; it has been noted by GNATS.

From: Giorgos Keramidas <keramida@freebsd.org>
To: Dan Lukes <dan@obluda.cz>
Cc: alfred@freebsd.org, bug-followup@freebsd.org
Subject: Re: bin/71628: [PATCH] cleanup of the usr.sbin/rpcbind code
Date: Sun, 12 Sep 2004 22:39:20 +0300

 On 2004-09-12 04:38, Dan Lukes <dan@obluda.cz> wrote:
 >   static int
 >   init_transport(struct netconfig *nconf)
 >   {
 > - 	int fd;
 > + 	int fd = fd;  /* init to suppres "may be used uninitialized" warning */
 
 Err, no please.  GCC complains that fd "may be used uninitialized" because
 of this construct near line 275 and the rest of the function body:
 
     275         if (nconf->nc_semantics != NC_TPI_CLTS) {
     276                 if ((fd = __rpc_nconf2fd(nconf)) < 0) {
     277                         int non_fatal = 0;
     ...
     283                         return (1);
     284                 }
     ...
     311         if (nconf->nc_semantics == NC_TPI_CLTS) {
     ...
     334                 while (nhostsbak > 0) {
     ...
     339                         if ((fd = __rpc_nconf2fd(nconf)) < 0) {
     ...
     452         } else {
     ...
     466                 if (bind(fd, sa, addrlen) < 0) {
 
 Pay attention to this last line.  GCC believes that fd can be used
 uninitialized because if NC_TPI_CLTS is not used the bind() call will
 receive an uninitialized value of `fd'.  I'm not acquainted with the
 internals of rpcbind() at all, but I know that Alfred Perlstein is.
 He's probably the best person to suggest a fix for this warning, if one
 is really needed.
 
 >   	struct t_bind taddr;
 >   	struct addrinfo hints, *res = NULL;
 >   	struct __rpc_sockinfo si;
 > - 	SVCXPRT	*my_xprt;
 > ! 	SVCXPRT	*my_xprt = my_xprt; /* init to suppres "may be used uninitialized" warning */
 
 No.  I don't know why you think that this is a good fix for all the
 uninitialized pointer warnings.  It's not.  Never :-/
 
 This warning is probably caused by GCC's inability to make sure that when
 `bar' is a pointer this construct is perfectly fine:
 
 	if (foo) {
 		...
 		if (bar = baz())
 			...
 	} else {
 		...
 		if (bar = baz2())
 			...
 	}
 
 	if (blah(bar))
 		...
 
 After a quick glance at the source of rpcbind() I think that there's no way
 that my_xrpt can be used uninitialized.  A proper fix for this warning
 would be then to just set my_xrpt to NULL at first and let the rest of the
 function unchanged regarding my_xrpt.
 



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