aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2023-05-22 13:43:28 +0100
committerMichael Brown <mcb30@ipxe.org>2023-05-22 13:43:28 +0100
commit57f3fcee5ebcae6f0ca0df36cc9774b805a65005 (patch)
tree94de7081ad9eb553fade27099ee829bbf7c132a2
parentee786d987f40d1e3e7a7bfc93344fa00b638c429 (diff)
downloadipxe-57f3fcee5ebcae6f0ca0df36cc9774b805a65005.zip
ipxe-57f3fcee5ebcae6f0ca0df36cc9774b805a65005.tar.gz
ipxe-57f3fcee5ebcae6f0ca0df36cc9774b805a65005.tar.bz2
merge efi_asprintf()
-rw-r--r--src/image/efi_image.c16
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;
}