Explorar el Código

[xen] Use standard calling pattern for asprintf()

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>
tags/v1.20.1
Michael Brown hace 7 años
padre
commit
01496a5028
Se han modificado 1 ficheros con 1 adiciones y 2 borrados
  1. 1
    2
      src/interface/xen/xenstore.c

+ 1
- 2
src/interface/xen/xenstore.c Ver fichero

538
 		      child += ( strlen ( child ) + 1 /* NUL */ ) ) {
538
 		      child += ( strlen ( child ) + 1 /* NUL */ ) ) {
539
 
539
 
540
 			/* Construct child key */
540
 			/* Construct child key */
541
-			asprintf ( &child_key, "%s/%s", key, child );
542
-			if ( ! child_key ) {
541
+			if ( asprintf ( &child_key, "%s/%s", key, child ) < 0 ){
543
 				DBGC ( xen, "XENSTORE could not allocate child "
542
 				DBGC ( xen, "XENSTORE could not allocate child "
544
 				       "key \"%s/%s\"\n", key, child );
543
 				       "key \"%s/%s\"\n", key, child );
545
 				rc = -ENOMEM;
544
 				rc = -ENOMEM;

Loading…
Cancelar
Guardar