[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250115102651.306f3b7b@gandalf.local.home>
Date: Wed, 15 Jan 2025 10:26:51 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: Costa Shulyupin <costa.shul@...hat.com>, Daniel Bristot de Oliveira
<bristot@...nel.org>, John Kacur <jkacur@...hat.com>, "Luis Claudio R.
Goncalves" <lgoncalv@...hat.com>, Eder Zulian <ezulian@...hat.com>, Tomas
Glozar <tglozar@...hat.com>, Gabriele Monaco <gmonaco@...hat.com>,
linux-trace-kernel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] Fix bug and add osnoise_trace_is_off()
On Wed, 15 Jan 2025 12:02:00 +0300
Dan Carpenter <dan.carpenter@...aro.org> wrote:
> You introduced a bug by changing the order.
>
> You have to undestand that to the original authors this stuff was really
> easy and they knew the order of the struct members because they chose it
> deliberately. In the end, they get so used to the code that
> "&record->trace" just becomes an idiom for casting "record" and they
> forget how it looks to a newcomer.
>
> I *personally* am not a fan of code which assumes we know the order of
> the struct members so I don't have a problem with you re-writing the
> code. But the commit message must say that it is just a cleanup and not
> a fix.
>
> Which reminds me that I had intended to create a container_of_first()
> for code like this which assumes that container_of() is just a cast.
> There is lots of code like this:
>
> struct something *member = container_of(p, struct foo, first_member);
>
> if (IS_ERR(member)) {
>
> Which relies on the face that "first_member" is the first member of
> foo struct. It's a quite common thing.
I agree that this is not a bug, but I will happily take a clean up to make
it more robust.
-- Steve
Powered by blists - more mailing lists