lkml.org 
[lkml]   [2020]   [Jun]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 09/24] dyndbg: add maybe(str,"") macro to reduce code
On Sat 2020-06-13 09:57:23, 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.
> ---
> lib/dynamic_debug.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
> index 31d3be30776e..20b712652ee4 100644
> --- 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 )
> static void vpr_info_dq(const struct ddebug_query *query, const char *msg)
> {
> /* trim any trailing newlines */
> @@ -127,10 +128,10 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg)
>
> vpr_info("%s: func=\"%s\" file=\"%s\" module=\"%s\" format=\"%.*s\" lineno=%u-%u\n",
> msg,
> - query->function ? query->function : "",
> - query->filename ? query->filename : "",
> - query->module ? query->module : "",
> - fmtlen, query->format ? query->format : "",
> + maybe(query->function, ""),
> + maybe(query->filename, ""),
> + maybe(query->module, ""),
> + fmtlen, maybe(query->format, ""),

From my POV this makes the code less readable. Open coding is much
more clear than an ambiguous macro name.

Best Regards,
Petr

\
 
 \ /
  Last update: 2020-06-15 15:29    [W:0.390 / U:1.784 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site