From: Markus Elfring <Markus.Elfring@web.de>
To: cocci@inria.fr
Subject: [cocci] Analysis challenges with SmPL for pass-through functions?
Date: Sun, 19 Oct 2025 16:00:36 +0200 [thread overview]
Message-ID: <4afdfd37-3177-4480-9648-ab0d7f59097c@web.de> (raw)
Hello,
I am curious if further developers will become interested to discuss technical
details like the following (in combination with the software “Coccinelle 1.3.0”).
Another source file example:
#include <string.h>
void my_test_copy(void)
{
char text[123];
char* target = strcpy(text, "Hello!");
target = strcpy(target, "Bye");
}
A)
SmPL script variant:
@display@
constant char[] input;
identifier x, y;
@@
*y = strcpy(x, input)
Test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> /usr/bin/spatch show_selected_strcpy_calls.cocci test-copy_literal_to_buffer2.c
…
@@ -3,6 +3,4 @@
void my_test_copy(void)
{
char text[123];
- char* target = strcpy(text, "Hello!");
- target = strcpy(target, "Bye");
}
B)
SmPL script variant:
@display2@
constant char[] literal;
identifier i;
@@
*i = strcpy(i, literal)
Test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> /usr/bin/spatch show_selected_strcpy_calls2.cocci test-copy_literal_to_buffer2.c
…
@@ -4,5 +4,4 @@ void my_test_copy(void)
{
char text[123];
char* target = strcpy(text, "Hello!");
- target = strcpy(target, "Bye");
}
The variable definition was not matched by the second source code search approach
because the used identifiers are obviously different there.
This aspect did not hinder an additional match by the first source code search approach
according to another assignment for the variable “target” while the same identifier
was found by two metavariables.
Will further clarifications become more interesting for corresponding case distinctions?
Regards,
Markus
next reply other threads:[~2025-10-19 14:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-19 14:00 Markus Elfring [this message]
2025-10-19 14:10 ` [cocci] Analysis challenges with SmPL for pass-through functions? Julia Lawall
2025-10-19 14:25 ` Markus Elfring
2025-10-19 14:30 ` Julia Lawall
2025-10-19 14:37 ` Markus Elfring
2025-10-19 14:40 ` Julia Lawall
2025-10-19 14:50 ` Markus Elfring
2025-10-21 6:16 ` Markus Elfring
2025-10-21 9:12 ` Julia Lawall
2025-10-21 9:40 ` Markus Elfring
2025-10-24 19:03 ` [cocci] Terminology evolution for SmPL? Markus Elfring
2025-10-22 9:20 ` [cocci] Analysis challenges with SmPL for pass-through functions? Markus Elfring
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=4afdfd37-3177-4480-9648-ab0d7f59097c@web.de \
--to=markus.elfring@web.de \
--cc=cocci@inria.fr \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).