On 06/30/2011 02:32 AM, Minoru Usui wrote:
Hi, Eric
On Wed, 29 Jun 2011 11:52:41 -0600
Eric Blake <eblake(a)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.
*/
void
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)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org