svn commit: r205119 - head/contrib/top

Bruce Evans brde at optusnet.com.au
Tue Mar 30 20:41:20 UTC 2010


On Tue, 30 Mar 2010, Giovanni Trematerra wrote:

> On Sat, Mar 13, 2010 at 1:17 PM, Bruce Cran <brucec at freebsd.org> wrote:
>> Author: brucec
>> Date: Sat Mar 13 11:17:39 2010
>> New Revision: 205119
>> URL: http://svn.freebsd.org/changeset/base/205119
>>
>> Log:
>>  Change the 'amt' parameter in format_k2 from int to unsigned long long
>>  to match the values passed in and prevent the SIZE field being corrupted
>>  when more than 2TB is allocated.
>>
>>  PR:           bin/129706
>>  Approved by:  rrs (mentor)
>>  MFC after:    1 week

Grrr, where are the ASCII ribbon campaigners?

mav@ (?) just reported a type error in this.  I may have already complained
about this :-).  unsigned long long should be a syntax error...

>>
>> Modified:
>>  head/contrib/top/utils.c
>>
>> Modified: head/contrib/top/utils.c
>> ==============================================================================
>> --- head/contrib/top/utils.c    Sat Mar 13 11:08:57 2010        (r205118)
>> +++ head/contrib/top/utils.c    Sat Mar 13 11:17:39 2010        (r205119)
>> @@ -476,7 +476,7 @@ int amt;
>>
>>  char *format_k2(amt)
>>
>> -int amt;
>> +unsigned long long amt;
>>
>>  {
>>     static char retarray[NUM_STRINGS][16];
>
> While here wouldn't be good thing to ansify the function?

No, ansi doesn't exist, and this is contribed code which is already
hundreds if not thousands of versions behind the "vendor" version,
partly because even non-gratuitous changes in it are hard to maintain.
contrib/top doesn't have many local changes, but usr.bin/top does
(including an almost complete reformatting to KNF), and unfortunately
the "vendor" changed almost everything in that too.

format_k2() is a FreeBSD addition.  In the "vendor" version 3.8b1, there
is still only format_k().  This has been converted to a new-style definition
so that it can no longer be compiled by old compilers, and its parameter
type has been changed from int to long, which is hopefully long enough.
Even its style has been improved.

Bruce


More information about the svn-src-all mailing list