Skip to content
Snippets Groups Projects
Commit c04fb597 authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Adam Wujek
Browse files

assert.h: parameter passing fix


See gcc info pages: "Macros with a Variable Number of Arguments."
The ISO-C stadanrd doesn't allow varargs macros to get zero or more
arguments. So this fixes the problem using the gcc extension.

A standard-compliant alternative would be to have "fmt" included in
the variadic part, like this:

  #define assert(cond, ...) \
        if (CONFIG_HAS_ASSERT && !(cond)) \
                __assert(__func__, __LINE__, 1 /* forever */, __VA_ARGS__)

But the reader wouldn't  now it's a fmt+args.

Signed-off-by: default avatarAlessandro Rubini <rubini@gnudd.com>
parent 7312da3c
No related merge requests found
......@@ -13,11 +13,11 @@ extern void panic(const char *fmt, ...)
#define assert(cond, fmt, ...) \
if (CONFIG_HAS_ASSERT && !(cond)) \
__assert(__func__, __LINE__, 1 /* forever */, fmt __VA_ARGS__)
__assert(__func__, __LINE__, 1 /* forever */, fmt, ## __VA_ARGS__)
#define assert_warn(cond, fmt, ...) \
if (CONFIG_HAS_ASSERT && !(cond)) \
__assert(__func__, __LINE__, 0 /* once */, fmt __VA_ARGS__)
__assert(__func__, __LINE__, 0 /* once */, fmt, ## __VA_ARGS__)
extern void __assert(const char *func, int line, int forever,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment