busybox-1.3.0 and nonstd APIs, installment 2

Denis Vlasenko vda.linux at googlemail.com
Mon Dec 18 21:23:01 UTC 2006


On Monday 18 December 2006 07:09, sampo at symlabs.com wrote:
> It occasionally happens that busybox seems to use needlessly
> poorly standardized APIs and it is fairly easy to remove such
> usage. 
> 
> coreutils/du.c 

Went thru it.

> For i386 architecture nlink_t is on dietlibc-0.30 uint16_t and and
> unsigned 32 bit int on glibc-2.3.6. It seems wrong to initialize it with a
> signed INT_MAX. I wonder if any standard documents what kind of
> type nlink_t is supposed to be? 
> 
> The intent of the du code appears to be to use count_hardlinks as a
> flag controlled by -l commandline switch. This code would probably be
> better written by interpretting the flag variable as a boolean, but
> making count_hardlinks very large will also do the trick. Since in all
> studied cases the nlink_t is unsigned, just setting all of its bits on
> will produce maximal value.

We have this nice MAXINT(nlink_t), which gives max possible value
for any integer (any size & signedness)

Can you try attached?
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 16995.patch
Type: text/x-diff
Size: 4301 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20061218/01f7e16d/attachment-0002.bin 


More information about the busybox mailing list