On Wed, 15 Jan 2025 21:40:40 +0300 Dan Carpenter <dan.carpen...@linaro.org> 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. -- Steve