Skip to contentSkip to conversation

coccinelle: semantic patch for missing put_device()

PATCH Julia Lawall 2 participants 4 messages Feb 15, 2019 1 message not in the archive Kernel janitors

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 18 lines · On Fri, 15 Feb 2019, [email protected] wrote:

Hi Julia, thank you very much.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

In a function, for variables returned by calling of_find_device_by_node(),

Do variables really get returned?
The provided pointer should usually be stored somewhere.

Thank you very much, we will consider this situation and submit a next version to fix it.

I don't know what Markus is talking about here, so I'm not sure that a change is needed.

I think Markus means that we need to deal with two situations:
1, The return value of of_find_device_by_node () is assigned to a variable, such as:
pdev = of_find_device_by_node(np);
2, The return value of of_find_device_by_node() is assigned to a variable in a structure, such as:
dev->pdev = of_find_device_by_node(args.np);

So I plan to modify the following to capture both cases:

Review

Quoted 2 lines
(quoted diff) +1 -1
-local idexpression id;
+expression id;

I'm not sure that this is a good idea. There is likely no need for a put in the latter case.

julia

Quoted 17 lines

...
id = of_find_device_by_node@p1(x)

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

+ "ERROR: missing put_device;"

Will change confidence considerations result in another fine-tuning for this message?

Thank you, we will change "ERROR" to "WARNING".

I think ERROR is fine. If it is a real positive than it is a real problem. Warning is for things that look ugly, but don't have any impact on the execution.

OK, I will keep it.
Thanks.

Regards,
Wen

#2 lore raw
Quoted 5 lines

Review

Quoted 3 lines

So I plan to modify the following to capture both cases:

(quoted diff) +1 -1
-local idexpression id;
+expression id;

I'm not sure that this is a good idea.

Why have you got doubts here?

Quoted 1 line

There is likely no need for a put in the latter case.

I have got understanding difficulties for such information. What did you try to express with this sentence finally?

Regards,
Markus

#3 lore raw
Quoted 6 lines · Markus Elfring
Quoted 5 lines

Review

Quoted 3 lines

So I plan to modify the following to capture both cases:

(quoted diff) +1 -1
-local idexpression id;
+expression id;

I'm not sure that this is a good idea.

Quoted 7 lines

Why have you got doubts here?

Quoted 1 line

There is likely no need for a put in the latter case.

I have got understanding difficulties for such information. What did you try to express with this sentence finally?

The whole goal of the semantic patch is to ensure that put_device is called when needed. If the value is stored in a structure, then someone else will likely take care of calling put_device later when the structure is destroyed.

julia

#4 lore raw
Quoted 2 lines

The whole goal of the semantic patch is to ensure that put_device is called when needed.

Thanks for this clarification.

The software development goal seems to be clear to some degree.

Quoted 1 line

If the value is stored in a structure,

Will any further means become relevant for the discussed data processing?

Quoted 2 lines

then someone else will likely take care of calling put_device later when the structure is destroyed.

Such a view is reasonable.

Are there any additional source code analysis and software development challenges to consider for safer resource management?

Regards,
Markus