From: Julia Lawall <julia.lawall@inria.fr>
To: Sumera Priyadarsini <sylphrenadin@gmail.com>
Cc: cocci@systeme.lip6.fr, michal.lkml@markovi.net,
nicolas.palix@imag.fr, linux-kernel@vger.kernel.org,
Gilles.Muller@lip6.fr
Subject: Re: [Cocci] [PATCH V2] coccinelle: iterators: Add for_each_child.cocci script
Date: Tue, 13 Oct 2020 12:30:36 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.22.394.2010131226130.2674@hadrien> (raw)
In-Reply-To: <20201012171909.ihbx73evyj5dosxl@adolin>
I have one more change to suggest. This one only affects the patch case,
as the other cases just point to a problem but don't ompletely specify
what to do about it.
> +@ruleone depends on patch && !context && !org && !report@
> +
> +local idexpression r.n;
> +iterator r.i,i1;
> +expression e;
> +expression list [r.n1] es;
> +statement S;
> +@@
> +
> + i(es,n,...) {
> + ...
> +(
> + of_node_put(n);
> +|
> + e = n
> +|
> + return n;
> +|
> + i1(...,n,...) S
> +|
> ++ of_node_put(n);
> +? return ...;
> +)
> + ... when any
> + }
There is one occurrence of the following code:
for_each_available_child_of_node(search, child) {
name = of_get_property(child, "regulator-compatible", NULL);
if (!name)
name = child->name;
if (!strcmp(desc->of_match, name)) {
of_node_put(search);
return of_node_get(child);
}
}
In this case, the for_each_available_child_of_node has incremented the
reference count of child by 1, and then the return increments it again.
It would be ok to put an of_not_put before the return, which is done by
the above rule, but the code would be even simpler if it would just leave
the reference count as is. So before the current return case, you can put
another return case that does the following:
- return of_node_get(n);
+ return n;
julia
prev parent reply other threads:[~2020-10-13 10:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-12 17:19 [PATCH V2] [Cocci] " Sumera Priyadarsini
2020-10-13 10:30 ` Julia Lawall [this message]
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=alpine.DEB.2.22.394.2010131226130.2674@hadrien \
--to=julia.lawall@inria.fr \
--cc=Gilles.Muller@lip6.fr \
--cc=cocci@systeme.lip6.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.lkml@markovi.net \
--cc=nicolas.palix@imag.fr \
--cc=sylphrenadin@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®