[libvirt] [PATCH] virAsprintf cleanup

Hi, please find a possible asprintf vs. virAsprintf cleanup attached. There were several occations where the result of a failed asprintf was used. Cheers, -- Guido

Guido Günther <agx@sigxcpu.org> wrote:
please find a possible asprintf vs. virAsprintf cleanup attached. There were several occations where the result of a failed asprintf was used.
Nice work. ACK.
diff --git a/.x-sc_prohibit_asprintf b/.x-sc_prohibit_asprintf new file mode 100644 index 0000000..614c238 --- /dev/null +++ b/.x-sc_prohibit_asprintf @@ -0,0 +1,3 @@ +^gnulib/ +^po/ +ChangeLog diff --git a/Makefile.maint b/Makefile.maint index 29c50fc..095e3d6 100644 --- a/Makefile.maint +++ b/Makefile.maint @@ -105,6 +105,12 @@ sc_prohibit_strcmp: { echo '$(ME): use STREQ in place of the above uses of str''cmp' \ 1>&2; exit 1; } || :
+# Use virAsprintf rather than a''sprintf since *strp is undefined on error. +sc_prohibit_asprintf: + @grep -nE '\<a''sprintf\>' $$($(VC_LIST_EXCEPT)) && \ + { echo '$(ME): do not use a''sprintf but virAsprintf'\ + 1>&2; exit 1; } || :
This looks fine, but it might be a little clearer to use a one-character range in the regexp in place of the pair of adjacent single quotes. And a couple other minor changes: # Use virAsprintf rather than a'sprintf since *strp is undefined on error. sc_prohibit_asprintf: @grep -nE '\<[a]sprintf\>' $$($(VC_LIST_EXCEPT)) && \ { echo '$(ME): use virAsprintf, not a'sprintf 1>&2; exit 1; } || : ...
diff --git a/src/util.c b/src/util.c ... @@ -1170,7 +1167,7 @@ virParseNumber(const char **str) /** * virAsprintf * - * like asprintf but makes sure *strp == NULL on failure + * like libc's_asprintf but makes sure *strp == NULL on failure
s/libc/glibc/

Hi, new version attached. It adds your suggestions and also uses virAsprintf in the new src/logging.c. -- Guido

Guido Günther <agx@sigxcpu.org> wrote:
new version attached. It adds your suggestions and also uses virAsprintf in the new src/logging.c.
Thanks! That looks fine, applies, and passes tests. You're welcome to apply it.

On Tue, Dec 23, 2008 at 10:45:57AM +0100, Jim Meyering wrote:
Guido Günther <agx@sigxcpu.org> wrote:
new version attached. It adds your suggestions and also uses virAsprintf in the new src/logging.c.
Thanks! That looks fine, applies, and passes tests. You're welcome to apply it. Applied now. -- Guido

On Mon, Dec 22, 2008 at 10:02:17PM +0100, Guido Günther wrote:
Hi, new version attached. It adds your suggestions and also uses virAsprintf in the new src/logging.c.
Oops, my fault ! Thanks for fixing this :-) Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (3)
-
Daniel Veillard
-
Guido Günther
-
Jim Meyering