From: Dan Carpenter <dan.carpenter@linaro.org>
To: Costa Shulyupin <costa.shul@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Daniel Bristot de Oliveira <bristot@kernel.org>,
John Kacur <jkacur@redhat.com>,
"Luis Claudio R. Goncalves" <lgoncalv@redhat.com>,
Eder Zulian <ezulian@redhat.com>,
Tomas Glozar <tglozar@redhat.com>,
Gabriele Monaco <gmonaco@redhat.com>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] Fix bug and add osnoise_trace_is_off()
Date: Wed, 15 Jan 2025 12:02:00 +0300 [thread overview]
Message-ID: <4ee1e1a7-f0b3-4062-97d9-45a342d0ca21@stanley.mountain> (raw)
In-Reply-To: <20250115081157.1274398-1-costa.shul@redhat.com>
You need an "rtla: " subsystem prefix in the subject. You're going to
need to remove the words "fix" and "bug" from the subject because this
is just a cleanup.
On Wed, Jan 15, 2025 at 10:09:56AM +0200, Costa Shulyupin wrote:
> The usage of trace_is_off() contains a small and elusive
> bug that requires a detailed explanation.
>
> To expose the bug, let's modify the source code by moving the first member,
> `trace`, of the `osnoise_tool` structure to the second position:
>
> struct osnoise_tool {
> - struct trace_instance trace;
> struct osnoise_context *context;
> + struct trace_instance trace;
>
> A correct program would work properly after this change,
> but this one does not.
No...
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.
regards,
dan carpenter
next prev parent reply other threads:[~2025-01-15 9:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 8:09 [PATCH v2] Fix bug and add osnoise_trace_is_off() Costa Shulyupin
2025-01-15 9:02 ` Dan Carpenter [this message]
2025-01-15 15:26 ` Steven Rostedt
2025-01-15 11:12 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4ee1e1a7-f0b3-4062-97d9-45a342d0ca21@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=bristot@kernel.org \
--cc=costa.shul@redhat.com \
--cc=ezulian@redhat.com \
--cc=gmonaco@redhat.com \
--cc=jkacur@redhat.com \
--cc=lgoncalv@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglozar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox