[U-Boot] [PATCH v2] Add assert() for debug assertions
Simon Glass
sjg at chromium.org
Fri Jun 24 20:13:11 CEST 2011
Hi Wolfgang,
On Thu, Jun 23, 2011 at 10:33 PM, Wolfgang Denk <wd at denx.de> wrote:
> Dear Simon Glass,
...
>> +#define assert(x) \
>> + ({ if (!(x) && _DEBUG) \
>> + printf("Assertion failure '%s' %s line %d\n", \
>> + #x, __FILE__, __LINE__); })
>
> Can we please use the same message format as used by assert(3) ?
> Afaict they use "%s%s%s:%u: %s%sAssertion `%s' failed.".
Yes, will do.
>
> Also, to save on memory footprint (frequent repetition of the common
> string "Assertion failed") we should probably provide a separate
> function for this (cf. /usr/include/assert.h).
Good idea will do.
>
> Finally, should the assert() not result in some termination or hang of
> U-Boot, like assert(3) is doing?
I'm happy either way so long as it prints a message. A hang is better
than a reboot for those with ICE units, etc. My intention was that it
would simply print the message and try to continue (since we can't
really 'terminate' U-Boot, and it continues with DEBUG not defined).
But I am happy either way, so let me know if you would like it to hang.
Regards,
Simon
>
> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> "What the scientists have in their briefcases is terrifying."
> - Nikita Khrushchev
>
More information about the U-Boot
mailing list