[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] maint: prohibit use of strncpy
From: |
Jim Meyering |
Subject: |
[PATCH] maint: prohibit use of strncpy |
Date: |
Thu, 24 May 2012 16:23:54 +0200 |
The use of strncpy is so seldom justifiable, that it is best
just to avoid it altogether. Thus, we should enforce that:
>From 22695d676de21d0af6d50ca8218eeb49b45608ab Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 24 May 2012 16:21:34 +0200
Subject: [PATCH] maint: prohibit use of strncpy
* cfg.mk (sc_prohibit_strncpy): New syntax-check rule.
Exempt pinky.c and who.c, at least for now.
---
cfg.mk | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/cfg.mk b/cfg.mk
index 7a86c2a..ff5d996 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -403,6 +403,12 @@ sc_prohibit_strncmp:
{ echo '$(ME): use STREQ_LEN or STRPREFIX instead of str''ncmp' \
1>&2; exit 1; } || :
+# Really. You don't want to use this function.
+sc_prohibit_strncpy:
+ @prohibit='\<str''ncpy *\(' \
+ halt='do not use str''ncpy, period' \
+ $(_sc_search_regexp)
+
# Enforce recommended preprocessor indentation style.
sc_preprocessor_indentation:
@if cppi --version >/dev/null 2>&1; then \
@@ -472,3 +478,6 @@ exclude_file_name_regexp--sc_prohibit_test_backticks = \
# Exempt test.c, since it's nominally shared, and relatively static.
exclude_file_name_regexp--sc_prohibit_operator_at_end_of_line = \
^src/(ptx|test|head)\.c$$
+
+# Exempt pinky and who: their uses of this function appear to be correct.
+exclude_file_name_regexp--sc_prohibit_strncpy = ^src/(pinky|who)\.c$$
--
1.7.10.2.565.gbd578b5
- [PATCH] maint: prohibit use of strncpy,
Jim Meyering <=