Subject: Re: progress(1) buffersize
To: None <tech-userlevel@netbsd.org>
From: Christos Zoulas <christos@astron.com>
List: tech-userlevel
Date: 06/04/2007 19:51:55
In article <20070604194515.GQ26767@canolog.ninthwonder.com>,
Allen Briggs <briggs@netbsd.org> wrote:
>On Mon, Jun 04, 2007 at 07:26:41PM +0000, Christos Zoulas wrote:
>> > fprintf(stderr,
>> >- "usage: %s [-ez] [-f file] [-l length] [-p prefix] cmd [args...]\n",
>> >- getprogname());
>> >+ "usage: %s [-ez] [-b buffersize] [-f file] [-l length]\n"
>> >+ " %*.s [-p prefix] cmd [args...]\n",
>> >+ getprogname(), (int) strlen(getprogname()), "");
>>
>> Why %*.s? we never do this...
>
>Just to line things up nicely. No other reason.
Typically we hard-code the spaces in... I guess this is nicer.
$ ps -\?
usage: ps [-acCehjlmrsSTuvwx] [-k key] [-O|o fmt] [-p pid] [-t tty]
[-M core] [-N system] [-W swap] [-U username]
ps [-L]
>
>> >+ long long buffersize;
>>
>> Why make buffersize long long, since malloc can only handle size_t?
>> Or at least check that buffersize < SIZE_T_MAX.
>
>To match the return type of strsuftoll(). I don't have a problem with
>changing it to size_t and restricting the conversion to SIZE_T_MAX
>instead of the somewhat arbitrary 256MB.
I think we should just check that it is < SIZE_T_MAX before we pass
it to malloc.
christos