diff options
author | Donald Sharp <donaldsharp72@gmail.com> | 2022-05-13 13:40:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-13 13:40:58 +0200 |
commit | f205a2309c7dc961216417fb49b4639892b219be (patch) | |
tree | 9a9839c3e141e990c96c43a1788ce9c6d95ea84b /tools | |
parent | Merge pull request #11188 from opensourcerouting/fix/argv_find (diff) | |
parent | *: Properly use memset() when zeroing (diff) | |
download | frr-f205a2309c7dc961216417fb49b4639892b219be.tar.xz frr-f205a2309c7dc961216417fb49b4639892b219be.zip |
Merge pull request #11177 from opensourcerouting/fix/memset_memcpy
*: memcpy/memset zeroing
Diffstat (limited to 'tools')
-rw-r--r-- | tools/coccinelle/memset.cocci | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/coccinelle/memset.cocci b/tools/coccinelle/memset.cocci new file mode 100644 index 000000000..0da576cda --- /dev/null +++ b/tools/coccinelle/memset.cocci @@ -0,0 +1,21 @@ +// + +@@ +identifier src, dst; +identifier str, len; +type t =~ "struct"; + +@@ + +( +- memset(&dst, 0, sizeof(t)); ++ memset(&dst, 0, sizeof(dst)); +| +- memcpy(&dst, &src, sizeof(t)); ++ memcpy(&dst, &src, sizeof(dst)); +| +- char str[...]; +... +- memset(&str, 0, ...); ++ memset(&str, 0, sizeof(str)); +) |