All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Jason Baron <jbaron@akamai.com>,
	linux-kernel@vger.kernel.org,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>
Subject: [PATCH 04/10] dynamic_debug: introduce accessors for string members of struct _ddebug
Date: Tue,  9 Apr 2019 23:25:11 +0200	[thread overview]
Message-ID: <20190409212517.7321-5-linux@rasmusvillemoes.dk> (raw)
In-Reply-To: <20190409212517.7321-1-linux@rasmusvillemoes.dk>

When we introduce compact versions of these pointers (a la
CONFIG_GENERIC_BUG_RELATIVE_POINTERS), all access to these members must
go via appropriate accessors. This just mass-converts dynamic_debug.c to
use the new accessors.

Acked-by: Jason Baron <jbaron@akamai.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 lib/dynamic_debug.c | 51 ++++++++++++++++++++++++++++++---------------
 1 file changed, 34 insertions(+), 17 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 7bdf98c37e91..497b1c8ccc2a 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -37,6 +37,23 @@
 #include <linux/device.h>
 #include <linux/netdevice.h>
 
+static inline const char *dd_modname(const struct _ddebug *dd)
+{
+	return dd->modname;
+}
+static inline const char *dd_function(const struct _ddebug *dd)
+{
+	return dd->function;
+}
+static inline const char *dd_filename(const struct _ddebug *dd)
+{
+	return dd->filename;
+}
+static inline const char *dd_format(const struct _ddebug *dd)
+{
+	return dd->format;
+}
+
 extern struct _ddebug __start___verbose[];
 extern struct _ddebug __stop___verbose[];
 
@@ -158,21 +175,21 @@ static int ddebug_change(const struct ddebug_query *query,
 
 			/* match against the source filename */
 			if (query->filename &&
-			    !match_wildcard(query->filename, dp->filename) &&
+			    !match_wildcard(query->filename, dd_filename(dp)) &&
 			    !match_wildcard(query->filename,
-					   kbasename(dp->filename)) &&
+					   kbasename(dd_filename(dp))) &&
 			    !match_wildcard(query->filename,
-					   trim_prefix(dp->filename)))
+					   trim_prefix(dd_filename(dp))))
 				continue;
 
 			/* match against the function */
 			if (query->function &&
-			    !match_wildcard(query->function, dp->function))
+			    !match_wildcard(query->function, dd_function(dp)))
 				continue;
 
 			/* match against the format */
 			if (query->format &&
-			    !strstr(dp->format, query->format))
+			    !strstr(dd_format(dp), query->format))
 				continue;
 
 			/* match against the line number range */
@@ -197,8 +214,8 @@ static int ddebug_change(const struct ddebug_query *query,
 #endif
 			dp->flags = newflags;
 			vpr_info("changed %s:%d [%s]%s =%s\n",
-				 trim_prefix(dp->filename), dp->lineno,
-				 dt->mod_name, dp->function,
+				 trim_prefix(dd_filename(dp)), dp->lineno,
+				 dt->mod_name, dd_function(dp),
 				 ddebug_describe_flags(dp, flagbuf,
 						       sizeof(flagbuf)));
 		}
@@ -533,10 +550,10 @@ static char *dynamic_emit_prefix(const struct _ddebug *desc, char *buf)
 	pos_after_tid = pos;
 	if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME)
 		pos += snprintf(buf + pos, remaining(pos), "%s:",
-				desc->modname);
+				dd_modname(desc));
 	if (desc->flags & _DPRINTK_FLAGS_INCL_FUNCNAME)
 		pos += snprintf(buf + pos, remaining(pos), "%s:",
-				desc->function);
+				dd_function(desc));
 	if (desc->flags & _DPRINTK_FLAGS_INCL_LINENO)
 		pos += snprintf(buf + pos, remaining(pos), "%d:",
 				desc->lineno);
@@ -790,10 +807,10 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
 	}
 
 	seq_printf(m, "%s:%u [%s]%s =%s \"",
-		   trim_prefix(dp->filename), dp->lineno,
-		   iter->table->mod_name, dp->function,
+		   trim_prefix(dd_filename(dp)), dp->lineno,
+		   iter->table->mod_name, dd_function(dp),
 		   ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf)));
-	seq_escape(m, dp->format, "\t\r\n\"");
+	seq_escape(m, dd_format(dp), "\t\r\n\"");
 	seq_puts(m, "\"\n");
 
 	return 0;
@@ -987,20 +1004,20 @@ static int __init dynamic_debug_init(void)
 		return 1;
 	}
 	iter = __start___verbose;
-	modname = iter->modname;
+	modname = dd_modname(iter);
 	iter_start = iter;
 	for (; iter < __stop___verbose; iter++) {
 		entries++;
-		verbose_bytes += strlen(iter->modname) + strlen(iter->function)
-			+ strlen(iter->filename) + strlen(iter->format);
+		verbose_bytes += strlen(dd_modname(iter)) + strlen(dd_function(iter))
+			+ strlen(dd_filename(iter)) + strlen(dd_format(iter));
 
-		if (strcmp(modname, iter->modname)) {
+		if (strcmp(modname, dd_modname(iter))) {
 			modct++;
 			ret = ddebug_add_module(iter_start, n, modname);
 			if (ret)
 				goto out_err;
 			n = 0;
-			modname = iter->modname;
+			modname = dd_modname(iter);
 			iter_start = iter;
 		}
 		n++;
-- 
2.20.1


  parent reply	other threads:[~2019-04-09 21:26 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09 21:25 [PATCH 00/10] implement DYNAMIC_DEBUG_RELATIVE_POINTERS Rasmus Villemoes
2019-04-09 21:25 ` Rasmus Villemoes
2019-04-09 21:25 ` Rasmus Villemoes
2019-04-09 21:25 ` [PATCH 01/10] linux/device.h: use unique identifier for each struct _ddebug Rasmus Villemoes
2019-04-09 21:25 ` [PATCH 02/10] linux/net.h: " Rasmus Villemoes
2019-04-09 21:25 ` [PATCH 03/10] linux/printk.h: " Rasmus Villemoes
2019-04-09 21:25 ` Rasmus Villemoes [this message]
2019-04-09 21:25 ` [PATCH 05/10] dynamic_debug: drop use of bitfields in " Rasmus Villemoes
2019-04-09 21:25 ` [PATCH 06/10] dynamic_debug: introduce CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS Rasmus Villemoes
2019-04-09 21:25 ` [PATCH 07/10] dynamic_debug: add asm-generic implementation for DYNAMIC_DEBUG_RELATIVE_POINTERS Rasmus Villemoes
2019-04-09 21:25   ` Rasmus Villemoes
2019-04-09 21:25   ` Rasmus Villemoes
2019-04-09 21:25 ` [PATCH 08/10] x86-64: select DYNAMIC_DEBUG_RELATIVE_POINTERS Rasmus Villemoes
2019-04-10  7:31   ` Ingo Molnar
2019-04-09 21:25 ` [PATCH 09/10] arm64: " Rasmus Villemoes
2019-04-09 21:25   ` Rasmus Villemoes
2019-04-26  9:39   ` Arnd Bergmann
2019-04-26  9:39     ` Arnd Bergmann
2019-04-26 10:05     ` Rasmus Villemoes
2019-04-26 10:05       ` Rasmus Villemoes
2019-04-26 13:00       ` Nathan Chancellor
2019-04-26 13:00         ` Nathan Chancellor
2019-04-26 19:06         ` [PATCH 11/10] arm64: unbreak DYNAMIC_DEBUG=y build with clang Rasmus Villemoes
2019-04-26 19:06           ` Rasmus Villemoes
2019-04-26 19:06           ` [PATCH 12/10] powerpc: " Rasmus Villemoes
2019-04-26 19:06             ` Rasmus Villemoes
2019-04-29 17:34             ` Nick Desaulniers
2019-04-29 17:34               ` Nick Desaulniers
2019-04-26 19:27           ` [PATCH 11/10] arm64: " Rasmus Villemoes
2019-04-26 19:27             ` Rasmus Villemoes
2019-04-26 21:58             ` Konstantin Ryabitsev
2019-04-26 21:58               ` Konstantin Ryabitsev
2019-04-26 22:07             ` Konstantin Ryabitsev
2019-04-26 22:07               ` Konstantin Ryabitsev
2019-04-29 17:32           ` Nick Desaulniers
2019-04-29 17:32             ` Nick Desaulniers
2019-04-30 18:22             ` Nick Desaulniers
2019-04-30 18:22               ` Nick Desaulniers
2019-05-02  8:57               ` Rasmus Villemoes
2019-05-02  8:57                 ` Rasmus Villemoes
2019-04-09 21:25 ` [PATCH 10/10] powerpc: select DYNAMIC_DEBUG_RELATIVE_POINTERS for PPC64 Rasmus Villemoes
2019-04-09 21:25   ` Rasmus Villemoes
2019-04-23 15:37   ` Christophe Leroy
2019-04-23 19:36     ` Andrew Morton
2019-04-23 19:36       ` Andrew Morton
2019-04-24  6:46       ` Rasmus Villemoes
2019-04-24  6:46         ` Rasmus Villemoes
2019-05-06  6:48 ` [PATCH 00/10] implement DYNAMIC_DEBUG_RELATIVE_POINTERS Rasmus Villemoes
2019-05-06  6:48   ` Rasmus Villemoes
2019-05-06  6:48   ` Rasmus Villemoes
2019-05-06  7:05   ` Ingo Molnar
2019-05-06  7:05     ` Ingo Molnar
2019-05-06  7:05     ` Ingo Molnar
2019-05-06  7:34     ` Rasmus Villemoes
2019-05-06  7:34       ` Rasmus Villemoes
2019-05-06  7:34       ` Rasmus Villemoes
2019-05-06  7:48       ` Ingo Molnar
2019-05-06  7:48         ` Ingo Molnar
2019-05-06  7:48         ` Ingo Molnar
2019-05-06 14:48       ` Segher Boessenkool
2019-05-06 14:48         ` Segher Boessenkool
2019-05-06 14:48         ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190409212517.7321-5-linux@rasmusvillemoes.dk \
    --to=linux@rasmusvillemoes.dk \
    --cc=akpm@linux-foundation.org \
    --cc=jbaron@akamai.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.