On Wed, 2016-02-10 at 17:26 +0100, Ján Tomko wrote:
Using strcat directly is more readable than passing strlen
of the copied string to strncat.
---
cfg.mk | 5 +++++
src/storage/storage_backend_logical.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 71b0866..be9e475 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1031,6 +1031,11 @@ sc_prohibit_not_strneq:
halt='Use STREQ instead of !STRNEQ' \
$(_sc_search_regexp)
+sc_prohibit_verbose_strcat:
+ @prohibit='strncat\([^,]*,\s+([^,]*),\s+strlen\(\1\)\)' \
I'd rather use [^,]+ to match parameters, as there will always
be at least one symbol, but shouldn't make any difference in
practice.
+ halt='Use strcat(a, b) instead of strncat(a, b, strlen())'
\
s/strlen()/strlen(b)/
ACK with at least the second fixed.
Cheers.
--
Andrea Bolognani
Software Engineer - Virtualization Team