Please send the exact semantic patch you are using
If I use the following SmPL approach, ...
assignment_pattern1.cocci:
@is_assigned@
position p;
expression x, y;
expression f != {strcpy, strcat};
statement S1, S2, S3, S4;
@@
y@p = x(...);
... when != if (<+...y...+>) S1 else S2
when != f(...,(<+...y...+>),...)
when != for (...;<+...y...+>;...) S3
when != while (<+...y...+>) S4
when != switch (<+...y...+>) { case ... : ... }
when != (<+...y...+>) ? ... : ...
@is_assigned_without_when_filters@
position p != is_assigned.p;
expression x, y;
@@
*y@p = x(...);
and the exact code on which you are using
Cstdlib-test1.c:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
sig_atomic_t termination = 0;
static void action(int ID)
{
termination = ID;
}
int main(void)
{
static char const name[] = "check.txt";
char* x = (char*) malloc(123);
strcpy(x, name);
signal(SIGTERM, action);
{
FILE* c = fopen(x, "r");
{
printf("file: %s\npointer: %p\n", x, c);
fflush(stdout);
fread(x, 1, 12, c);
fclose(c);
}
realloc(x, 456);
}
fprintf(stderr, "terminated: %d", (int) termination);
return EXIT_SUCCESS;
}
and the exact answer that you expect.
... I get only the following response ...
init_defs_builtins: /usr/share/coccinelle/standard.h
HANDLING: Cstdlib-test1.c
... while I also expect the display of two marked statements.
- char* x = (char*) malloc(123);
and
- FILE* c = fopen(x, "r");
That way I can be sure to give you an appropriate answer.
I'm curious that we can achieve progress in a cooperative way.
Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)