Coccinelle: semantic code search for missing put_device()
Quoted 28 lines · On Sat, 16 Feb 2019, [email protected] wrote:
Quoted 16 lines
Quoted 4 lines
Quoted 2 lines
Does the first SmPL when specification include the case that a call of the function “put_device” can occur within a branch of an if statement?
It does include that,
Thanks for this acknowledgement.
So it seems that you find my interpretation of this bit of SmPL code appropriate.
Quoted 1 line
but there is another execution path where the put device is not present.
It is tried to find such cases.
Quoted 2 lines
But given the test in the if in the when code,
on that execution path id is NULL, an so there is no need to put it.Quoted 7 lines
I would like to point out that the function “put_device” belongs also to the category of functions which tolerate the passing of null pointers.
https://elixir.bootlin.com/linux/v5.0-rc6/source/drivers/base/core.c#L2053
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/base/core.c?id=cb5b020a8d38f77209d0472a0fea755299a8ec78#n2053Have we got still different software development opinions about the need for an extra pointer check in the “second” SmPL when specification?
Thanks to Julia and Markus.
We will modify the the if in the when code like this:
Review if (id == NULL || ...) { ... return ...; } · line 25
Quoted 5 lines
(quoted diff) +1
-1@@ -22,7 +22,7 @@ if (id == NULL || ...) { ... return ...; } ... when != put_device(&id->dev) when != platform_device_put(id) when != of_dev_put(id) - when != if (id) { ... put_device(&id->dev) ... } + when != if (...) { ... put_device(&id->dev) ... }
This looks ok. You can check the old version and the new version and see if there is any differencein the set of reports.
julia
Quoted 4 lines
Review if (id == NULL || ...) { ... return ...; } · line 22
Quoted 4 lines
We will modify the the if in the when code like this:
(quoted diff) +0
-0@@ -22,7 +22,7 @@ if (id == NULL || ...) { ... return ...; } ... when != put_device(&id->dev)
…
Quoted 4 lines
Review if (id == NULL || ...) { ... return ...; } · line 23
Quoted 2 lines
(quoted diff) +1
-1- when != if (id) { ... put_device(&id->dev) ... } + when != if (...) { ... put_device(&id->dev) ... }This looks ok.
I have got another different software development opinion also for such SmPL code in the adjusted line.
I find this specific source code search variant irrelevant because the shown reference release function should be found by the first SmPL when specification already.
Would you like to determine generally if the desired function call is present at all?
Thus I do not see a need (or requirement) for a duplicate search attempt.
Regards,
Markus
Quoted 18 lines · Markus Elfring
Quoted 4 lines
Quoted 4 lines
We will modify the the if in the when code like this:
(quoted diff) +0
-0@@ -22,7 +22,7 @@ if (id == NULL || ...) { ... return ...; } ... when != put_device(&id->dev)…
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- when != if (id) { ... put_device(&id->dev) ... } + when != if (...) { ... put_device(&id->dev) ... }This looks ok.
I have got another different software development opinion also for such SmPL code in the adjusted line.
I find this specific source code search variant irrelevant because the shown reference release function should be found by the first SmPL when specification already.
Would you like to determine generally if the desired function call is present at all?
Quoted 1 line
Thus I do not see a need (or requirement) for a duplicate search attempt.
Why don't you actually try it and see what the difference is rather than repeatedly giving false information?
julia
Quoted 4 lines
Quoted 1 line
Thus I do not see a need (or requirement) for a duplicate search attempt.
Why don't you actually try it and see what the difference is rather than repeatedly giving false information?
I suggest to clarify this software development disagreement by the following SmPL code.
... when != put_stuff(my_pointer)
when != if (...) { ... put_stuff(my_pointer) ... }Is this a specification for a bit of duplicate code?
Or:
Do you insist to find such a function call only within a branch of an if statement?
Regards,
Markus