Re: [PATCH v4a 00/38] timers: Use timer_shutdown*() before freeing timers

From: Julia Lawall
Date: Sat Nov 05 2022 - 19:18:50 EST




On Sat, 5 Nov 2022, Steven Rostedt wrote:

> On Sat, 5 Nov 2022 11:28:33 -0700
> Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> > On Sat, Nov 5, 2022 at 11:04 AM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> > >
> > > Here's the changes I made after running the script
> >
> > Please. No.
> >
> > What part of "I don't want extra crud" was I unclear on?
>
> The first one was a false change. That is, the script *did* catch it,
> when it should not have. So I reverted the change. The coccinelle
> documentation even states to look over the changes to see if there are
> false positives.
>
> The second change is that it frees three timers all for the same
> object. If you want, I could run the script 2 more times on the same
> file, and it will catch it then.
>
> Would you be happier if I just ran it three times on that file? I can do
> that, and it will produce the same result.

Various suggestions:

1. On your ... put when strict and then on a separate line put when !=
ptr. The when strict will get rid of the goto problem (usually a
desirable feature, but not here) and the when != ptr will be sure that ptr
is not used before the free.

2. If you want to handle the initialization of the function field, then
you can duplicate the rule and add the removal of that assignment in the
first one. This only seems worth it if it is a very common case.
Otherwise, I would agree with Linus and just take care of it by hand
later.

3. Running the rule three times seems to me like a reasonable choice. Or
you could duplicate the rule three times. But that would be more script
to read through. If this is not a common case, though, you could probably
also fix the one up later by hand.

julia