Received: from eggs.gnu.org ([2001:4830:134:3::10]:59237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WjmPZ-0008CX-GS for qemu-devel@nongnu.org; Mon, 12 May 2014 05:20:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WjmPU-00063Z-9T for qemu-devel@nongnu.org; Mon, 12 May 2014 05:20:41 -0400 From: Markus Armbruster References: <1399569594-31678-1-git-send-email-mjt@msgid.tls.msk.ru> <536F2DC0.9080809@redhat.com> <536F6180.1010905@msgid.tls.msk.ru> Date: Mon, 12 May 2014 11:20:31 +0200 In-Reply-To: <536F6180.1010905@msgid.tls.msk.ru> (Michael Tokarev's message of "Sun, 11 May 2014 15:39:44 +0400") Message-ID: <87mwenz734.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] libcacard: remove useless initializers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev Cc: qemu-trivial@nongnu.org, Alon Levy , qemu-devel@nongnu.org Michael Tokarev writes: > 11.05.2014 11:58, Alon Levy wrote: >> On 05/08/2014 08:19 PM, Michael Tokarev wrote: >>> libcacard has many functions which initializes local variables >>> at declaration time, which are always assigned some values later >>> (often right after declaration). Clean up these initializers. >> >> How is this an improvement? Doesn't the compiler ignore this anyhow? > > Just less code. > > To me, when I see something like > > Type *var = NULL; > > in a function, it somehow "translates" to a construct like > > Type *found = NULL; > > That is -- so this variable will be used either as an accumulator > or a search result, so that initial value is really important. > > So when I see the same variable receives its initial value in > the next line, I start wondering what's missed in the code which > should be there. Or why I don't read the code correctly. Or > something like this. > > So, basically, this is a cleanup patch just to avoid confusion, > it most likely not needed for current compiler who can figure > it out by its own. And for consistency - why not initialize > other variables too? I hate redundant initializers for yet another reason: when I change the code, and accidentally add a path bypassing the *real* initialization, I don't get a "may be used uninitialized" warning, I get the stupid redundant initialization and quite possibly a crash to debug some time later. > Maybe that's just my old-scool mind works this way. > > At any rate you can just ignore this patch. Please consider it.