[libvirt] [PATCHv3 0/3] sysinfo trailing spaces

Eric Blake eblake at redhat.com
Wed Jul 6 21:21:04 UTC 2011

On 06/30/2011 02:32 AM, Minoru Usui wrote:
> Hi, Eric
> On Wed, 29 Jun 2011 11:52:41 -0600
> Eric Blake <eblake at redhat.com> wrote:
>> Incorporating my own suggestions from earlier rounds of review.
>> Minoru's original 2/2 patch is unchanged.
>> I think this series is probably worth including in 0.9.3, since
>> it is fixing a just-added feature, but won't push without feedback.
> Thank you for your patches. I think these are good itself.

With that, I'll push my patch 1 and 2, then review your patch 3 v4.

> But my 2/2 patch depends on prior behaviour of virSkipSpacesBackwards().
> In case of @str consists of only spaces, prior virSkipSpacesBackwards() set NULL pointer to @endp. 
> Your version set non-NULL but points to a NULL pointer.

That's easy enough to fix - I could make virSkipSpacesBackwards set
@endp to NULL if nothing remains.  In fact, if I do that, then your v2
patch applies.  So here's what I squashed in:

diff --git i/src/util/util.c w/src/util/util.c
index 457c7fa..5542557 100644
--- i/src/util/util.c
+++ w/src/util/util.c
@@ -1600,7 +1600,8 @@ virTrimSpaces(char *str, char **endp)
  * virSkipSpacesBackwards:
  * @str: start of string
  * @endp: on entry, *endp must be NULL or a location within @str, on exit,
- * will be adjusted to skip trailing spaces
+ * will be adjusted to skip trailing spaces, or to NULL if @str had nothing
+ * but spaces.
 virSkipSpacesBackwards(const char *str, char **endp)
@@ -1612,6 +1613,8 @@ virSkipSpacesBackwards(const char *str, char **endp)
     if (!*endp)
         *endp = s + strlen(s);
     virTrimSpaces(s, endp);
+    if (s == *endp)
+        *endp = NULL;

diff --git i/src/util/util.h w/src/util/util.h
index 3972fa5..7a1eb11 100644
--- i/src/util/util.h
+++ w/src/util/util.h
@@ -166,8 +166,8 @@ int virHexToBin(unsigned char c);

 int virMacAddrCompare (const char *mac1, const char *mac2);

-void virSkipSpaces(const char **str);
-void virSkipSpacesAndBackslash(const char **str);
+void virSkipSpaces(const char **str) ATTRIBUTE_NONNULL(1);
+void virSkipSpacesAndBackslash(const char **str) ATTRIBUTE_NONNULL(1);
 void virTrimSpaces(char *str, char **endp) ATTRIBUTE_NONNULL(1);
 void virSkipSpacesBackwards(const char *str, char **endp)

Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110706/6686f18d/attachment-0001.sig>

More information about the libvir-list mailing list