Re: [PATCH v2] USB: mtu3: tracing: Use the new __vstring() helper
From: Chunfeng Yun
Date: Tue Jul 19 2022 - 12:20:04 EST
On Tue, 2022-07-19 at 11:27 -0400, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>
>
> 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.
>
> Cc: Chunfeng Yun <chunfeng.yun@xxxxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: linux-usb@xxxxxxxxxxxxxxx
> Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
> Cc: linux-mediatek@xxxxxxxxxxxxxxxxxxx
> Acked-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
> ---
> Changes since v1:
> https://urldefense.com/v3/__https://lkml.kernel.org/r/20220705224750.354926535@goodmis.org__;!!CTRNKA9wMg0ARbw!w4K66JYkRKSGW-em5q2L6FJ6YI_Z81PAnnTJrBJayW6pf_-JVd5-B5daGto_frdtBJcz$
>
>
> - Removed MTU3_MSG_MAX define. (Chunfeng Yun)
>
> drivers/usb/mtu3/mtu3_trace.h | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/mtu3/mtu3_trace.h
> b/drivers/usb/mtu3/mtu3_trace.h
> index 1b897636daf2..a98fa012b729 100644
> --- a/drivers/usb/mtu3/mtu3_trace.h
> +++ b/drivers/usb/mtu3/mtu3_trace.h
> @@ -18,18 +18,16 @@
>
> #include "mtu3.h"
>
> -#define MTU3_MSG_MAX 256
> -
> TRACE_EVENT(mtu3_log,
> TP_PROTO(struct device *dev, struct va_format *vaf),
> TP_ARGS(dev, vaf),
> TP_STRUCT__entry(
> __string(name, dev_name(dev))
> - __dynamic_array(char, msg, MTU3_MSG_MAX)
> + __vstring(msg, vaf->fmt, vaf->va)
> ),
> TP_fast_assign(
> __assign_str(name, dev_name(dev));
> - vsnprintf(__get_str(msg), MTU3_MSG_MAX, vaf->fmt, *vaf-
> >va);
> + __assign_vstr(msg, vaf->fmt, vaf->va);
> ),
> TP_printk("%s: %s", __get_str(name), __get_str(msg))
> );
Tested-by: Chunfeng Yun <chunfeng.yun@xxxxxxxxxxxx>
Thanks a lot