mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
33af88cf70
For example, the following transformation: - sizeof(s)-1 + STRLEN(s) would replace sizeof by STRLEN even in the STRLEN macro definition itself, which generates following nonsensical patch: --- src/basic/macro.h +++ /tmp/cocci-output-8753-b50773-macro.h @@ -182,7 +182,7 @@ static inline unsigned long ALIGN_POWER2 * Contrary to strlen(), this is a constant expression. * @x: a string literal. */ -#define STRLEN(x) (sizeof(""x"") - 1) +#define STRLEN(x) (STRLEN("" x "")) /* * container_of - cast a member of a structure out to the containing structure Let's exclude the macro itself from the transformation to avoid this
39 lines
376 B
Plaintext
39 lines
376 B
Plaintext
@@
|
|
expression s;
|
|
@@
|
|
- memset(&s, 0, sizeof(s))
|
|
+ zero(s)
|
|
@@
|
|
expression s;
|
|
@@
|
|
- memset(s, 0, sizeof(*s))
|
|
+ zero(*s)
|
|
@@
|
|
expression s;
|
|
@@
|
|
- bzero(&s, sizeof(s))
|
|
+ zero(s)
|
|
@@
|
|
expression s;
|
|
@@
|
|
- bzero(s, sizeof(*s))
|
|
+ zero(*s)
|
|
@@
|
|
expression a, b;
|
|
@@
|
|
(
|
|
#define memzero
|
|
&
|
|
- memset(a, 0, b)
|
|
+ memzero(a, b)
|
|
)
|
|
@@
|
|
expression a, b;
|
|
@@
|
|
(
|
|
#define memzero
|
|
&
|
|
- bzero(a, b)
|
|
+ memzero(a, b)
|
|
)
|