Re: [PATCH v2 09/24] dyndbg: add maybe(str,"") macro to reduce code

From: Joe Perches
Date: Sat Jun 13 2020 - 12:14:18 EST


On Sat, 2020-06-13 at 09:57 -0600, Jim Cromie wrote:
> reduce word count via macro, no actual object change.
>
> OTOH, maybe() could be scrubbed if printk's default printing (iirc) of
> "(null)" pointers is deemed appropriate for the log-msg.
[]
> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
[]
> @@ -114,6 +114,7 @@ do { \
> #define vpr_info(fmt, ...) vnpr_info(1, fmt, ##__VA_ARGS__)
> #define v2pr_info(fmt, ...) vnpr_info(2, fmt, ##__VA_ARGS__)
>
> +#define maybe(str, empty) ( str ? str : empty )

This macro is unnecessary.

An even shorter very commonly used gcc extension would be

str ?: empty