svn commit: r303600 - head/usr.bin/indent

Pedro Giffuni pfg at FreeBSD.org
Mon Aug 1 16:08:49 UTC 2016



On 08/01/16 01:08, Bruce Evans wrote:
> On Sun, 31 Jul 2016, Xin Li wrote:
>
>> On 7/31/16 14:36, Pedro F. Giffuni wrote:
>>>
>>> Log:
>>>   indent(1): replace function call to bzero with memset.
>>>
>>>   Reference:
>>>
>>> https://github.com/pstef/freebsd_indent/commit/7422f42f80099c69d34833d7106035dc09230235
>>>
>>>
>>>   Differential Revision: https://reviews.freebsd.org/D6966  (Partial)
>>>   Submitted by:    Piotr Stefaniak
>>>
>>> Modified:
>>>   head/usr.bin/indent/io.c
>>>
>>> Modified: head/usr.bin/indent/io.c
>>> ==============================================================================
>>>
>>> --- head/usr.bin/indent/io.c    Sun Jul 31 21:29:10 2016    (r303599)
>>> +++ head/usr.bin/indent/io.c    Sun Jul 31 21:36:40 2016    (r303600)
>>> @@ -629,7 +629,7 @@ parsefont(struct fstate *f, const char *
>>>      const char *s = s0;
>>>      int         sizedelta = 0;
>>>
>>> -    bzero(f, sizeof *f);
>>> +    memset(f, 0, sizeof(struct fstate));
>>                    ^^^^^^^^^^^^^^^^^^^^^  This is much more error-prone
>> than sizeof(*f) IMHO.
>
> I also prefer bzero().
>

bzero --> memset changes are done to ease portability ...

On another BSD such replacements were done for performance but then
they discovered it was their bzero that was broken.

> Removal of the space after sizeof is another regression.  KNF disallows
> the space, but indent's style is very far from KNF.  It isn't clear if
> indent's style is to require the space, since old versions of indent
> never used sizeof(typename), and 'sizeof object' requires the space.
> Regressions started in r93440 with sizeof(object) in an nitems() expansion.

OK ... that was in 2002.
We are using nitems() now, which undoes the portability meant to be 
brought by memset. OTOH, using sys/param.h is implicit permission
to use nitems() and may involve other portability issues already.
Can't keep everybody happy.

Pedro.


More information about the svn-src-head mailing list