Skip to contentSkip to conversation

coccinelle: api: add kvfree script

PATCH Markus Elfring 2 participants 3 messages Jun 6, 2020 Kernel janitors

lore
Share & tools
lore
#0 lore raw

Review

Quoted 9 lines

+@choice@

(quoted diff) +8 -0
+expression E, E1;
+position kok, vok;
+@@
+
+(
+  if (...) {
+    ...
+    E = \(kmalloc@kok\|…\)(...)

Further implementation details from this SmPL script caught my software development attention.

* Is there a need to add the specification “when any” to the SmPL ellipses before such assignment statements?

* A limited search approach was expressed. Will additional source code variations become relevant?
+ switch statement
+ if branches with single statements
+ conditional operator

Quoted 1 line

+@opportunity depends on !patch …@

…

Review

Quoted 3 lines
(quoted diff) +3 -0
+  E = \(kmalloc\|…\)(..., size, ...)
+  ... when != E = E1
+      when != size = E1

I wonder that two assignments should be excluded here according to the same expression metavariable.

+@pkfree depends on patch exists@
…
+- \(kfree\|kvfree\)(E)
++ vfree(E)

Would you like to use a SmPL code variant like the following at any more places?
(Is it occasionally helpful to increase the change precision?)

+-\(kfree\|kvfree\)
++vfree
+ (E)

Regards,
Markus

#1 lore raw
Quoted 13 lines · Markus Elfring

Review

Quoted 9 lines

+@choice@

(quoted diff) +8 -0
+expression E, E1;
+position kok, vok;
+@@
+
+(
+  if (...) {
+    ...
+    E = \(kmalloc@kok\|…\)(...)

Further implementation details from this SmPL script caught my software development attention.

Quoted 2 lines

* Is there a need to add the specification “when any” to the SmPL ellipses before such assignment statements?

Having multiple assignments to kmalloc in one if seems unlikely, and perhaps one would want to think about such a case differently, so it seems ok as is.

Quoted 6 lines

* A limited search approach was expressed. Will additional source code variations become relevant?
+ switch statement
+ if branches with single statements
+ conditional operator

The point is that there is a kmalloc in one branch and a vmalloc in another branch, so a if with a single branch doesn't seem relevant.

The other cases sem highly improbable.

Quoted 9 lines
Quoted 2 lines

+@opportunity depends on !patch …@

…

Review

Quoted 3 lines
(quoted diff) +3 -0
+  E = \(kmalloc\|…\)(..., size, ...)
+  ... when != E = E1
+      when != size = E1

I wonder that two assignments should be excluded here according to the same expression metavariable.

Doesn't matter. The metavariables are considered separately in the different whens.

Quoted 6 lines

+@pkfree depends on patch exists@
…
+- \(kfree\|kvfree\)(E)
++ vfree(E)

Quoted 7 lines

Would you like to use a SmPL code variant like the following at any more places?
(Is it occasionally helpful to increase the change precision?)

+-\(kfree\|kvfree\)
++vfree
+ (E)

"increase the change precision" seems to be an obscure way to say "improve the formatting". Indeed, leaving (E) as is would have the effect of not changing the formatting. But the problem seems unlikely for a functoin with such a short name. And this presentation will likely run afoul of the fact that you can't attach + code to a disjunction. So the original presentation was more concise, and should be fine in practice.

julia

#2 lore raw
Quoted 8 lines
Quoted 5 lines

* A limited search approach was expressed. Will additional source code variations become relevant?
+ switch statement
+ if branches with single statements
+ conditional operator

The point is that there is a kmalloc in one branch and a vmalloc in another branch, so a if with a single branch doesn't seem relevant.

Is an other wording more appropriate to handle if/else statements without curly brackets?

Quoted 1 line

The other cases sem highly improbable.

This can be.

But how much do such details influence the confidence level for such a SmPL script?

Quoted 10 lines
Quoted 8 lines
Quoted 1 line

+@opportunity depends on !patch …@

…

Review

Quoted 3 lines
(quoted diff) +3 -0
+  E = \(kmalloc\|…\)(..., size, ...)
+  ... when != E = E1
+      when != size = E1

I wonder that two assignments should be excluded here according to the same expression metavariable.

Doesn't matter.

Would different variable names reduce the potential for confusion?

Quoted 1 line

The metavariables are considered separately in the different whens.

Is this information relevant for a better software documentation?

Quoted 9 lines
Quoted 9 lines
Quoted 1 line

+@pkfree depends on patch exists@

…

Quoted 2 lines

+- \(kfree\|kvfree\)(E)
++ vfree(E)

Would you like to use a SmPL code variant like the following at any more places?
(Is it occasionally helpful to increase the change precision?)

Quoted 6 lines
Quoted 3 lines

+-\(kfree\|kvfree\)
++vfree
+ (E)

"increase the change precision" seems to be an obscure way to say "improve the formatting".

We come along a different understanding of such a transformation approach once more.

Quoted 1 line

Indeed, leaving (E) as is would have the effect of not changing the formatting.

I just propose to leave source code unmodified as much as possible here.

Quoted 1 line

But the problem seems unlikely for a functoin with such a short name.

This can be.

Quoted 2 lines

And this presentation will likely run afoul of the fact that you can't attach + code to a disjunction.

There is a minus character before such SmPL disjunctions.

Quoted 1 line

So the original presentation was more concise, and should be fine in practice.

Is less duplicated SmPL code useful?

I point a design alternative out.
Would you like to integrate it anyhow?

Regards,
Markus