[ovs-dev] [PATCH 2/2] Makefile: Add rule to check for new uses of strncpy() in userspace.
Ben Pfaff
blp at nicira.com
Fri Feb 20 18:42:21 UTC 2015
This should keep more uses from creeping in again.
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
Makefile.am | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index 0480d20..479f1af 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -244,6 +244,21 @@ printf-check:
fi
.PHONY: printf-check
+# Check for strncpy().
+ALL_LOCAL += strncpy-check
+strncpy-check:
+ @cd $(srcdir); \
+ if test -e .git && (git --version) >/dev/null 2>&1 && \
+ git --no-pager grep -n -e '\bstrncpy(' `git ls-files | grep '\.[ch]$$' \
+ | grep -vE '^datapath'` \
+ | $(EGREP) -v ':[ ]*/?\*'; \
+ then \
+ echo "See above for list of uses of strncpy(). Please use"; \
+ echo "another function, e.g. ovs_strlcpy() or ovs_strzcpy()."; \
+ exit 1; \
+ fi
+.PHONY: strncpy-check
+
# Check that certain data structures are always declared "static".
ALL_LOCAL += static-check
static-check:
--
1.7.10.4
More information about the dev
mailing list