[libvirt] PATCH: Remove use of strcmp, etc

Jim Meyering jim at meyering.net
Thu May 15 07:10:52 UTC 2008


"Daniel P. Berrange" <berrange at redhat.com> wrote:
> On Fri, May 09, 2008 at 11:40:39PM +0200, Jim Meyering wrote:
>> "Daniel P. Berrange" <berrange at redhat.com> wrote:
>>
>> > This patch removes all use of strcmp, strncmp, strcasecmp and strncasecmp
>> > in favour of the equality macros we have defined in internal.h, eg STREQ,
>> > STRNEQ, STRNEQLEN, STREQLEN, etc, etc
>>
>> Nice.  With that, you can remove sc_prohibit_strcmp
>> from the list of disabled checks in Makefile.cfg.
>
> I have comitted the patch and enabled this check now
>
>> You might want to extend the corresponding regexp in Makefile.maint
>> to prohibit the other completely excluded functions like strncmp.
>
> My grep regex foo isn't upto scratch on this - gimme perl ! Feel free to
> add it if you have a chance though.

Yeah, Perl regexps are great, but grep -E is very similar.
The business with "''" below doesn't help -- that is solely to
obscure strings that would otherwise trigger a false-positive match.

>From fd867ed796a94b32769259db19b8927d9dcd2d16 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Thu, 15 May 2008 09:07:44 +0200
Subject: [PATCH] * Makefile.maint (sc_prohibit_strcmp): Also prohibit strncmp.

---
 Makefile.maint |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/Makefile.maint b/Makefile.maint
index 0f79ed7..a593ae2 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -90,8 +90,9 @@ sc_prohibit_atoi_atof:
 		1>&2; exit 1; } || :

 # Use STREQ rather than comparing strcmp == 0, or != 0.
+# Similarly, use STREQLEN or STRPREFIX rather than strncmp.
 sc_prohibit_strcmp:
-	@grep -nE '! *str''cmp *\(|\<str''cmp *\([^)]+\) *=='		\
+	@grep -nE '! *str''n?cmp *\(|\<str''n?cmp *\([^)]+\) *=='	\
 	    $$($(VC_LIST_EXCEPT)) &&					\
 	  { echo '$(ME): use STREQ in place of the above uses of str''cmp' \
 		1>&2; exit 1; } || :
--
1.5.5.1.148.gbc1be




More information about the libvir-list mailing list