From owner-freebsd-current Sat Mar 6 11: 0:26 1999 Delivered-To: freebsd-current@freebsd.org Received: from wall.polstra.com (rtrwan160.accessone.com [206.213.115.74]) by hub.freebsd.org (Postfix) with ESMTP id 7C0E714CE5 for ; Sat, 6 Mar 1999 11:00:24 -0800 (PST) (envelope-from jdp@polstra.com) Received: from vashon.polstra.com (vashon.polstra.com [206.213.73.13]) by wall.polstra.com (8.9.1/8.9.1) with ESMTP id LAA21989; Sat, 6 Mar 1999 11:00:06 -0800 (PST) (envelope-from jdp@polstra.com) Received: (from jdp@localhost) by vashon.polstra.com (8.9.2/8.9.1) id LAA47116; Sat, 6 Mar 1999 11:00:06 -0800 (PST) (envelope-from jdp@polstra.com) Message-ID: X-Mailer: XFMail 1.3 [p0] on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <199903061736.KAA24445@mt.sri.com> Date: Sat, 06 Mar 1999 11:00:05 -0800 (PST) Organization: Polstra & Co., Inc. From: John Polstra To: Nate Williams Subject: Re: callout changes nit Cc: current@FreeBSD.ORG Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Nate Williams wrote: >> > +void >> > +callout_init(c) >> > + struct callout *c; >> > +{ >> > + bzero(c, sizeof c); >> > } >> > >> > That doesn't look correct, does it? >> >> Agreed. I think it should be "sizeof *c". > > Ahh, I see. I think it should say > > bzero(c, sizeof(struct callout)); > > To avoid the compiler using the size of the pointers et. al. This is largely a matter of taste, so we don't need to agree on it. :-) But I do have a specific reason for preferring the "sizeof *c" form. Namely, it reduces redundancy. The advantage is best seen if you consider making a macro for clearing a structure. Here are two possibilities: #define CLEAR_STRUCT(ptr) bzero((ptr), sizeof *(ptr)) #define CLEAR_STRUCT(ptr, type) bzero((ptr), sizeof(type)) In this context, the 1-parameter form is indisputably less error-prone. Of course, the context of the original example was different. So I'm satisfied to say we are both "right". John --- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Nobody ever went broke underestimating the taste of the American public." -- H. L. Mencken To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message