[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [Qemu-devel] [PATCH] libcacard: remove useless initia

From: Alon Levy
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] libcacard: remove useless initializers
Date: Sun, 25 May 2014 13:14:49 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

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 <address@hidden> 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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]