Skip to contentSkip to conversation

tracing: Add warning if string in __assign_str() does not match __string()

PATCH In review Steven Rostedt 2 participants 3 messages Feb 23, 2024 – Feb 26, 2024 Tracing

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

PATCH v2 1/1 tracing: Add warning if string in __assign_str() does not match __string()

From: "Steven Rostedt (Google)" <[email protected]>

In preparation to remove the second parameter of __assign_str(), make sure it is really a duplicate of __string() by adding a WARN_ON_ONCE().

---
Changes since v1: https://lore.kernel.org/linux-trace-kernel/[email protected]/

- If src is NULL it is saved as NULL, no need to not test that too.

 include/trace/stages/stage6_event_callback.h | 1 +
 1 file changed, 1 insertion(+)
include/trace/stages/stage6_event_callback.h +1 -0
index 0c0f50bcdc56..935608971899 100644
@@ -35,6 +35,7 @@
 	do {								\
 		char *__str__ = __get_str(dst);				\
 		int __len__ = __get_dynamic_array_len(dst) - 1;		\
+		WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_);	\
 		memcpy(__str__, __data_offsets.dst##_ptr_ ? :		\
 		       EVENT_NULL_STR, __len__);			\
 		__str__[__len__] = '\0';				\
Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · On Fri, 23 Feb 2024 16:13:56 -0500 Steven Rostedt <[email protected]> wrote:

From: "Steven Rostedt (Google)" <[email protected]>

In preparation to remove the second parameter of __assign_str(), make sure it is really a duplicate of __string() by adding a WARN_ON_ONCE().

Looks good to me. So eventually this is removed when the second parameter is removed?

Thank you,

Quoted 24 lines

---
Changes since v1: https://lore.kernel.org/linux-trace-kernel/[email protected]/

- If src is NULL it is saved as NULL, no need to not test that too.

 include/trace/stages/stage6_event_callback.h | 1 +
 1 file changed, 1 insertion(+)
include/trace/stages/stage6_event_callback.h +1 -0
index 0c0f50bcdc56..935608971899 100644
@@ -35,6 +35,7 @@
 	do {								\
 		char *__str__ = __get_str(dst);				\
 		int __len__ = __get_dynamic_array_len(dst) - 1;		\
+		WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_);	\
 		memcpy(__str__, __data_offsets.dst##_ptr_ ? :		\
 		       EVENT_NULL_STR, __len__);			\
 		__str__[__len__] = '\0';				\
Signature · 1 line
2.43.0
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
author maintainer
#2 lore raw
Quoted 11 lines · On Mon, 26 Feb 2024 09:33:28 +0900 Masami Hiramatsu (Google)…
Quoted 5 lines · On Fri, 23 Feb 2024 16:13:56 -0500 Steven Rostedt <[email protected]> wrote:

From: "Steven Rostedt (Google)" <[email protected]>

In preparation to remove the second parameter of __assign_str(), make sure it is really a duplicate of __string() by adding a WARN_ON_ONCE().

Looks good to me. So eventually this is removed when the second parameter is removed?

Yes, I applied this after my other patches.

Quoted 2 lines

Thanks!

-- Steve