All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Yuan Can <yuancan@huawei.com>, cocci@inria.fr
Cc: Julia Lawall <Julia.Lawall@inria.fr>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	kernel-janitors@vger.kernel.org
Subject: Re: [cocci] [PATCH v3 1/2] coccinelle: locks: add missing_mutex_init.cocci script
Date: Sat, 24 Sep 2022 17:40:28 +0200	[thread overview]
Message-ID: <58a33107-51c3-a392-8357-a0793736c66f@web.de> (raw)
In-Reply-To: <20220922115535.44132-2-yuancan@huawei.com>

…
> +++ b/scripts/coccinelle/locks/missing_mutex_init.cocci
> +/// Report mutex used without initialize. False positives can occur
> +/// when the mutex allocation and initialization happens in two
> +/// different files.


How do you think about to use the following wording variant?


+/// Report mutexes which are used without initialization.
+/// False positives can occur when
+/// * the mutex allocation and initialization will be performed in
+///   two different source files.
+/// * inappropriate data types will be found in the source code
+///   because of unsafe scope resolution.


> +///
> +// Confidence: Low


Will this categorisation trigger further development considerations?



…

> +@r1@
> +identifier s, fld;
> +struct s *mm;
> +@@
> +mutex_init(&(mm->fld))
> +
> +@r2@
> +identifier r1.s, r1.fld;
> +position p;
> +@@
> +
> +struct s {
> +  ...
> +  struct mutex fld@p;
> +  ...
> +};


How “safe” do you find the scope resolution for the searched data types?


Would you like to explain data processing consequences a bit more for
inheriting metavariables after these SmPL rules would occasionally not match?


…

> +@script:python depends on report@
> +p << r5.p;
> +p1 << r4.p;
> +s << r3.s;
> +fld << r3.fld;
> +@@
> +msg = "Mutex %s inside the struct %s malloced at line %s is possibly used at line %s without init." % (fld, s, p[0].line, p1[0].line);
> +coccilib.report.print_report(p[0], msg)

I suggest to use the following statement variant.

coccilib.report.print_report(p[0],
                             "Mutex “%s” within the structure “%s” (which was allocated at line %s) is possibly used at line %s without initialization."
                             % (fld, s, p[0].line, p1[0].line))


Regards,
Markus

  parent reply	other threads:[~2022-09-24 15:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 11:55 [cocci] [PATCH v3 0/2] coccinelle: Introduce cocci script to detect missing mutext and spin lock initialization Yuan Can
2022-09-22 11:55 ` [cocci] [PATCH v3 1/2] coccinelle: locks: add missing_mutex_init.cocci script Yuan Can
2022-09-22 18:11   ` Markus Elfring
2022-09-23 14:21     ` Julia Lawall
2022-09-23 17:02       ` [cocci] [v3 " Markus Elfring
2022-09-23 17:08         ` Julia Lawall
2022-09-23 17:47           ` Markus Elfring
2022-09-23 19:27             ` Julia Lawall
2022-09-24  8:15               ` Markus Elfring
2022-09-24  8:36   ` [cocci] [PATCH v3 " Markus Elfring
2022-09-24 15:40   ` Markus Elfring [this message]
2022-09-25 20:33   ` Markus Elfring
2022-09-22 11:55 ` [cocci] [PATCH v3 2/2] coccinelle: locks: add missing_spin_lock_init.cocci script Yuan Can
2022-09-22 17:19 ` [cocci] [PATCH v3 0/2] coccinelle: Introduce cocci script to detect missing mutext and spin lock initialization Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58a33107-51c3-a392-8357-a0793736c66f@web.de \
    --to=markus.elfring@web.de \
    --cc=Julia.Lawall@inria.fr \
    --cc=cocci@inria.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=nicolas.palix@imag.fr \
    --cc=yuancan@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.