From: Michael Tokarev <mjt@tls.msk.ru>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-trivial@nongnu.org, Alon Levy <alevy@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] libcacard: remove useless initializers
Date: Sat, 24 May 2014 00:59:51 +0400 [thread overview]
Message-ID: <537FB6C7.5000900@msgid.tls.msk.ru> (raw)
In-Reply-To: <87mwenz734.fsf@blackfin.pond.sub.org>
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).
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.
>
WARNING: multiple messages have this Message-ID (diff)
From: Michael Tokarev <mjt@tls.msk.ru>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-trivial@nongnu.org, Alon Levy <alevy@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] libcacard: remove useless initializers
Date: Sat, 24 May 2014 00:59:51 +0400 [thread overview]
Message-ID: <537FB6C7.5000900@msgid.tls.msk.ru> (raw)
In-Reply-To: <87mwenz734.fsf@blackfin.pond.sub.org>
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).
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.
>
next prev parent reply other threads:[~2014-05-23 21:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-08 17:19 [Qemu-trivial] [PATCH] libcacard: remove useless initializers Michael Tokarev
2014-05-08 17:19 ` [Qemu-devel] " Michael Tokarev
2014-05-11 7:58 ` [Qemu-trivial] " Alon Levy
2014-05-11 7:58 ` [Qemu-devel] " Alon Levy
2014-05-11 11:39 ` [Qemu-trivial] " Michael Tokarev
2014-05-11 11:39 ` Michael Tokarev
2014-05-12 9:20 ` [Qemu-trivial] " Markus Armbruster
2014-05-12 9:20 ` Markus Armbruster
2014-05-23 20:59 ` Michael Tokarev [this message]
2014-05-23 20:59 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-05-25 10:14 ` [Qemu-trivial] [Qemu-devel] " Alon Levy
2014-05-25 10:14 ` [Qemu-devel] [Qemu-trivial] " Alon Levy
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=537FB6C7.5000900@msgid.tls.msk.ru \
--to=mjt@tls.msk.ru \
--cc=alevy@redhat.com \
--cc=armbru@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.