* [KJ] is there a kernel standard for assertions?
@ 2007-03-17 19:51 Robert P. J. Day
2007-03-17 20:39 ` Matthew Wilcox
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Robert P. J. Day @ 2007-03-17 19:51 UTC (permalink / raw)
To: kernel-janitors
it seems like lots of kernel code is re-inventing the idea of an
assertion. is there no single basic standard for assertions in the
kernel?
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.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [KJ] is there a kernel standard for assertions?
2007-03-17 19:51 [KJ] is there a kernel standard for assertions? Robert P. J. Day
@ 2007-03-17 20:39 ` Matthew Wilcox
2007-03-17 21:24 ` Adrian Bunk
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Matthew Wilcox @ 2007-03-17 20:39 UTC (permalink / raw)
To: kernel-janitors
On Sat, Mar 17, 2007 at 03:51:49PM -0400, Robert P. J. Day wrote:
> it seems like lots of kernel code is re-inventing the idea of an
> assertion. is there no single basic standard for assertions in the
> kernel?
BUG_ON().
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [KJ] is there a kernel standard for assertions?
2007-03-17 19:51 [KJ] is there a kernel standard for assertions? Robert P. J. Day
2007-03-17 20:39 ` Matthew Wilcox
@ 2007-03-17 21:24 ` Adrian Bunk
2007-03-17 21:46 ` Robert P. J. Day
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Adrian Bunk @ 2007-03-17 21:24 UTC (permalink / raw)
To: kernel-janitors
On Sat, Mar 17, 2007 at 02:39:25PM -0600, Matthew Wilcox wrote:
> On Sat, Mar 17, 2007 at 03:51:49PM -0400, Robert P. J. Day wrote:
> > it seems like lots of kernel code is re-inventing the idea of an
> > assertion. is there no single basic standard for assertions in the
> > kernel?
>
> BUG_ON().
Or WARN_ON() if it's considered non-fatal.
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [KJ] is there a kernel standard for assertions?
2007-03-17 19:51 [KJ] is there a kernel standard for assertions? Robert P. J. Day
2007-03-17 20:39 ` Matthew Wilcox
2007-03-17 21:24 ` Adrian Bunk
@ 2007-03-17 21:46 ` Robert P. J. Day
2007-03-17 21:55 ` Arnd Bergmann
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Robert P. J. Day @ 2007-03-17 21:46 UTC (permalink / raw)
To: kernel-janitors
On Sat, 17 Mar 2007, Adrian Bunk wrote:
> On Sat, Mar 17, 2007 at 02:39:25PM -0600, Matthew Wilcox wrote:
> > On Sat, Mar 17, 2007 at 03:51:49PM -0400, Robert P. J. Day wrote:
> > > it seems like lots of kernel code is re-inventing the idea of an
> > > assertion. is there no single basic standard for assertions in the
> > > kernel?
> >
> > BUG_ON().
>
> Or WARN_ON() if it's considered non-fatal.
i'm aware of both of those macros, which is why i'm wondering why so
many developers insist on inventing their own version of an "assert"
routine. given all of the *existing* debugging routines, shouldn't
inventing your own be discouraged? is that something that could be
turned into a KJ project of some kind?
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.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [KJ] is there a kernel standard for assertions?
2007-03-17 19:51 [KJ] is there a kernel standard for assertions? Robert P. J. Day
` (2 preceding siblings ...)
2007-03-17 21:46 ` Robert P. J. Day
@ 2007-03-17 21:55 ` Arnd Bergmann
2007-03-18 3:39 ` Richard Knutsson
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2007-03-17 21:55 UTC (permalink / raw)
To: kernel-janitors
On Saturday 17 March 2007 22:46:39 Robert P. J. Day wrote:
> i'm aware of both of those macros, which is why i'm wondering why so
> many developers insist on inventing their own version of an "assert"
> routine. given all of the *existing* debugging routines, shouldn't
> inventing your own be discouraged? is that something that could be
> turned into a KJ project of some kind?
Yes. I guess most of the assert() implementations in the kernel are
older than BUG_ON() and WARN_ON(). Adding new ones is normally
discouraged.
Arnd <><
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [KJ] is there a kernel standard for assertions?
2007-03-17 19:51 [KJ] is there a kernel standard for assertions? Robert P. J. Day
` (3 preceding siblings ...)
2007-03-17 21:55 ` Arnd Bergmann
@ 2007-03-18 3:39 ` Richard Knutsson
2007-03-18 4:38 ` Randy Dunlap
2007-03-18 14:15 ` Richard Knutsson
6 siblings, 0 replies; 8+ messages in thread
From: Richard Knutsson @ 2007-03-18 3:39 UTC (permalink / raw)
To: kernel-janitors
Robert P. J. Day wrote:
> On Sat, 17 Mar 2007, Adrian Bunk wrote:
>
>
>> On Sat, Mar 17, 2007 at 02:39:25PM -0600, Matthew Wilcox wrote:
>>
>>> On Sat, Mar 17, 2007 at 03:51:49PM -0400, Robert P. J. Day wrote:
>>>
>>>> it seems like lots of kernel code is re-inventing the idea of an
>>>> assertion. is there no single basic standard for assertions in the
>>>> kernel?
>>>>
>>> BUG_ON().
>>>
>> Or WARN_ON() if it's considered non-fatal.
>>
>
> i'm aware of both of those macros, which is why i'm wondering why so
> many developers insist on inventing their own version of an "assert"
> routine. given all of the *existing* debugging routines, shouldn't
> inventing your own be discouraged? is that something that could be
> turned into a KJ project of some kind?
>
Is there any way to just enable the debugging for one sub-system and not
the whole tree?
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [KJ] is there a kernel standard for assertions?
2007-03-17 19:51 [KJ] is there a kernel standard for assertions? Robert P. J. Day
` (4 preceding siblings ...)
2007-03-18 3:39 ` Richard Knutsson
@ 2007-03-18 4:38 ` Randy Dunlap
2007-03-18 14:15 ` Richard Knutsson
6 siblings, 0 replies; 8+ messages in thread
From: Randy Dunlap @ 2007-03-18 4:38 UTC (permalink / raw)
To: kernel-janitors
On Sun, 18 Mar 2007 04:39:39 +0100 Richard Knutsson wrote:
> Robert P. J. Day wrote:
> > On Sat, 17 Mar 2007, Adrian Bunk wrote:
> >
> >
> >> On Sat, Mar 17, 2007 at 02:39:25PM -0600, Matthew Wilcox wrote:
> >>
> >>> On Sat, Mar 17, 2007 at 03:51:49PM -0400, Robert P. J. Day wrote:
> >>>
> >>>> it seems like lots of kernel code is re-inventing the idea of an
> >>>> assertion. is there no single basic standard for assertions in the
> >>>> kernel?
> >>>>
> >>> BUG_ON().
> >>>
> >> Or WARN_ON() if it's considered non-fatal.
> >>
> >
> > i'm aware of both of those macros, which is why i'm wondering why so
> > many developers insist on inventing their own version of an "assert"
> > routine. given all of the *existing* debugging routines, shouldn't
> > inventing your own be discouraged? is that something that could be
> > turned into a KJ project of some kind?
> >
> Is there any way to just enable the debugging for one sub-system and not
> the whole tree?
A few subsystems have specific debug-enabling config symbols,
like USB and ACPI and KOBJECT and PM (Power Management) and PCI,
PCMCIA, NETFILTER, IRDA, IEEE80211, DRIVERS, MTD, PNP, SCSI,
SPI, SOUND, HID, MMC, EDAC, JBD, JFS, NTFS, UFS, CIFS, DLM,
and KOBJECTS (just to name some of the big ones).
But BUG_ON() and WARN_ON() are often used without the aid (i.e.,
enabling) of those DEBUG config symbols.
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [KJ] is there a kernel standard for assertions?
2007-03-17 19:51 [KJ] is there a kernel standard for assertions? Robert P. J. Day
` (5 preceding siblings ...)
2007-03-18 4:38 ` Randy Dunlap
@ 2007-03-18 14:15 ` Richard Knutsson
6 siblings, 0 replies; 8+ messages in thread
From: Richard Knutsson @ 2007-03-18 14:15 UTC (permalink / raw)
To: kernel-janitors
Randy Dunlap wrote:
> On Sun, 18 Mar 2007 04:39:39 +0100 Richard Knutsson wrote:
>
>
>> Robert P. J. Day wrote:
>>
>>> On Sat, 17 Mar 2007, Adrian Bunk wrote:
>>>
>>>
>>>
>>>> On Sat, Mar 17, 2007 at 02:39:25PM -0600, Matthew Wilcox wrote:
>>>>
>>>>
>>>>> On Sat, Mar 17, 2007 at 03:51:49PM -0400, Robert P. J. Day wrote:
>>>>>
>>>>>
>>>>>> it seems like lots of kernel code is re-inventing the idea of an
>>>>>> assertion. is there no single basic standard for assertions in the
>>>>>> kernel?
>>>>>>
>>>>>>
>>>>> BUG_ON().
>>>>>
>>>>>
>>>> Or WARN_ON() if it's considered non-fatal.
>>>>
>>>>
>>> i'm aware of both of those macros, which is why i'm wondering why so
>>> many developers insist on inventing their own version of an "assert"
>>> routine. given all of the *existing* debugging routines, shouldn't
>>> inventing your own be discouraged? is that something that could be
>>> turned into a KJ project of some kind?
>>>
>>>
>> Is there any way to just enable the debugging for one sub-system and not
>> the whole tree?
>>
>
> A few subsystems have specific debug-enabling config symbols,
> like USB and ACPI and KOBJECT and PM (Power Management) and PCI,
> PCMCIA, NETFILTER, IRDA, IEEE80211, DRIVERS, MTD, PNP, SCSI,
> SPI, SOUND, HID, MMC, EDAC, JBD, JFS, NTFS, UFS, CIFS, DLM,
> and KOBJECTS (just to name some of the big ones).
>
> But BUG_ON() and WARN_ON() are often used without the aid (i.e.,
> enabling) of those DEBUG config symbols.
>
"Often used without"? Is it possible to enable BUG_ON() and WARN_ON()
with those config symbols? I can see how to disable ex BUG_ON by:
<in header>
#ifndef DEBUG_CONFIG_SYMBOL
#undef BUG_ON
#define BUG_ON(x) do {} while(0);
#endif
or
<in code>
#ifdef DEBUG_CONFIG_SYMBOL
BUG_ON(...)
#endif
But how to enable them when DEBUG is not defined? Otherwise I can
understand if maintainers do not want to use BUG_ON/WARN_ON and get the
debugging-info from the whole system.
Would something like SUBSYS_BUG_ON() be acceptable, who are just like
BUG_ON() but is (en/dis)abled by the subsystems debug-config-symbol?
(Would require some SUBSYS_BUG_ON_INIT() to define the debug-symbol)
Just my 2c
Richard Knutsson
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-03-18 14:15 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-17 19:51 [KJ] is there a kernel standard for assertions? Robert P. J. Day
2007-03-17 20:39 ` Matthew Wilcox
2007-03-17 21:24 ` Adrian Bunk
2007-03-17 21:46 ` Robert P. J. Day
2007-03-17 21:55 ` Arnd Bergmann
2007-03-18 3:39 ` Richard Knutsson
2007-03-18 4:38 ` Randy Dunlap
2007-03-18 14:15 ` Richard Knutsson
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.