tracing: Use ? : shortcut in trace macros

Instead of having:

  #define __assign_str(dst, src)					\
	memcpy(__get_str(dst), __data_offsets.dst##_ptr_ ?		\
		__data_offsets.dst##_ptr_ : "(null)",			\
		__get_dynamic_array_len(dst))

Use the ? : shortcut and compact it down to:

  #define __assign_str(dst, src)					\
	memcpy(__get_str(dst), __data_offsets.dst##_ptr_ ? : "(null)",	\
	       __get_dynamic_array_len(dst))

Link: https://lore.kernel.org/linux-trace-kernel/20240222211442.949327725@goodmis.org

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Chuck Lever <chuck.lever@oracle.com>
Suggested-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
Steven Rostedt (Google) 2024-02-22 16:14:18 -05:00
parent e8b737bfb1
commit 916849860f
2 changed files with 8 additions and 10 deletions

View File

@ -47,7 +47,7 @@
#undef __string
#define __string(item, src) __dynamic_array(char, item, \
strlen((src) ? (const char *)(src) : "(null)") + 1) \
strlen((const char *)(src) ? : "(null)") + 1) \
__data_offsets->item##_ptr_ = src;
#undef __string_len
@ -70,7 +70,7 @@
#undef __rel_string
#define __rel_string(item, src) __rel_dynamic_array(char, item, \
strlen((src) ? (const char *)(src) : "(null)") + 1) \
strlen((const char *)(src) ? : "(null)") + 1) \
__data_offsets->item##_ptr_ = src;
#undef __rel_string_len

View File

@ -32,15 +32,14 @@
#undef __assign_str
#define __assign_str(dst, src) \
memcpy(__get_str(dst), __data_offsets.dst##_ptr_ ? \
__data_offsets.dst##_ptr_ : "(null)", \
memcpy(__get_str(dst), __data_offsets.dst##_ptr_ ? : "(null)", \
__get_dynamic_array_len(dst))
#undef __assign_str_len
#define __assign_str_len(dst, src, len) \
do { \
memcpy(__get_str(dst), __data_offsets.dst##_ptr_ ? \
__data_offsets.dst##_ptr_ : "(null)", len); \
memcpy(__get_str(dst), \
__data_offsets.dst##_ptr_ ? : "(null)", len); \
__get_str(dst)[len] = '\0'; \
} while(0)
@ -95,15 +94,14 @@
#undef __assign_rel_str
#define __assign_rel_str(dst, src) \
memcpy(__get_rel_str(dst), __data_offsets.dst##_ptr_ ? \
__data_offsets.dst##_ptr_ : "(null)", \
memcpy(__get_rel_str(dst), __data_offsets.dst##_ptr_ ? : "(null)", \
__get_rel_dynamic_array_len(dst))
#undef __assign_rel_str_len
#define __assign_rel_str_len(dst, src, len) \
do { \
memcpy(__get_rel_str(dst), __data_offsets.dst##_ptr_ ? \
__data_offsets.dst##_ptr_ : "(null)", len); \
memcpy(__get_rel_str(dst), \
__data_offsets.dst##_ptr_ ? : "(null)", len); \
__get_rel_str(dst)[len] = '\0'; \
} while (0)