Re: [PATCH] coccinelle: merge two rules from flex_alloc.cocci
- From
Denton Liu <liu.denton@gmail.com>
- Date
- Nov 12, 2019, 17:59 UTC
- Message-ID
- <20191112175926.GA41101@generichostname>
- In-Reply-To
- <f867512c-e5b2-6bca-2a37-2976f4c182bd@web.de>
Hi Markus,
Thanks for the contribution.
I see that you've sent many Coccinelle patches to the mailing list. It might be better to send them all together as a single threaded patchset so that reviewers will have an easier time finding all of them.
On Tue, Nov 12, 2019 at 04:34:34PM +0100, Markus Elfring wrote:
Show 20 quoted lines
> From: Markus Elfring <elfring@users.sourceforge.net> > Date: Tue, 12 Nov 2019 16:30:14 +0100 > > This script contained two transformation rules for the semantic patch language > which used duplicate code. > Thus combine these rules by using a SmPL disjunction for the replacement > of two identifiers. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > --- > contrib/coccinelle/flex_alloc.cocci | 25 +++++++++++++------------ > 1 file changed, 13 insertions(+), 12 deletions(-) > > diff --git a/contrib/coccinelle/flex_alloc.cocci b/contrib/coccinelle/flex_alloc.cocci > index e9f7f6d861..1b4fa8f801 100644 > --- a/contrib/coccinelle/flex_alloc.cocci > +++ b/contrib/coccinelle/flex_alloc.cocci > @@ -1,13 +1,14 @@ > -@@ > +@adjustment@
None of our other cocci scripts have rulenames so I would drop the rulename here. It also doesn't really help since its name is so generic.
I would also echo this for the other patches you've sent.
Show 24 quoted lines
> expression str; > -identifier x, flexname; > -@@ > -- FLEX_ALLOC_MEM(x, flexname, str, strlen(str)); > -+ FLEX_ALLOC_STR(x, flexname, str); > - > -@@ > -expression str; > -identifier x, ptrname; > -@@ > -- FLEXPTR_ALLOC_MEM(x, ptrname, str, strlen(str)); > -+ FLEXPTR_ALLOC_STR(x, ptrname, str); > +identifier x, name; > +@@ > +( > +-FLEX_ALLOC_MEM > ++FLEX_ALLOC_STR > +| > +-FLEXPTR_ALLOC_MEM > ++FLEXPTR_ALLOC_STR > +) > + (x, name, str > +- , strlen(str) > + );
Small nitpick but to be inline with how the rest of our cocci scripts are written, I'd write this as
(x, name, str - , strlen(str) );
Thanks,
Denton
> -- > 2.24.0 >