diff options
| author | Peter Jones <pjones@redhat.com> | 2021-02-18 10:36:23 +0100 |
|---|---|---|
| committer | Peter Jones <pjones@redhat.com> | 2021-02-19 14:28:10 -0500 |
| commit | f1feb3ac04e2c96aa751fda8d36bb50c04ffa58d (patch) | |
| tree | 09dd24bbc16a3b03b3a35f69887350afbbf0da60 /sbat.c | |
| parent | 146f9d8e8d75eff8d3277a5416943877ed902c73 (diff) | |
| download | efi-boot-shim-f1feb3ac04e2c96aa751fda8d36bb50c04ffa58d.tar.gz efi-boot-shim-f1feb3ac04e2c96aa751fda8d36bb50c04ffa58d.zip | |
sbat: drop the struct sbat and just use two variables instead
The struct sbat isn't doing anything and only has two fields so let's pass
pass those two to the functions directly instead of storing it in a struct.
Signed-off-by: Peter Jones <pjones@redhat.com>
Diffstat (limited to 'sbat.c')
| -rw-r--r-- | sbat.c | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -68,21 +68,24 @@ error: } EFI_STATUS -parse_sbat(char *sbat_base, size_t sbat_size, struct sbat *sbat) +parse_sbat(char *sbat_base, size_t sbat_size, size_t *sbats, struct sbat_entry ***sbat) { CHAR8 *current = (CHAR8 *) sbat_base; CHAR8 *end = (CHAR8 *) sbat_base + sbat_size - 1; EFI_STATUS efi_status = EFI_SUCCESS; struct sbat_entry *entry; - struct sbat_entry **entries; - unsigned int i; + struct sbat_entry **entries = NULL; + unsigned int i = 0; - if (!sbat_base || !sbat || sbat_size == 0) + if (!sbat_base || sbat_size == 0 || !sbats || !sbat) return EFI_INVALID_PARAMETER; if (current == end) return EFI_INVALID_PARAMETER; + *sbats = 0; + *sbat = 0; + do { entry = NULL; efi_status = parse_sbat_entry(¤t, end, &entry); @@ -96,24 +99,25 @@ parse_sbat(char *sbat_base, size_t sbat_size, struct sbat *sbat) if (entry) { entries = ReallocatePool( - sbat->entries, sbat->size * sizeof(entry), - (sbat->size + 1) * sizeof(entry)); + entries, i * sizeof(entry), + (i + 1) * sizeof(entry)); if (!entries) { efi_status = EFI_OUT_OF_RESOURCES; goto error; } - sbat->entries = entries; - sbat->entries[sbat->size] = entry; - sbat->size++; + entries[i++] = entry; } } while (entry && *current != '\0'); + *sbats = i; + *sbat = entries; + return efi_status; error: perror(L"Failed to parse SBAT data: %r\n", efi_status); - for (i = 0; i < sbat->size; i++) - FreePool(sbat->entries[i]); + while (i) + FreePool(entries[i--]); return efi_status; } |
