Re: [libvirt] PATCH: Remove use of strcmp, etc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote:

> On Fri, May 09, 2008 at 10:42:08PM +0100, Daniel P. Berrange wrote:
>> On Fri, May 09, 2008 at 11:40:39PM +0200, Jim Meyering wrote:
>> > "Daniel P. Berrange" <berrange@xxxxxxxxxx> 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.
>> > You might want to extend the corresponding regexp in Makefile.maint
>> > to prohibit the other completely excluded functions like strncmp.
>> >
>> > BTW, did you make this change automatically?  or do a binary before/after
>> > comparison.  In which case there's not much point in reviewing the details...
>>
>> No I did it manually & checked with inspection. Could try a binary diff
>> with & without the patch if you want...
>
> Actually a binary diff won't work because of places where I changed
> from strncmp to  STRPREFIX - the latter includes a calls to strlen
> instead of hardcoding the constant

To check, so far I've converted all strcmp uses with these:

git grep -l '!strcmp *('|xargs perl -pi -e 's/!strcmp( *)\(/STREQ$1(/g'
git grep -l 'strcmp *([^=]*== *0'|xargs perl -pi -e 's/\bstrcmp( *\(.*?\)) *== *0/STREQ$1/'
git grep -l 'strcmp *([^=]*!= *0'|xargs perl -pi -e 's/\bstrcmp( *\(.*?\)) *!= *0/STRNEQ$1/g'

git grep -l '!(strcmp *('|xargs perl -pi -e 's/!\(strcmp( *\(.*?\))\)/STREQ$1/'

git grep -l 'strcmp *('|xargs perl -pi -e 's/\bstrcmp( *\()/STRNEQ$1/g'

Next (later ;-) is to convert strncmp uses and compare with yours.

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]