diff options
author | Michael Brown <mcb30@ipxe.org> | 2023-05-22 13:43:28 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2023-05-22 13:43:28 +0100 |
commit | 57f3fcee5ebcae6f0ca0df36cc9774b805a65005 (patch) | |
tree | 94de7081ad9eb553fade27099ee829bbf7c132a2 | |
parent | ee786d987f40d1e3e7a7bfc93344fa00b638c429 (diff) | |
download | ipxe-57f3fcee5ebcae6f0ca0df36cc9774b805a65005.zip ipxe-57f3fcee5ebcae6f0ca0df36cc9774b805a65005.tar.gz ipxe-57f3fcee5ebcae6f0ca0df36cc9774b805a65005.tar.bz2 |
merge efi_asprintf()
-rw-r--r-- | src/image/efi_image.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/image/efi_image.c b/src/image/efi_image.c index 0ca4960..039ac8f 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -111,18 +111,14 @@ efi_image_path ( struct image *image, EFI_DEVICE_PATH_PROTOCOL *parent ) { */ static wchar_t * efi_image_cmdline ( struct image *image ) { wchar_t *cmdline; - size_t len; - len = ( strlen ( image->name ) + - ( image->cmdline ? - ( 1 /* " " */ + strlen ( image->cmdline ) ) : 0 ) ); - cmdline = zalloc ( ( len + 1 /* NUL */ ) * sizeof ( wchar_t ) ); - if ( ! cmdline ) + /* Allocate and construct command line */ + if ( efi_asprintf ( &cmdline, "%s%s%s", image->name, + ( image->cmdline ? " " : "" ), + ( image->cmdline ? image->cmdline : "" ) ) < 0 ) { return NULL; - efi_snprintf ( cmdline, ( len + 1 /* NUL */ ), "%s%s%s", - image->name, - ( image->cmdline ? " " : "" ), - ( image->cmdline ? image->cmdline : "" ) ); + } + return cmdline; } |