[dpdk-dev] [PATCH] debug: update assertion macro

Ilya Matveychikov matvejchikov at gmail.com
Sun Nov 19 15:41:20 CET 2017



> On Nov 19, 2017, at 12:18 PM, Ilya Matveychikov <matvejchikov at gmail.com> wrote:
> 
> Update RTE_VERIFY macro to make it possible to use complex expressions
> in RTE_ASSERT.
> 
> Signed-off-by: Ilya V. Matveychikov <matvejchikov at gmail.com>
> 
> Fixes: 148f963fb532 ("xen: core library changes")
> Cc: bruce.richardson at intel.com
> 
> ---
> Now it's incorrect to use complex expressions for assertion
> like RTE_ASSERT((1 + 2) == 3). This patch makes it possible.

Update.

Now it’s possible to have % char inside the expression, for example:

RTE_ASSERT((sizeof(some_struct) % 64) == 0)

Before the patch, “%" sign acts like a conversion specification beginning
character.

> 
> lib/librte_eal/common/include/rte_debug.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/librte_eal/common/include/rte_debug.h b/lib/librte_eal/common/include/rte_debug.h
> index 79b67b3ec..fbb3bb5e5 100644
> --- a/lib/librte_eal/common/include/rte_debug.h
> +++ b/lib/librte_eal/common/include/rte_debug.h
> @@ -86,7 +86,7 @@ void rte_dump_registers(void);
> #endif
> #define	RTE_VERIFY(exp)	do {                                                  \
> 	if (unlikely(!(exp)))                                                           \
> -		rte_panic("line %d\tassert \"" #exp "\" failed\n", __LINE__); \
> +		rte_panic("line %d\tassert \"%s\" failed\n", __LINE__, #exp); \
> } while (0)
> 
> /*
> --
> 2.15.0



More information about the dev mailing list