maint.mk: add strncpy-prohibiting syntax-check rule
authorJim Meyering <meyering@redhat.com>
Fri, 25 May 2012 14:38:49 +0000 (16:38 +0200)
committerJim Meyering <meyering@redhat.com>
Fri, 25 May 2012 17:19:18 +0000 (19:19 +0200)
* top/maint.mk (sc_prohibit_strncpy): New rule, from coreutils.

ChangeLog
top/maint.mk

index 686228c..1252100 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-25  Jim Meyering  <meyering@redhat.com>
+
+       maint.mk: add strncpy-prohibiting syntax-check rule
+       * top/maint.mk (sc_prohibit_strncpy): New rule, from coreutils.
+
 2012-05-24  Jim Meyering  <meyering@redhat.com>
 
        maint.mk: compute $(gpg_key_ID) more portably
index 9746410..11cb6a6 100644 (file)
@@ -332,6 +332,14 @@ sc_prohibit_strcmp:
        halt='$(ME): replace strcmp calls above with STREQ/STRNEQ'      \
          $(_sc_search_regexp)
 
+# Really.  You don't want to use this function.
+# It may fail to NUL-terminate the destination,
+# and always NUL-pads out to the specified length.
+sc_prohibit_strncpy:
+       @prohibit='\<strncpy *\('                                       \
+       halt='do not use strncpy, period'                               \
+         $(_sc_search_regexp)
+
 # Pass EXIT_*, not number, to usage, exit, and error (when exiting)
 # Convert all uses automatically, via these two commands:
 # git grep -l '\<exit *(1)' \