[2/5] devtools/cocci: make strlcpy replacement smarter

Message ID 20190403144505.46234-3-bruce.richardson@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series clean up snprintf use for string copying |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Bruce Richardson April 3, 2019, 2:45 p.m. UTC
  The original coccinelle script worked by replacing instances of
snprintf(.."%s",...) with strlcpy(), but only where the source and dest
parameters were plain identifiers. Allowing expressions for those params
opens up a wide range of other possible changes.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 devtools/cocci/strlcpy.cocci | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Patch

diff --git a/devtools/cocci/strlcpy.cocci b/devtools/cocci/strlcpy.cocci
index 335e27128..6f6beb697 100644
--- a/devtools/cocci/strlcpy.cocci
+++ b/devtools/cocci/strlcpy.cocci
@@ -1,6 +1,5 @@ 
 @use_strlcpy@
-identifier src, dst;
-expression size;
+expression src, dst, size;
 @@
 (
 - snprintf(dst, size, "%s", src)