From: Max <msuraev@sysmocom.de>
To: cocci@systeme.lip6.fr
Subject: Re: [Cocci] replacing defines
Date: Tue, 18 Dec 2018 16:48:55 +0100 [thread overview]
Message-ID: <2b642105-f754-51a0-2e8b-c9f7d439d0d5@sysmocom.de> (raw)
In-Reply-To: <alpine.DEB.2.20.1812181629290.2886@hadrien>
[-- Attachment #1: Type: text/plain, Size: 1977 bytes --]
Attached are spatch and minimal example to reproduce the error.
I believe that the reason is the last '}' of multiline #define. This
seems like a valid syntax to gcc but spatch gives aforementioned error.
Just in case ML won't accept attachements, here's how #define looks like:
________________
#define OLD(msg, data, len) \
if (msgb_func(msg) != len) { \
printf("%s:%d ERROR! with %d\n", \
__func__, __LINE__, (int) len); \
abort(); \
}
________________
18.12.18 16:34, Julia Lawall пишет:
>
> It's complaining about the rule starting on line 2, which is the one
> removing the #define. So the problem doesn't have anything to do with the
> two rules being together - it never starts executing the second one.
>
> Something being reachable by inconsistent control-flow paths occurs when
> if you trace through the function in one way (ie via one if branch) you
> get one transformation, and if you trace through it in another way you get
> another transformation (or no transformation).
>
> It's a bit strange that this would occur in your case, where you just want
> to remove the entire body of the #define. Can you mak a simple example
> that illustrates the problem?
>
> To figure out what #define is being considered, you can try the
> command-line argument --show-trying. If that doesn't suffice (I don't
> know to what extent it is supported for #define), then --verbose-match
> might be helpful as well.
>
> julia
--
- Max Suraev <msuraev@sysmocom.de> http://www.sysmocom.de/
=======================================================================
* sysmocom - systems for mobile communications GmbH
* Alt-Moabit 93
* 10559 Berlin, Germany
* Sitz / Registered office: Berlin, HRB 134158 B
* Geschaeftsfuehrer / Managing Directors: Harald Welte
[-- Attachment #2: test.c --]
[-- Type: text/x-csrc, Size: 441 bytes --]
/*
* (C)omment
* All Rights Reserved
*/
#include <errno.h>
#define OLD(msg, data, len) \
if (msgb_func(msg) != len) { \
printf("%s:%d ERROR! with %d\n", \
__func__, __LINE__, (int) len); \
abort(); \
}
static void test_error()
{
static const uint8_t res[] = { 0x00, 0x01, 0x21 };
struct msgb *msg;
printf("Testing for error\n");
msg = test_complete();
OLD(msg, res, ARRAY_SIZE(res));
msgb_free(msg);
}
[-- Attachment #3: my.spatch --]
[-- Type: text/plain, Size: 168 bytes --]
// spatch --in-place --sp-file my.spatch test.c
@@
@@
- #define OLD(msg, data, len) ...
@@
expression a, b, c;
@@
- OLD(a, b, c);
+ if (!my_func(a, b, c))
+ abort();
[-- Attachment #4: Type: text/plain, Size: 136 bytes --]
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
next prev parent reply other threads:[~2018-12-18 15:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-12 12:17 [Cocci] replacing defines Max
2018-12-12 12:26 ` Julia Lawall
2018-12-12 18:00 ` Max
[not found] ` <alpine.DEB.2.21.1812130723160.2458@hadrien>
2018-12-13 16:16 ` Max
2018-12-13 19:56 ` Julia Lawall
2018-12-14 11:31 ` Max
2018-12-18 15:25 ` Max
2018-12-18 15:34 ` Julia Lawall
2018-12-18 15:48 ` Max [this message]
2018-12-18 16:10 ` Julia Lawall
2018-12-18 16:26 ` Max
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=2b642105-f754-51a0-2e8b-c9f7d439d0d5@sysmocom.de \
--to=msuraev@sysmocom.de \
--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;
as well as URLs for NNTP newsgroup(s).