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

Bruce Evans brde at optusnet.com.au
Mon Aug 1 06:08:13 UTC 2016


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().

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.
The style of this is very different from an nitems() expansion in r1590.
There was 1 more sizeof(object) and 1 sizeof(int).  This is the first
sizeof(typename) where 'sizeof object' cannot be used for technical
reasons.

KNF also requires parentheses for sizeof(object).  Then the space is
unnecessary and disallowed.

Bruce


More information about the svn-src-all mailing list