[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200613155738.2249399-10-jim.cromie@gmail.com>
Date: Sat, 13 Jun 2020 09:57:23 -0600
From: Jim Cromie <jim.cromie@...il.com>
To: jbaron@...mai.com, linux-kernel@...r.kernel.org,
akpm@...uxfoundation.org, gregkh@...uxfoundation.org
Cc: linux@...musvillemoes.dk, Jim Cromie <jim.cromie@...il.com>
Subject: [PATCH v2 09/24] dyndbg: add maybe(str,"") macro to reduce code
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, ""),
query->first_lineno, query->last_lineno);
}
--
2.26.2
Powered by blists - more mailing lists