[PATCH 1/1] cmd: simplify 'efidebug boot add' command

We can determine the length of the device path in the boot option after it is created. There is no need to keep track of the length while building the device path.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- cmd/efidebug.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 67ab06aefc..3398f56962 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -964,7 +964,6 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, struct efi_load_option lo; void *data = NULL; efi_uintn_t size; - efi_uintn_t fp_size = 0; efi_status_t ret; int r = CMD_RET_SUCCESS;
@@ -1008,8 +1007,6 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, r = CMD_RET_FAILURE; goto out; } - fp_size += efi_dp_size(file_path) + - sizeof(struct efi_device_path); argc -= 5; argv += 5; } else if (!strcmp(argv[0], "-i")) { @@ -1026,8 +1023,6 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, } argc -= 3; argv += 3; - fp_size += efi_dp_size(initrd_dp) + - sizeof(struct efi_device_path); } else if (!strcmp(argv[0], "-s")) { if (argc < 1 || lo.optional_data) { r = CMD_RET_USAGE; @@ -1056,7 +1051,8 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, }
lo.file_path = final_fp; - lo.file_path_length = fp_size; + lo.file_path_length = efi_dp_size(final_fp) + + sizeof(struct efi_device_path);
size = efi_serialize_load_option(&lo, (u8 **)&data); if (!size) { -- 2.30.2

On 10/14/21 11:46 PM, Heinrich Schuchardt wrote:
We can determine the length of the device path in the boot option after it is created. There is no need to keep track of the length while building the device path.
As we are using end of total device path node as separator this does not work.
Sorry for the noise.
Best regards
Heinrich
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
cmd/efidebug.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 67ab06aefc..3398f56962 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -964,7 +964,6 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, struct efi_load_option lo; void *data = NULL; efi_uintn_t size;
- efi_uintn_t fp_size = 0; efi_status_t ret; int r = CMD_RET_SUCCESS;
@@ -1008,8 +1007,6 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, r = CMD_RET_FAILURE; goto out; }
fp_size += efi_dp_size(file_path) +
} else if (!strcmp(argv[0], "-i")) {sizeof(struct efi_device_path); argc -= 5; argv += 5;
@@ -1026,8 +1023,6 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, } argc -= 3; argv += 3;
fp_size += efi_dp_size(initrd_dp) +
} else if (!strcmp(argv[0], "-s")) { if (argc < 1 || lo.optional_data) { r = CMD_RET_USAGE;sizeof(struct efi_device_path);
@@ -1056,7 +1051,8 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, }
lo.file_path = final_fp;
- lo.file_path_length = fp_size;
lo.file_path_length = efi_dp_size(final_fp) +
sizeof(struct efi_device_path);
size = efi_serialize_load_option(&lo, (u8 **)&data); if (!size) {
-- 2.30.2
participants (1)
-
Heinrich Schuchardt