Re: [PATCH v4] tools/rtla: Add osnoise_trace_is_off()

From: Dan Carpenter
Date: Fri Jan 17 2025 - 00:08:23 EST


On Thu, Jan 16, 2025 at 07:34:32PM -0500, Steven Rostedt wrote:
> On Wed, 15 Jan 2025 21:40:40 +0300
> Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
>
> > On Wed, Jan 15, 2025 at 07:58:30PM +0200, Costa Shulyupin wrote:
> > > The original code accidentally works because offset of
> > > `record->trace` is zero.
> >
> > It doesn't "accidentally work". The people who write this kind of
> > code 100% understand what they are doing. They don't see it as
> > anything complicated.
>
> I'm taking this patch but I replaced the change log with the following text:
>
> tools/rtla: Add osnoise_trace_is_off()
>
> All of the users of trace_is_off() passes in &record->trace as the second
> parameter, where record is a pointer to a struct osnoise_tool. This record
> could be NULL and there is a hidden dependency that the trace field is the
> first field to allow &record->trace to work with a NULL record pointer.
>
> In order to make this code a bit more robust, as record shouldn't be
> dereferenced if it is NULL, even if the code does work, create a new
> function called osnoise_trace_is_off() that takes the pointer to a
> struct osnoise_tool as its second parameter. This way it can properly test
> if it is NULL before it dereferences it.
>
> The old function trace_is_off() is removed and the function
> osnoise_trace_is_off() is added into osnoise.c which is what the
> struct osnoise_tool is associated with.

Thanks!

regards,
dan carpenter