From: Alon Levy <alevy@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>, Markus Armbruster <armbru@redhat.com>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] libcacard: remove useless initializers
Date: Sun, 25 May 2014 13:14:49 +0300 [thread overview]
Message-ID: <5381C299.7080709@redhat.com> (raw)
In-Reply-To: <537FB6C7.5000900@msgid.tls.msk.ru>
On 05/23/2014 11:59 PM, Michael Tokarev wrote:
> So, should we apply this or not? It's been waiting for quite some time,
> and during this time we've found a very good example of why it should
> be applied (I think anyway).
I'm fine with applying it, I changed my mind.
>
> Thanks,
>
> /mjt
>
>
> 12.05.2014 13:20, Markus Armbruster wrote:
>> Michael Tokarev <mjt@tls.msk.ru> 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.
>>
>
>
prev parent reply other threads:[~2014-05-25 10:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-08 17:19 [Qemu-devel] [PATCH] libcacard: remove useless initializers Michael Tokarev
2014-05-11 7:58 ` Alon Levy
2014-05-11 11:39 ` Michael Tokarev
2014-05-12 9:20 ` Markus Armbruster
2014-05-23 20:59 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-05-25 10:14 ` Alon Levy [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5381C299.7080709@redhat.com \
--to=alevy@redhat.com \
--cc=armbru@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).