From: elfring@users.sourceforge.net (SF Markus Elfring)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Checking signal handler implementations with SmPL
Date: Wed, 15 Jul 2015 09:09:21 +0200 [thread overview]
Message-ID: <55A60721.5050209@users.sourceforge.net> (raw)
Hello,
I am looking for a specific programming mistake with the help
of the semantic patch language once more.
1. A SmPL approach like the following seems to work to some degree.
@find_unsafe@
identifier receiver =~ "^(?x)
(?:
(?:alarm|parent|sig(?:chld|hup|term))_handler
|
handle_sigterm
|
(?:CancelJ|cancel_j)ob
)$";
@@
void receiver(...)
{
...
(
- exit(...);
|
- fprintf(...);
)
...
}
elfring at Sonne:~/Projekte/CUPS> spatch.opt -sp-file async-unsafe1.cocci -dir lokal > async-unsafe1.diff && cat async-unsafe1.diff
init_defs_builtins: /usr/local/lib/coccinelle/standard.h
?
Skipping:lokal/vcnet/regex/regerror.c
diff -u -p a/backend/ipp.c b/backend/ipp.c
--- a/backend/ipp.c
+++ b/backend/ipp.c
@@ -3271,8 +3271,6 @@ sigterm_handler(int sig) /* I - Signal
if (tmpfilename[0])
unlink(tmpfilename);
-
- exit(1);
2. I have tried another SmPL script variant out.
@show_unsafe@
identifier receiver =~ "^(?x)
(?:
(?:alarm|parent|sig(?:chld|hup|term))_handler
|
handle_sigterm
|
(?:CancelJ|cancel_j)ob
)$";
@@
void receiver(...)
{
...
(
* exit
|
* fprintf
)
(...);
...
}
elfring at Sonne:~/Projekte/CUPS> spatch.opt -sp-file async-unsafe2.cocci -dir lokal > async-unsafe2.diff && cat async-unsafe2.diff
init_defs_builtins: /usr/local/lib/coccinelle/standard.h
?
diff -u -p lokal/backend/dnssd.c /tmp/nothing/backend/dnssd.c
--- lokal/backend/dnssd.c
+++ /tmp/nothing/backend/dnssd.c
@@ -1289,7 +1289,6 @@ sigterm_handler(int sig) /* I - Signal
(void)sig;
if (job_canceled)
- exit(CUPS_BACKEND_OK);
else
job_canceled = 1;
}
diff -u -p lokal/backend/usb-darwin.c /tmp/nothing/backend/usb-darwin.c
--- lokal/backend/usb-darwin.c
+++ /tmp/nothing/backend/usb-darwin.c
@@ -2262,9 +2262,7 @@ sigterm_handler(int sig) /* I - Signal
while (waitpid(child_pid, &status, 0) < 0 && errno == EINTR);
if (WIFEXITED(status))
- exit(WEXITSTATUS(status));
else if (status == SIGTERM || status == SIGKILL)
- exit(0);
else
{
fprintf(stderr, "DEBUG: Child crashed on signal %d\n", status);
diff -u -p lokal/backend/ipp.c /tmp/nothing/backend/ipp.c
--- lokal/backend/ipp.c
+++ /tmp/nothing/backend/ipp.c
@@ -3272,7 +3272,6 @@ sigterm_handler(int sig) /* I - Signal
if (tmpfilename[0])
unlink(tmpfilename);
- exit(1);
}
Why did the first approach find less?
Should the call of the function "fprintf" in the source file "usb-darwin.c"
also be marked for further considerations here?
Are there any more update candidates to consider?
3. If I add the parameter "-jobs 4" to the shown commands for a parallel
source code analysis, I wonder about a message like the following.
[Pid 5399]: Error creating async-unsafe2 : File exists; proceeding without stdout/stderr redirection
Should it be avoided usually?
Regards,
Markus
next reply other threads:[~2015-07-15 7:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-15 7:09 SF Markus Elfring [this message]
2015-07-15 14:27 ` [Cocci] Checking signal handler implementations with SmPL Julia Lawall
2015-07-15 20:38 ` SF Markus Elfring
2015-07-16 5:41 ` [Cocci] Deletion of blank lines? SF Markus Elfring
2015-07-17 9:50 ` Julia Lawall
2015-07-17 11:12 ` SF 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=55A60721.5050209@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=cocci@systeme.lip6.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