From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/3420 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] bugfix: initialize a state variable in lio_wait Date: Sun, 16 Jun 2013 10:24:35 -0400 Message-ID: <20130616142435.GK29800@brightrain.aerifal.cx> References: <1371333657.16425.350.camel@eris.loria.fr> <20130615221627.GB6548@port70.net> <20130616054006.GJ29800@brightrain.aerifal.cx> <1371367371.16425.363.camel@eris.loria.fr> <1371375118.16425.368.camel@eris.loria.fr> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1371392690 11801 80.91.229.3 (16 Jun 2013 14:24:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 16 Jun 2013 14:24:50 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-3424-gllmg-musl=m.gmane.org@lists.openwall.com Sun Jun 16 16:24:51 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1UoDsv-0000gP-Qm for gllmg-musl@plane.gmane.org; Sun, 16 Jun 2013 16:24:49 +0200 Original-Received: (qmail 1546 invoked by uid 550); 16 Jun 2013 14:24:49 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 1535 invoked from network); 16 Jun 2013 14:24:49 -0000 Content-Disposition: inline In-Reply-To: <1371375118.16425.368.camel@eris.loria.fr> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:3420 Archived-At: On Sun, Jun 16, 2013 at 11:31:58AM +0200, Jens Gustedt wrote: > In all, this re-enforces my opinion to *always* initialize variables, > unless I know that its address is immediately passed to an I disagree with this principle. If you initialize the variable to a dummy value, the compiler (or other static analysis tools) cannot catch erroneous use of the variable before a real value is stored in it. Also valgrind cannot catch them. Your "always initialize" principle only makes sense when (as in this case) there's an obvious "default value" the variable should have if it's not set elsewhere. But often that's not the case, especially for pointers. Rich