[PATCH 1/3] tail: turn i to unsigned integer

Guilherme Maciel Ferreira guilherme.maciel.ferreira at gmail.com
Mon Jul 28 13:00:50 UTC 2014


Hi,

2014-07-26 15:02 GMT-03:00 walter harms <wharms at 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 at 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 at 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


More information about the busybox mailing list