提交 e9d51507 编写于 作者: L Laurent Vivier 提交者: Michael Tokarev

scripts: add muldiv64() checking coccinelle scripts

Signed-off-by: NLaurent Vivier <lvivier@redhat.com>
Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
上级 96165b9e
// Find muldiv64(i64, i64, x) for potential overflow
@filter@
typedef uint64_t;
typedef int64_t;
{ uint64_t, int64_t, long, unsigned long } a, b;
expression c;
position p;
@@
muldiv64(a,b,c)@p
@script:python@
p << filter.p;
@@
cocci.print_main("potential muldiv64() overflow", p)
// replace muldiv64(a, 1, b) by "a / b"
@@
expression a, b;
@@
-muldiv64(a, 1, b)
+a / b
// replace muldiv64(i32, i32, x) by (uint64_t)i32 * i32 / x
@@
typedef uint32_t;
typedef int32_t;
{ uint32_t, int32_t, int, unsigned int } a, b;
typedef uint64_t;
expression c;
@@
-muldiv64(a,b,c)
+(uint64_t) a * b / c
// replace muldiv64(i32, i64, x) by muldiv64(i64, i32, x)
@@
typedef uint64_t;
typedef int64_t;
typedef uint32_t;
typedef int32_t;
{ uint32_t, int32_t, int, unsigned int } a;
{ uint64_t, int64_t, long, unsigned long } b;
expression c;
@@
-muldiv64(a,b,c)
+muldiv64(b,a,c)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册