Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts: add muldiv64() checking coccinelle scripts
Signed-off-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
- Loading branch information
Showing
4 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// replace muldiv64(a, 1, b) by "a / b" | ||
@@ | ||
expression a, b; | ||
@@ | ||
-muldiv64(a, 1, b) | ||
+a / b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// 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) |