Repository : ssh://git@diktynna/batman-adv
On branch : master
commit fce06f6da01b39e16391de141466fb7e0a35c02e Author: Steven Rostedt (Google) rostedt@goodmis.org Date: Sun Jul 31 15:03:31 2022 -0400
batman-adv: tracing: Use the new __vstring() helper
Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new __vstring() helper that will use a va_list and only write enough of the string into the ring buffer that is needed.
Link: https://lkml.kernel.org/r/20220724191650.236b1355@rorschach.local.home
Cc: Marek Lindner mareklindner@neomailbox.ch Cc: Ingo Molnar mingo@kernel.org Cc: Andrew Morton akpm@linux-foundation.org Cc: Simon Wunderlich sw@simonwunderlich.de Cc: Antonio Quartulli a@unstable.cc Cc: "David S. Miller" davem@davemloft.net Cc: Eric Dumazet edumazet@google.com Cc: Jakub Kicinski kuba@kernel.org Cc: Paolo Abeni pabeni@redhat.com Cc: b.a.t.m.a.n@lists.open-mesh.org Cc: netdev@vger.kernel.org Acked-by: Sven Eckelmann sven@narfation.org Signed-off-by: Steven Rostedt (Google) rostedt@goodmis.org [sven@narfation.org: add compat code] Signed-off-by: Sven Eckelmann sven@narfation.org
fce06f6da01b39e16391de141466fb7e0a35c02e compat-include/linux/tracepoint.h | 24 ++++++++++++++++++++++++ net/batman-adv/trace.h | 9 ++------- 2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/compat-include/linux/tracepoint.h b/compat-include/linux/tracepoint.h new file mode 100644 index 00000000..4a79f51a --- /dev/null +++ b/compat-include/linux/tracepoint.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_TRACEPOINT_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_TRACEPOINT_H_ + +#include <linux/version.h> +#include_next <linux/tracepoint.h> + +#if LINUX_VERSION_IS_LESS(6, 0, 0) + +#define __vstring(item, fmt, ap) __dynamic_array(char, item, 256) +#define __assign_vstr(dst, fmt, va) \ + WARN_ON_ONCE(vsnprintf(__get_dynamic_array(dst), 256, fmt, *va) >= 256) + +#endif /* LINUX_VERSION_IS_LESS(6, 0, 0) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_TRACEPOINT_H_ */ diff --git a/net/batman-adv/trace.h b/net/batman-adv/trace.h index d673ebdd..31c8f922 100644 --- a/net/batman-adv/trace.h +++ b/net/batman-adv/trace.h @@ -28,8 +28,6 @@
#endif /* CONFIG_BATMAN_ADV_TRACING */
-#define BATADV_MAX_MSG_LEN 256 - TRACE_EVENT(batadv_dbg,
TP_PROTO(struct batadv_priv *bat_priv, @@ -40,16 +38,13 @@ TRACE_EVENT(batadv_dbg, TP_STRUCT__entry( __string(device, bat_priv->soft_iface->name) __string(driver, KBUILD_MODNAME) - __dynamic_array(char, msg, BATADV_MAX_MSG_LEN) + __vstring(msg, vaf->fmt, vaf->va) ),
TP_fast_assign( __assign_str(device, bat_priv->soft_iface->name); __assign_str(driver, KBUILD_MODNAME); - WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), - BATADV_MAX_MSG_LEN, - vaf->fmt, - *vaf->va) >= BATADV_MAX_MSG_LEN); + __assign_vstr(msg, vaf->fmt, vaf->va); ),
TP_printk(