All of lore.kernel.org
 help / color / mirror / Atom feed
* [cocci] List global variables.
@ 2022-05-09 10:05 Alessandro Carminati
  2022-05-09 10:11 ` Julia Lawall
  2022-05-09 10:17 ` Julia Lawall
  0 siblings, 2 replies; 24+ messages in thread
From: Alessandro Carminati @ 2022-05-09 10:05 UTC (permalink / raw)
  To: cocci

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

Hello,
I need to build a tool that just lists the global variables for a given c
project.
It appeared to me to be a straight simple operation using coccinelle, still
the script I wrote does not return the expected values.
here the script
```
@g@
type T;
global idexpression T x;
@@
x

@script:python@
x << g.x;
@@
print (x)
```
And this is the simple file I used to test it.
```
#include <stdio.h>
#include <stdlib.h>

static char glid[3];
int cnt;

int function(int a){
return a;
}

int main(){
char *p;
int i,c;
p=malloc(100);
i=function(9);
c=sprintf(p, "Nice text%d\n", i);
puts(p);
free(p);
return 0;
}
```
my expectation was to get "glid" and "cnt" as product for the computation,
instead I just get "function".

Could anybody clarify why this?

cheers
Alessandro

[-- Attachment #2: Type: text/html, Size: 1329 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2022-05-21 14:05 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-09 10:05 [cocci] List global variables Alessandro Carminati
2022-05-09 10:11 ` Julia Lawall
2022-05-09 10:17 ` Julia Lawall
     [not found]   ` <CAPp5cGRMAOanfvuhV1LAV9eZka8ZJHRPy6ncMwO=Q+C=GUA2gA@mail.gmail.com>
2022-05-09 10:49     ` [cocci] Fwd: " Alessandro Carminati
2022-05-09 11:49       ` Julia Lawall
2022-05-09 19:23       ` [cocci] List global variables with SmPL Markus Elfring
2022-05-10  7:52         ` Alessandro Carminati
2022-05-10  8:06           ` Julia Lawall
2022-05-10  9:18             ` Alessandro Carminati
2022-05-10  9:24               ` Julia Lawall
2022-05-10  9:53                 ` Alessandro Carminati
2022-05-10 10:39                   ` Julia Lawall
2022-05-10 17:00                     ` Markus Elfring
2022-05-21 14:05                       ` Markus Elfring
2022-05-11  7:38                     ` Alessandro Carminati
2022-05-11  7:44                       ` Julia Lawall
2022-05-11  7:57                         ` Alessandro Carminati
2022-05-11  8:14                       ` Julia Lawall
2022-05-11  8:36                         ` Alessandro Carminati
2022-05-11  8:46                           ` Julia Lawall
2022-05-11 19:54                           ` Markus Elfring
2022-05-11 18:11                       ` Markus Elfring
2022-05-12  6:42                         ` Alessandro Carminati
2022-05-12 16:48                           ` Markus Elfring

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.