diff --git a/.x-sc_prohibit_strcmp_and_strncmp b/.x-sc_prohibit_strcmp_and_strncmp deleted file mode 100644 index 77c3ee6ad0..0000000000 --- a/.x-sc_prohibit_strcmp_and_strncmp +++ /dev/null @@ -1,9 +0,0 @@ -^gnulib/ -^ChangeLog-old$ -^docs/ -^examples/domain-events/events-c/event-test\.c$ -^src/internal\.h$ -^src/lxc/lxc_container\.c$ -^src/node_device/node_device_devkit\.c$ -^src/node_device/node_device_hal\.c$ -^src/storage/parthelper\.c$ diff --git a/.x-sc_prohibit_strncmp b/.x-sc_prohibit_strncmp new file mode 100644 index 0000000000..8be205529a --- /dev/null +++ b/.x-sc_prohibit_strncmp @@ -0,0 +1 @@ +^src/internal\.h$ diff --git a/Makefile.am b/Makefile.am index e88814467d..d3f8876b23 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,7 +35,7 @@ EXTRA_DIST = \ .x-sc_prohibit_nonreentrant \ .x-sc_prohibit_sprintf \ .x-sc_prohibit_strcmp \ - .x-sc_prohibit_strcmp_and_strncmp \ + .x-sc_prohibit_strncmp \ .x-sc_prohibit_strncpy \ .x-sc_prohibit_test_minus_ao \ .x-sc_prohibit_VIR_ERR_NO_MEMORY \ diff --git a/cfg.mk b/cfg.mk index 286b9022c3..0851f44a8c 100644 --- a/cfg.mk +++ b/cfg.mk @@ -231,12 +231,14 @@ sc_avoid_write: halt='consider using safewrite instead of write' \ $(_sc_search_regexp) -# Use STREQ rather than comparing strcmp == 0, or != 0. -# Similarly, use STREQLEN or STRPREFIX rather than strncmp. -sc_prohibit_strcmp_and_strncmp: - @prohibit='strn?cmp *\(' \ - halt='use STREQ() in place of the above uses of str[n]cmp' \ - $(_sc_search_regexp) +# Similar to the gnulib maint.mk rule for sc_prohibit_strcmp +# Use STREQLEN or STRPREFIX rather than comparing strncmp == 0, or != 0. +sc_prohibit_strncmp: + @grep -nE '! *str''ncmp *\(|\&2; exit 1; } || : # Use virAsprintf rather than as'printf since *strp is undefined on error. sc_prohibit_asprintf: