All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ] memory zeroing macros
@ 2007-02-10 22:32 Robert P. J. Day
  2007-02-10 23:42 ` Alexey Dobriyan
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Robert P. J. Day @ 2007-02-10 22:32 UTC (permalink / raw)
  To: kernel-janitors


  i've put some ideas in the wiki:

http://fsdev.net/wiki/index.php?title=Memory_zeroing_macros

rday

-- 
====================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
====================================
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [KJ] memory zeroing macros
  2007-02-10 22:32 [KJ] memory zeroing macros Robert P. J. Day
@ 2007-02-10 23:42 ` Alexey Dobriyan
  2007-02-11  8:55 ` Robert P. J. Day
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Alexey Dobriyan @ 2007-02-10 23:42 UTC (permalink / raw)
  To: kernel-janitors

On Sat, Feb 10, 2007 at 05:32:10PM -0500, Robert P. J. Day wrote:
> 
>   i've put some ideas in the wiki:
> 
> http://fsdev.net/wiki/index.php?title=Memory_zeroing_macros

Sheesh... No way in hell such macroses are going to be accepted.

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [KJ] memory zeroing macros
  2007-02-10 22:32 [KJ] memory zeroing macros Robert P. J. Day
  2007-02-10 23:42 ` Alexey Dobriyan
@ 2007-02-11  8:55 ` Robert P. J. Day
  2007-02-11  9:24 ` Alexey Dobriyan
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Robert P. J. Day @ 2007-02-11  8:55 UTC (permalink / raw)
  To: kernel-janitors

On Sun, 11 Feb 2007, Alexey Dobriyan wrote:

> On Sat, Feb 10, 2007 at 05:32:10PM -0500, Robert P. J. Day wrote:
> >
> >   i've put some ideas in the wiki:
> >
> > http://fsdev.net/wiki/index.php?title=Memory_zeroing_macros
>
> Sheesh... No way in hell such macroses are going to be accepted.

i didn't think so, but at the very least, we can probably standardize
on memzero(), yes?

rday

-- 
====================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
====================================
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [KJ] memory zeroing macros
  2007-02-10 22:32 [KJ] memory zeroing macros Robert P. J. Day
  2007-02-10 23:42 ` Alexey Dobriyan
  2007-02-11  8:55 ` Robert P. J. Day
@ 2007-02-11  9:24 ` Alexey Dobriyan
  2007-02-11  9:32 ` Robert P. J. Day
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Alexey Dobriyan @ 2007-02-11  9:24 UTC (permalink / raw)
  To: kernel-janitors

On Sun, Feb 11, 2007 at 03:55:26AM -0500, Robert P. J. Day wrote:
> On Sun, 11 Feb 2007, Alexey Dobriyan wrote:
>
> > On Sat, Feb 10, 2007 at 05:32:10PM -0500, Robert P. J. Day wrote:
> > >
> > >   i've put some ideas in the wiki:
> > >
> > > http://fsdev.net/wiki/index.php?title=Memory_zeroing_macros
> >
> > Sheesh... No way in hell such macroses are going to be accepted.
>
> i didn't think so, but at the very least, we can probably standardize
> on memzero(), yes?

No! If anything we can put bzero() back but adding second idiom for
clearing memory may be not worth it.

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [KJ] memory zeroing macros
  2007-02-10 22:32 [KJ] memory zeroing macros Robert P. J. Day
                   ` (2 preceding siblings ...)
  2007-02-11  9:24 ` Alexey Dobriyan
@ 2007-02-11  9:32 ` Robert P. J. Day
  2007-02-11 20:34 ` burns.ethan
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Robert P. J. Day @ 2007-02-11  9:32 UTC (permalink / raw)
  To: kernel-janitors

On Sun, 11 Feb 2007, Alexey Dobriyan wrote:

> On Sun, Feb 11, 2007 at 03:55:26AM -0500, Robert P. J. Day wrote:
> > On Sun, 11 Feb 2007, Alexey Dobriyan wrote:
> >
> > > On Sat, Feb 10, 2007 at 05:32:10PM -0500, Robert P. J. Day wrote:
> > > >
> > > >   i've put some ideas in the wiki:
> > > >
> > > > http://fsdev.net/wiki/index.php?title=Memory_zeroing_macros
> > >
> > > Sheesh... No way in hell such macroses are going to be accepted.
> >
> > i didn't think so, but at the very least, we can probably
> > standardize on memzero(), yes?
>
> No! If anything we can put bzero() back but adding second idiom for
> clearing memory may be not worth it.

sure, i have nothing against bzero().  but, obviously, the basic
question, is it worth having a shortcut for zeroing a chunk of memory
rather than calling memset() all the time?  enough developers seem to
think so given the number of redefinitions of "memzero()".

or maybe this really is just not worth the effort.  who knows?

rday

-- 
====================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
====================================
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [KJ] memory zeroing macros
  2007-02-10 22:32 [KJ] memory zeroing macros Robert P. J. Day
                   ` (3 preceding siblings ...)
  2007-02-11  9:32 ` Robert P. J. Day
@ 2007-02-11 20:34 ` burns.ethan
  2007-02-11 21:33 ` Greg KH
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burns.ethan @ 2007-02-11 20:34 UTC (permalink / raw)
  To: kernel-janitors

On Sun, Feb 11, 2007 at 04:32:11AM -0500, Robert P. J. Day wrote:
> or maybe this really is just not worth the effort.  who knows?

I don't think its worth the effort.  Changing the name on this wouldn't add
any readability.  memset(dest, 0, len) is very clear, in my opinion.  Also,
there's nothing really error prone about it...  I see no advantage.

	Just my 2 cents,
		--Ethan
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [KJ] memory zeroing macros
  2007-02-10 22:32 [KJ] memory zeroing macros Robert P. J. Day
                   ` (4 preceding siblings ...)
  2007-02-11 20:34 ` burns.ethan
@ 2007-02-11 21:33 ` Greg KH
  2007-02-12  1:51 ` Srdjan Todorovic
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2007-02-11 21:33 UTC (permalink / raw)
  To: kernel-janitors

On Sun, Feb 11, 2007 at 03:34:34PM -0500, burns.ethan@gmail.com wrote:
> On Sun, Feb 11, 2007 at 04:32:11AM -0500, Robert P. J. Day wrote:
> > or maybe this really is just not worth the effort.  who knows?
> 
> I don't think its worth the effort.  Changing the name on this wouldn't add
> any readability.  memset(dest, 0, len) is very clear, in my opinion.  Also,
> there's nothing really error prone about it...  I see no advantage.

Not true at all, 0 and len get switched a lot accidentally.  See the
archives for times people have swept the kernel tree to fix this issue
up.

thanks,

greg k-h
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [KJ] memory zeroing macros
  2007-02-10 22:32 [KJ] memory zeroing macros Robert P. J. Day
                   ` (5 preceding siblings ...)
  2007-02-11 21:33 ` Greg KH
@ 2007-02-12  1:51 ` Srdjan Todorovic
  2007-02-12  4:43 ` Greg KH
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Srdjan Todorovic @ 2007-02-12  1:51 UTC (permalink / raw)
  To: kernel-janitors

On Sun, 11 Feb 2007, Greg KH wrote:

> On Sun, Feb 11, 2007 at 03:34:34PM -0500, burns.ethan@gmail.com wrote:
> > On Sun, Feb 11, 2007 at 04:32:11AM -0500, Robert P. J. Day wrote:
> > > or maybe this really is just not worth the effort.  who knows?
> > 
> > I don't think its worth the effort.  Changing the name on this wouldn't add
> > any readability.  memset(dest, 0, len) is very clear, in my opinion.  Also,
> > there's nothing really error prone about it...  I see no advantage.
> 
> Not true at all, 0 and len get switched a lot accidentally.  See the
> archives for times people have swept the kernel tree to fix this issue
> up.

I agree with you here, Greg, about accidentally switching the args to
memset(). However just because someone (I've done this in the past,
damn hard to debug since you don't expect to make this silly mistake)
can do:

  if (x = 0)  { }

doesn't mean that we should discourage if statements.

The macros from the wiki page add yet another set of macros/functions
that someone has to learn. memset() should be really well-known to
anyone doing C for a while. Plus with new code, comes the possibility
of abuse and bugs (eg. the macros in the wiki page don't protect the
arguement with brackets).

Thanks,

Srdjan
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [KJ] memory zeroing macros
  2007-02-10 22:32 [KJ] memory zeroing macros Robert P. J. Day
                   ` (6 preceding siblings ...)
  2007-02-12  1:51 ` Srdjan Todorovic
@ 2007-02-12  4:43 ` Greg KH
  2007-02-12  5:28 ` Richard Knutsson
  2007-02-12  8:59 ` Robert P. J. Day
  9 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2007-02-12  4:43 UTC (permalink / raw)
  To: kernel-janitors

On Mon, Feb 12, 2007 at 01:51:20AM +0000, Srdjan Todorovic wrote:
> On Sun, 11 Feb 2007, Greg KH wrote:
> 
> > On Sun, Feb 11, 2007 at 03:34:34PM -0500, burns.ethan@gmail.com wrote:
> > > On Sun, Feb 11, 2007 at 04:32:11AM -0500, Robert P. J. Day wrote:
> > > > or maybe this really is just not worth the effort.  who knows?
> > > 
> > > I don't think its worth the effort.  Changing the name on this wouldn't add
> > > any readability.  memset(dest, 0, len) is very clear, in my opinion.  Also,
> > > there's nothing really error prone about it...  I see no advantage.
> > 
> > Not true at all, 0 and len get switched a lot accidentally.  See the
> > archives for times people have swept the kernel tree to fix this issue
> > up.
> 
> I agree with you here, Greg, about accidentally switching the args to
> memset(). However just because someone (I've done this in the past,
> damn hard to debug since you don't expect to make this silly mistake)
> can do:
> 
>   if (x = 0)  { }

gcc will now warn against this :)

Anyway, anyone is welcome to sweep the kernel tree to see if there are
any 0 for the len argument in the tree left.

thanks,

greg k-h
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [KJ] memory zeroing macros
  2007-02-10 22:32 [KJ] memory zeroing macros Robert P. J. Day
                   ` (7 preceding siblings ...)
  2007-02-12  4:43 ` Greg KH
@ 2007-02-12  5:28 ` Richard Knutsson
  2007-02-12  8:59 ` Robert P. J. Day
  9 siblings, 0 replies; 11+ messages in thread
From: Richard Knutsson @ 2007-02-12  5:28 UTC (permalink / raw)
  To: kernel-janitors

Greg KH wrote:
> On Mon, Feb 12, 2007 at 01:51:20AM +0000, Srdjan Todorovic wrote:
>   
>> On Sun, 11 Feb 2007, Greg KH wrote:
>>     
>>> Not true at all, 0 and len get switched a lot accidentally.  See the
>>> archives for times people have swept the kernel tree to fix this issue
>>> up.
>>>       
>> I agree with you here, Greg, about accidentally switching the args to
>> memset(). However just because someone (I've done this in the past,
>> damn hard to debug since you don't expect to make this silly mistake)
>> can do:
>>
>>   if (x = 0)  { }
>>     
>
> gcc will now warn against this :)
>
> Anyway, anyone is welcome to sweep the kernel tree to see if there are
> any 0 for the len argument in the tree left.
>
> thanks,
>
> greg k-h
>   
linux-2.6]$ grep -Enr "memset *\(.*, *0 *\)" *
Documentation/scsi/ChangeLog.1992-1997:260:     * scsi.c (scan_scsis): memset(SDpnt, 0) and set SCmd.device to SDpnt.
include/asm-arm/uaccess.h:392:#define __clear_user(addr,n)              (memset((void __force *)addr, 0, n), 0)
include/asm-frv/uaccess.h:274:#define clear_user(dst,count)                    (memset(____force(dst), 0, (count)), 0)
linux-2.6]$ 

So it seems ok.
Added it to an error-script with whom I can scan the tree in irregular intervals.

Richard Knutsson


_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [KJ] memory zeroing macros
  2007-02-10 22:32 [KJ] memory zeroing macros Robert P. J. Day
                   ` (8 preceding siblings ...)
  2007-02-12  5:28 ` Richard Knutsson
@ 2007-02-12  8:59 ` Robert P. J. Day
  9 siblings, 0 replies; 11+ messages in thread
From: Robert P. J. Day @ 2007-02-12  8:59 UTC (permalink / raw)
  To: kernel-janitors

On Mon, 12 Feb 2007, Srdjan Todorovic wrote:

> On Sun, 11 Feb 2007, Greg KH wrote:
>
> > On Sun, Feb 11, 2007 at 03:34:34PM -0500, burns.ethan@gmail.com wrote:
> > > On Sun, Feb 11, 2007 at 04:32:11AM -0500, Robert P. J. Day wrote:
> > > > or maybe this really is just not worth the effort.  who knows?
> > >
> > > I don't think its worth the effort.  Changing the name on this
> > > wouldn't add any readability.  memset(dest, 0, len) is very
> > > clear, in my opinion.  Also, there's nothing really error prone
> > > about it...  I see no advantage.
> >
> > Not true at all, 0 and len get switched a lot accidentally.  See
> > the archives for times people have swept the kernel tree to fix
> > this issue up.
>
> I agree with you here, Greg, about accidentally switching the args
> to memset(). However just because someone (I've done this in the
> past, damn hard to debug since you don't expect to make this silly
> mistake) can do:
>
>   if (x = 0)  { }
>
> doesn't mean that we should discourage if statements.
>
> The macros from the wiki page add yet another set of
> macros/functions that someone has to learn.

i agree that those extra macros are overkill, except possibly in the
case of a simple memzero(), given that other developers seem to
re-invent it on an occasional basis.

but i'll leave this decision to someone else.

rday

-- 
====================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
====================================
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-02-12  8:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-10 22:32 [KJ] memory zeroing macros Robert P. J. Day
2007-02-10 23:42 ` Alexey Dobriyan
2007-02-11  8:55 ` Robert P. J. Day
2007-02-11  9:24 ` Alexey Dobriyan
2007-02-11  9:32 ` Robert P. J. Day
2007-02-11 20:34 ` burns.ethan
2007-02-11 21:33 ` Greg KH
2007-02-12  1:51 ` Srdjan Todorovic
2007-02-12  4:43 ` Greg KH
2007-02-12  5:28 ` Richard Knutsson
2007-02-12  8:59 ` Robert P. J. Day

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.