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

Re: [Libvir] [PATCH] Add bus attribute to disk target definition



Jim Meyering <jim meyering net> wrote:

> "Daniel P. Berrange" <berrange redhat com> wrote:
>
>> On Tue, Apr 29, 2008 at 04:10:40PM +0200, Soren Hansen wrote:
>>> On Tue, Apr 29, 2008 at 02:27:00PM +0100, Daniel P. Berrange wrote:
>>> >> +    if (!bus)
>>> >> +        disk->bus = QEMUD_DISK_BUS_IDE;
>>> >> +    else if (!strcmp((const char *)bus, "ide"))
>>> >> +        disk->bus = QEMUD_DISK_BUS_IDE;
>>> >> +    else if (!strcmp((const char *)bus, "scsi"))
>>> >> +        disk->bus = QEMUD_DISK_BUS_SCSI;
>>> >> +    else if (!strcmp((const char *)bus, "virtio"))
>>> >> +        disk->bus = QEMUD_DISK_BUS_VIRTIO;
>>> > Can you use the   STREQ   macro here instead of strcmp.
>>>
>>> Erm... I *could*.. I'm curious, though, why e.g. the similar code right
>>> above it doesn't use STREQ if that's the preferred way to do it?
>>
>> We've been slowly updating code to match these new standards when doing
>> patches.
>
> FYI, there's already a test for this, but it's currently disabled.
> If someone wants to turn it on (remove the sc_prohibit_strcmp
> line from Makefile.cfg) and fix all the new violations exposed
> by running "make syntax-check", it sounds like it would be welcome, now.

In preparation for this, I've just relaxed the regexp in the check
to allow for libvirt's varying coding styles (space or not between
function name and opening parenthesis):

	tests: recognize more uses of strcmp.
	* Makefile.maint (sc_prohibit_strcmp): Relax regexp.

=============================================================================
Index: Makefile.maint
===================================================================
RCS file: /data/cvs/libvirt/Makefile.maint,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -p -u -r1.21 -r1.22
--- Makefile.maint	21 Apr 2008 10:09:07 -0000	1.21
+++ Makefile.maint	29 Apr 2008 14:25:19 -0000	1.22
@@ -91,7 +91,7 @@ sc_prohibit_atoi_atof:

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


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