summaryrefslogtreecommitdiffstats
path: root/src/image/efi_image.c
diff options
context:
space:
mode:
authorMichael Brown2023-05-22 14:35:34 +0200
committerMichael Brown2023-05-22 16:10:16 +0200
commitce2200d5fb3d337c7fc7e8ff337c2ddf7645ba89 (patch)
tree500327d40c308f8259f98ad6968f6d92a4571420 /src/image/efi_image.c
parent[image] Generalise concept of selected image (diff)
downloadipxe-ce2200d5fb3d337c7fc7e8ff337c2ddf7645ba89.tar.gz
ipxe-ce2200d5fb3d337c7fc7e8ff337c2ddf7645ba89.tar.xz
ipxe-ce2200d5fb3d337c7fc7e8ff337c2ddf7645ba89.zip
[efi] Add efi_asprintf() and efi_vasprintf()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/image/efi_image.c')
-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 6a7bba01..43713403 100644
--- a/src/image/efi_image.c
+++ b/src/image/efi_image.c
@@ -109,18 +109,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;
}