Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Aug 2016 10:30:26 -0500
From:      Pedro Giffuni <pfg@FreeBSD.org>
To:        Xin Li <delphij@delphij.net>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Cc:        d@delphij.net
Subject:   Re: svn commit: r303600 - head/usr.bin/indent
Message-ID:  <3eb7a9fe-f80d-7d34-c78e-df11e4a6aeb4@FreeBSD.org>
In-Reply-To: <8d6114b7-cd71-239a-dcc4-03a6d568482c@delphij.net>
References:  <201607312136.u6VLaeRb058693@repo.freebsd.org> <8d6114b7-cd71-239a-dcc4-03a6d568482c@delphij.net>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------F06810B83B1DA26EB4E2C552
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit



On 08/01/16 00:28, Xin Li wrote:
>
>
> On 7/31/16 14:36, Pedro F. Giffuni wrote:
>> Author: pfg
>> Date: Sun Jul 31 21:36:40 2016
>> New Revision: 303600
>> URL: https://svnweb.freebsd.org/changeset/base/303600
>>
>> 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.
>
> Cheers,
>
Does this look better?

Cheers,

Pedro.

--------------F06810B83B1DA26EB4E2C552
Content-Type: text/x-patch;
 name="indent-memset.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="indent-memset.diff"

Index: usr.bin/indent/io.c
===================================================================
--- usr.bin/indent/io.c	(revision 303615)
+++ usr.bin/indent/io.c	(working copy)
@@ -629,7 +629,7 @@
     const char *s = s0;
     int         sizedelta = 0;
 
-    memset(f, 0, sizeof(struct fstate));
+    memset(f, '\0', sizeof(*f));
     while (*s) {
 	if (isdigit(*s))
 	    f->size = f->size * 10 + *s - '0';

--------------F06810B83B1DA26EB4E2C552--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3eb7a9fe-f80d-7d34-c78e-df11e4a6aeb4>