]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[xen] Use standard calling pattern for asprintf()
authorMichael Brown <mcb30@ipxe.org>
Wed, 22 Mar 2017 12:41:01 +0000 (14:41 +0200)
committerMichael Brown <mcb30@ipxe.org>
Wed, 22 Mar 2017 12:41:01 +0000 (14:41 +0200)
Our asprintf() implementation guarantees that strp will be NULL on
allocation failure, but this is not standard behaviour.  Detect errors
by checking for a negative return value instead of a NULL pointer.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/interface/xen/xenstore.c

index 23424a926e217e471d4a2164218cf51b4e79bf06..a14881fcd9c7c932fab64f6b3b58610db8067cf2 100644 (file)
@@ -538,8 +538,7 @@ void xenstore_dump ( struct xen_hypervisor *xen, const char *key ) {
                      child += ( strlen ( child ) + 1 /* NUL */ ) ) {
 
                        /* Construct child key */
-                       asprintf ( &child_key, "%s/%s", key, child );
-                       if ( ! child_key ) {
+                       if ( asprintf ( &child_key, "%s/%s", key, child ) < 0 ){
                                DBGC ( xen, "XENSTORE could not allocate child "
                                       "key \"%s/%s\"\n", key, child );
                                rc = -ENOMEM;