From owner-freebsd-bugs@FreeBSD.ORG Mon Sep 13 06:46:37 2004 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4932F16A4CE; Mon, 13 Sep 2004 06:46:37 +0000 (GMT) Received: from beaver.trit.org (beaver.trit.org [69.107.245.241]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1932543D46; Mon, 13 Sep 2004 06:46:35 +0000 (GMT) (envelope-from dd@freebsd.org) Received: by beaver.trit.org (Postfix, from userid 1000) id DDC7590DCB2; Mon, 13 Sep 2004 06:46:34 +0000 (UTC) Date: Mon, 13 Sep 2004 06:46:34 +0000 From: Dima Dorfman To: Dan Lukes Message-ID: <20040913064634.GA34521@trit.org> References: <200409130100.i8D10xDG057337@freefall.freebsd.org> <20040913031253.GD42003@trit.org> <41451B14.5050103@obluda.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41451B14.5050103@obluda.cz> User-Agent: Mutt/1.4.2.1i X-PGP-Key: 69FAE582 (http://www.trit.org/~dima/dima.asc) X-PGP-Fingerprint: B340 8338 7DA3 4D61 7632 098E 0730 055B 69FA E582 cc: freebsd-bugs@freebsd.org cc: keramida@freebsd.org 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 List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Sep 2004 06:46:37 -0000 Dan Lukes wrote: > Dima Dorfman wrote: > > Any initialization in the form "T v = v" invokes undefined behavior by > > using the indeterminate value of an object. Eliminating a warning or > > Unless compiler documentation say other ... > The v=v DURING DECLARATION (not later) is special case. I looked for such an exception in C99 before my original post, but I didn't find one. If it is indeed there, I'd appreciate a pointer--I'm genuinely curious. In either case, if it depends on the compiler documentation, then it sounds like implementation-defined behavior at best, so we'd still prefer to avoid it. > But I'm far away from pushing this way to eliminate warnings. It's no > problem to initialise variable to constant for me (I hope those patches > will not be rejected "because the initialisation is not necesarry as > variable is properly initialised later") We're not rejecting your patches, but we're making suggestions for improving them. That the initialization is not necessary could be a valid point in some cases; not everyone likes a defensive style, and spurious initializations can be confusing ("is there really a case where the initial value is used?"). It might be better to set to a bogus value only when necessary. E.g.: : int : f(int a) : { : int i, j; : : i = 0; : if (a) { : i = 1; : j = -1; /* Silence compiler warning. */ : } else : j = 1; : if (i) : return (0); : return (j); : } : This isn't appropriate in all cases either, so use your judgement. If you do decide to initialize it in the beginning, note that style(9) discourages initializers. That's not a hard-and-fast rule, either. Do I sound like a pedant yet? ;-) Dima.