All of lore.kernel.org
 help / color / mirror / Atom feed
From: Erick Karanja <karanja99erick@gmail.com>
To: outreachy@lists.linux.dev, Julia Lawall <Julia.Lawall@inria.fr>
Cc: Dan Carpenter <dan.carpenter@linaro.org>
Subject: Local-variable initialization semantic patch update
Date: Mon, 07 Apr 2025 14:58:43 +0300	[thread overview]
Message-ID: <844b0916a2198527090255a2b065bffda9084188.camel@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 382 bytes --]

The original semantic patch had deficiencies in handling 
local variable initialization, especially with function calls in
declarations. 
This reduced readability, obscured side effects and made debugging
harder.

Suggested-by: Greg KH <gregkh@linuxfoundation.org>
Suggested-by: Julia Lawall <Julia.Lawall@inria.fr>
Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>


[-- Attachment #2: update_script.cocci --]
[-- Type: text/plain, Size: 2776 bytes --]

@initialize:ocaml@
@@

let bigcode p =
  let p = List.hd p in
  (p.Coccilib.line <> p.Coccilib.line_end) ||
  (p.Coccilib.col_end - p.Coccilib.col >= 60) 


@r1@
type T;
identifier x;
position p;
@@

T@p x;

@badr1@
type T,T2;
identifier r1.x,y;
statement S1,S2;
position r1.p;
@@

T@p x;
... when != S1
T2 y;
... when != S2
x = <+... y ...+>;

@badr1a@
type T;
expression e,f;
identifier r1.x;
statement S,S1,S2;
position r1.p;
binary operator op;
@@

T@p x;
... when != S
x = e;
if (<+...\(x == NULL\|x != NULL\|x op 0\|f(...,x,...)\)...+>) S1 else S2

@badr1b@
type T;
expression e;
identifier r1.x;
statement S;
position r1.p;
position q : script:ocaml() { bigcode q };
@@

T@p x;
... when != S
x = e@q;

@badr_func_assign@
type T;
identifier r1.x;
position r1.p;
identifier f;
statement S;
@@

T@p x;
... when != S
x = f(...);

@depends on !badr1 && !badr1a && !badr1b && !badr_func_assign@
type T;
identifier r1.x;
expression e;
statement S;
position r1.p;
@@

T@p x
+ = e
  ;
... when != S
- x = e;

// ---------------------------

@r2@
type T;
identifier x;
position p;
@@

T@p x;

@badr2@
type T,T2;
identifier r2.x,y;
statement S1,S2;
position r2.p;
@@

T@p x;
... when != S1
T2 y;
... when != S2
x = <+... y ...+>;

@badr2a@
type T;
expression e,f;
identifier r2.x;
statement S,S1,S2;
position r2.p;
binary operator op;
@@

T@p x;
... when != S
x = e;
if (<+...\(x == NULL\|x != NULL\|x op 0\|f(...,x,...)\)...+>) S1 else S2

@badr2b@
type T;
expression e;
identifier r2.x;
statement S;
position r2.p;
position q : script:ocaml() { bigcode q };
@@

T@p x;
... when != S
x = e@q;

@badr_func_assign2@

type T;
identifier r2.x;
position r2.p;
identifier f;
statement S;
@@

T@p x;
... when != S
x = f(...);

@depends on !badr2 && !badr2a && !badr2b && !badr_func_assign2@
type T;
identifier r2.x;
expression e;
statement S;
position r2.p;
@@

T@p x
+ = e
  ;
... when != S
- x = e;

// ---------------------------

@r3@
type T;
identifier x;
position p;
@@

T@p x;

@badr3@
type T,T2;
identifier r3.x,y;
statement S1,S2;
position r3.p;
@@

T@p x;
... when != S1
T2 y;
... when != S2
x = <+... y ...+>;

@badr3a@
type T;
expression e,f;
identifier r3.x;
statement S,S1,S2;
position r3.p;
binary operator op;
@@

T@p x;
... when != S
x = e;
if (<+...\(x == NULL\|x != NULL\|x op 0\|f(...,x,...)\)...+>) S1 else S2

@badr3b@
type T;
expression e;
identifier r3.x;
statement S;
position r3.p;
position q : script:ocaml() { bigcode q };
@@

T@p x;
... when != S
x = e@q;

@badr_func_assign3@
type T;
identifier r3.x;
position r3.p;
identifier f;
statement S;
@@

T@p x;
... when != S
x = f(...);

@depends on !badr3 && !badr3a && !badr3b && !badr_func_assign3@
type T;
identifier r3.x;
expression e;
statement S;
position r3.p;
@@

T@p x
+ = e
  ;
... when != S
- x = e;


             reply	other threads:[~2025-04-07 11:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-07 11:58 Erick Karanja [this message]
2025-04-07 12:32 ` Local-variable initialization semantic patch update Julia Lawall
2025-04-07 12:44   ` Erick Karanja

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=844b0916a2198527090255a2b065bffda9084188.camel@gmail.com \
    --to=karanja99erick@gmail.com \
    --cc=Julia.Lawall@inria.fr \
    --cc=dan.carpenter@linaro.org \
    --cc=outreachy@lists.linux.dev \
    /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.