is there a standard for specifying assertions?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  is there (or can there be) a prescribed standard for assertions in
kernel code?  as it stands, include/asm-generic/bug.h defines the
following debugging directives:

  BUG()
  BUG_ON(condition)
  WARN_ON(condition)
  WARN_ON_ONCE(condition)

which, you would think, would be sufficient to cover the majority of
needs.  and yet, loads of people insist on defining some variation of
an assertion for their code:

  $ grep -r "define.*assert(" *

in some cases, an assertion is defined directly in terms of BUG_ON():

  net/tipc/core.h:#define assert(i)  BUG_ON(!(i))

in other cases, it might as well have been:

  arch/cris/arch-v32/drivers/cryptocop.c:#define assert(s) do{if (!(s)) panic(#s);} while(0);

so there's two possible issues here:

1) if an assertion is exactly equivalent to one of the existing
directives, should it be removed and that directive be used directly
in the code?

2) if an assertion *isn't* exactly equivalent to an existing
directive, should a new directive be added?  what about just adding a
new header file "assert.h" with a universal assert() macro?  wouldn't
that make more sense than having all these separate definitions?

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

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

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux