Re: [Cocci] [PATCH v4] coccinelle: misc: add minmax script

2021-03-08 Thread Julia Lawall
> +@pmaxif depends on patch@ > +identifier func; > +expression x, y; > +expression max_val; > +binary operator cmp = {>=, >}; > +@@ > + > +func(...) > +{ > + <... > +-if ((x) cmp (y)) { > +-max_val = (x); > +-} else { > +-max_val = (y); > +-} > ++max_val

[Cocci] [PATCH] coccinelle: misc: restrict patch mode in flexible_array.cocci

2021-03-08 Thread Denis Efremov
Skip patches generation for structs/unions with a single field. Changing a zero-length array to a flexible array member in a struct with no named members breaks the compilation. However, reporting such cases is still valuable, e.g. commit 637464c59e0b ("ACPI: NFIT: Fix flexible_array.cocci

[Cocci] [PATCH v5] coccinelle: misc: add minmax script

2021-03-08 Thread Denis Efremov
Check for opencoded min(), max() implementations. Signed-off-by: Denis Efremov --- Changes in v2: - <... ...> instead of ... when any - org mode reports fixed - patch rule to drop excessive () Changes in v3: - "depends on patch && (pmax || pmaxif || pmin || pminif)" fixed Changes in v4: -