On Wednesday, June 22, 2011 17:04:49 Simon Glass wrote: > +/* > + * An assertion is run-time check done in debug mode only. If DEBUG is not > + * defined then it is skipped. It does not BUG or halt U-Boot, but tries > to + * continue execution in any case. It is hoped that all failing > assertions + * are found before release, and after release it is hoped > that they don't + * matter. But in any case these failing assertions > cannot be fixed with a + * BUG-type reset (which may just do the same > assertion again). > + */ > +#define assert(x) \ > + ({ if (!(x)) printf("Assertion failure '%s' %s line %d\n", \ > + #x, __FILE__, __LINE__); }) > #else > #define debug(fmt,args...) > #define debugX(level,fmt,args...) > +#define assert(x) > #endif /* DEBUG */
the trouble with ifdef magic like this is that errors/warnings can be introduced when DEBUG isnt defined, and then only noticed when DEBUG is defined. so how about: #ifdef DEBUG # define _DEBUG 1 #else # define _DEBUG 2 #endif #define assert(x) \ do { \ if ((x) && _DEBUG) \ printf("%s:%s():%i: assertion failure: %s\n", \ __FILE__, __func__, __LINE__, #x); \ } while (0) (and yes, i know debug() and debugX() are also broken this way) -mike
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot