Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+2 -7
+2 -7
net/batman-adv/trace.h
··· 28 28 29 29 #endif /* CONFIG_BATMAN_ADV_TRACING */ 30 30 31 - #define BATADV_MAX_MSG_LEN 256 32 - 33 31 TRACE_EVENT(batadv_dbg, 34 32 35 33 TP_PROTO(struct batadv_priv *bat_priv, ··· 38 40 TP_STRUCT__entry( 39 41 __string(device, bat_priv->soft_iface->name) 40 42 __string(driver, KBUILD_MODNAME) 41 - __dynamic_array(char, msg, BATADV_MAX_MSG_LEN) 43 + __vstring(msg, vaf->fmt, vaf->va) 42 44 ), 43 45 44 46 TP_fast_assign( 45 47 __assign_str(device, bat_priv->soft_iface->name); 46 48 __assign_str(driver, KBUILD_MODNAME); 47 - WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), 48 - BATADV_MAX_MSG_LEN, 49 - vaf->fmt, 50 - *vaf->va) >= BATADV_MAX_MSG_LEN); 49 + __assign_vstr(msg, vaf->fmt, vaf->va); 51 50 ), 52 51 53 52 TP_printk(