All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] coccinelle: api: add kvfree script
  2020-06-06  7:30 ` Markus Elfring
  (?)
@ 2020-06-06 14:04 ` Markus Elfring
  -1 siblings, 0 replies; 34+ messages in thread
From: Markus Elfring @ 2020-06-06 14:04 UTC (permalink / raw)
  To: Denis Efremov, Coccinelle, Gilles Muller, Julia Lawall,
	Masahiro Yamada, Michal Marek, Nicolas Palix
  Cc: linux-kernel, kernel-janitors

> +@choice@
> +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


> +@opportunity depends on !patch …@
> +  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

^ permalink raw reply	[flat|nested] 34+ messages in thread
* Re: coccinelle: api: add kvfree script
@ 2020-06-14 15:10 Markus Elfring
  0 siblings, 0 replies; 34+ messages in thread
From: Markus Elfring @ 2020-06-14 15:10 UTC (permalink / raw)
  To: Denis Efremov, cocci; +Cc: linux-kernel

> … Looks like it's impossible to break "when" lines.

Thus I became also curious on clarification for further software
development possibilities around the safer application of code exclusion
specifications by the means of the semantic patch language.

Regards,
Markus

^ permalink raw reply	[flat|nested] 34+ messages in thread
* Re: [PATCH] coccinelle: api: add kvfree script
@ 2020-06-06  7:30 ` Markus Elfring
  0 siblings, 0 replies; 34+ messages in thread
From: Markus Elfring @ 2020-06-06  7:30 UTC (permalink / raw)
  To: Denis Efremov, Coccinelle, Gilles Muller, Julia Lawall,
	Masahiro Yamada, Michal Marek, Nicolas Palix
  Cc: kernel-janitors, linux-kernel

> Check that alloc and free types of functions match each other.

Further software development challenges are interesting also for such an use case.


> +/// Check that kvmalloc'ed memory is freed by kfree functions,
> +/// vmalloc'ed by vfree functions and kvmalloc'ed by kvfree
> +/// functions.

* How do you think about to offer a wording suggestion for subjects of
  generated patches?

* Will the presented case distinction trigger further improvements for
  the desired matching?

* Would you like to generalise the safe handling of allocations
  and corresponding release of system resources?


> +// Confidence: High

I suggest to reconsider this information once more.


> +virtual patch
> +virtual report
> +virtual org
> +virtual context

+virtual patch, report, org, context

Is such a SmPL code variant more succinct?


> +@choice@

* Can it be that this SmPL rule is not relevant for all operation modes?

* Will additional dependencies matter?


> +    E = \(kmalloc@kok\|kzalloc@kok\|krealloc@kok\|kcalloc@kok\|kmalloc_node@kok\|kzalloc_node@kok\|kmalloc_array@kok\|kmalloc_array_node@kok\|kcalloc_node@kok\)(...)

I would prefer an other coding style here.

* Items for such SmPL disjunctions can be specified also on multiple lines.

* The semantic patch language supports further means to handle function name lists
  in more convenient ways.
  Would you like to work with customised constraints?


> +msg = "WARNING: kmalloc is used to allocate this memory at line %s" % (k[0].line)
> +coccilib.report.print_report(p[0], msg)

* I propose once more omit the extra variable “msg” at similar places.
  The desired message object can be directly passed as a function parameter.

* I find the diagnostic text insufficient.

* Can the corresponding function category be dynamically determined?


Are you looking for opportunities to avoid unwanted code duplication?

Regards,
Markus

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2020-06-14 15:10 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-06 14:04 [PATCH] coccinelle: api: add kvfree script Markus Elfring
2020-06-06 14:04 ` [Cocci] " Markus Elfring
2020-06-06 14:04 ` Markus Elfring
2020-06-06 14:39 ` Julia Lawall
2020-06-06 14:39   ` [Cocci] " Julia Lawall
2020-06-06 14:39   ` Julia Lawall
2020-06-06 15:10   ` Markus Elfring
2020-06-06 15:10     ` [Cocci] " Markus Elfring
2020-06-06 15:10     ` Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2020-06-14 15:10 Markus Elfring
2020-06-06  7:30 [PATCH] " Markus Elfring
2020-06-06  7:30 ` [Cocci] " Markus Elfring
2020-06-06  7:30 ` Markus Elfring
2020-06-06  7:46 ` Julia Lawall
2020-06-06  7:46   ` [Cocci] " Julia Lawall
2020-06-06  7:46   ` Julia Lawall
2020-06-06  9:50   ` Markus Elfring
2020-06-06  9:50     ` [Cocci] " Markus Elfring
2020-06-06  9:50     ` Markus Elfring
2020-06-07 14:02     ` Coccinelle: Extending capabilities for source file pre-selection Markus Elfring
2020-06-07 14:02       ` [Cocci] " Markus Elfring
2020-06-07 14:02       ` Markus Elfring
2020-06-06 11:06   ` coccinelle: api: add kvfree script Markus Elfring
2020-06-06 11:06     ` [Cocci] " Markus Elfring
2020-06-06 11:06     ` Markus Elfring
2020-06-06 11:11     ` Julia Lawall
2020-06-06 11:11       ` [Cocci] " Julia Lawall
2020-06-06 11:11       ` Julia Lawall
2020-06-06 11:21       ` Markus Elfring
2020-06-06 11:21         ` [Cocci] " Markus Elfring
2020-06-06 11:21         ` Markus Elfring
2020-06-07  6:42         ` Coccinelle: Improving software components around usage of SmPL disjunctions Markus Elfring
2020-06-07  6:42           ` [Cocci] " Markus Elfring
2020-06-07  6:42           ` Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.