From owner-freebsd-bugs@FreeBSD.ORG Mon Sep 13 06:00:48 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DF86216A501 for ; Mon, 13 Sep 2004 06:00:48 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id CE2C143D2F for ; Mon, 13 Sep 2004 06:00:48 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i8D60mvb015046 for ; Mon, 13 Sep 2004 06:00:48 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i8D60msi015043; Mon, 13 Sep 2004 06:00:48 GMT (envelope-from gnats) Date: Mon, 13 Sep 2004 06:00:48 GMT Message-Id: <200409130600.i8D60msi015043@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Giorgos Keramidas Subject: Re: bin/71628: [PATCH] cleanup of the usr.sbin/rpcbind code X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Giorgos Keramidas List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Sep 2004 06:00:49 -0000 The following reply was made to PR bin/71628; it has been noted by GNATS. From: Giorgos Keramidas To: Dan Lukes Cc: alfred@freebsd.org, bug-followup@freebsd.org Subject: Re: bin/71628: [PATCH] cleanup of the usr.sbin/rpcbind code Date: Mon, 13 Sep 2004 08:49:07 +0300 On 2004-09-13 02:57, Dan Lukes wrote: >On Sun, 12 Sep 2004, Giorgos Keramidas wrote: >> 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. > > The unnecesarry initialisation of variable initialised again later > seems to be vaste of resources. But IMHO only. True, but this is not the case here. If you do initialize the value of my_xrpt to something (i.e. to whatever value happens to be held in my_xrpt at the time execution reaches the point of its declaration), you should at least set it to something that is Right(TM). This initialization char *foo = foo; is not cheaper than this one: char *foo = NULL; so if you're going to pay the penalty of initializing a variable to shuttup the compiler, the second is preferrable because it explicitly sets the pointer to a value that cannot be dereferenced. This will catch possible bugs (current or future) in the rest of the code, so it's a lot safer.