Re: [Grubby - PATCH 4/4] Avoid C99 declaration inside for-loop

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

 



Hi,

Peter Jones <pjones@xxxxxxxxxx> writes:

> On 06/11/2012 12:29 PM, Adrian Perez wrote:
>> Avoids declaring an integer variable inside the initializer of a for-loop.
>> This patch avoids needing to compile the source in C99 mode.
                                                      ^^^
Ouch... This is s typo, “C89” should be written there.

> Er, why?  The c99 way is *better*, and we can easily compile in C99 mode.

I'm using GCC in default mode, which is -std=gnu89, so C89. This is the
only variable declaration inside a for-loop control part, so maybe it
makes sense to declare “i” outside the loop, to keep the style coherent.


>> ---
>>  grubby.c |    3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/grubby.c b/grubby.c
>> index 4866f1d..d0101cd 100644
>> --- a/grubby.c
>> +++ b/grubby.c
>> @@ -2423,9 +2423,10 @@ static void requote(struct singleLine *tmplLine, struct configFileInfo * cfi)
>>  	    quoteLen += strlen(tmplLine->elements[j].indent);
>>  	    
>>  	    if (isquote(tmplLine->elements[j].item[itemlen - 1])) {
>> +		int i;
>>  		c = malloc(quoteLen + 1);
>>  		c[0] = '\0';
>> -		for (int i = firstQuotedItem; i < j+1; i++) {
>> +		for (i = firstQuotedItem; i < j+1; i++) {
>>  		    strcat(c, tmplLine->elements[i].item);
>>  		    strcat(c, tmplLine->elements[i].indent);
>>  		}
>
>

Regards,

-- 
Adrian Perez <aperez@xxxxxxxxxx> - Sent from my toaster
Igalia - Free Software Engineering

Attachment: pgpA2NhRlOPGo.pgp
Description: PGP signature

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux