[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH 1/3] tail: turn i to unsigned integer
From:       Guilherme Maciel Ferreira <guilherme.maciel.ferreira () gmail ! com>
Date:       2014-07-28 13:00:50
Message-ID: CAF=5bWfQQ7GVrStKsr_2G_bv6E6aC7N6gxPCE86-Y9ZuA6KEyQ () mail ! gmail ! com
[Download RAW message or body]

Hi,

2014-07-26 15:02 GMT-03:00 walter harms <wharms@bfs.de>:
> what is the advantage ?

I think correctness is a good advantage. I mean, why use a signed
integer, if this variable works as (and with) unsigned integers only?

>
> re,
>  wh
>
> Am 26.07.2014 19:37, schrieb Guilherme Maciel Ferreira:
>> The variable i is used only to index and to be assigned to other unsigned
>> integers.
>>
>> Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
>> ---
>>  coreutils/tail.c |    5 +++--
>>  1 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/coreutils/tail.c b/coreutils/tail.c
>> index e352ab6..c44aeb8 100644
>> --- a/coreutils/tail.c
>> +++ b/coreutils/tail.c
>> @@ -100,7 +100,8 @@ int tail_main(int argc, char **argv)
>>       size_t tailbufsize;
>>       unsigned header_threshhold = 1;
>>       unsigned nfiles;
>> -     int i, opt;
>> +     unsigned i;
>> +     int opt;
>>
>>       int *fds;
>>       const char *fmt;
>> @@ -161,7 +162,7 @@ int tail_main(int argc, char **argv)
>>               }
>>               fds[nfiles] = fd;
>>               argv[nfiles++] = argv[i];
>> -     } while (++i < argc);
>> +     } while (++i < (unsigned) argc);
>>
>>       if (!nfiles)
>>               bb_error_msg_and_die("no files");
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox



-- 
Guilherme Maciel Ferreira
Mobile Brazil: +55 48 9917 3969
Site: http://guilhermemacielferreira.com/
Skype: guilherme.maciel.ferreira
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic