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 <[email protected]>       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

/*
 * (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);
}
// 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();
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to