summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2020-01-07 06:02:33 +0100
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2020-01-07 18:08:20 +0100
commit173cd9e73ad833bf479cc5b400de5ca738ef7510 (patch)
tree2b727fddb47045daa207d4764e68f6218400a64b /cmd
parent7b31efc54c3fba33d1305a0f9b730472bb0f63eb (diff)
downloadu-boot-173cd9e73ad833bf479cc5b400de5ca738ef7510.tar.gz
cmd: efidebug: simplify get_guid_text()
When we hit a matching GUID we can directly return the text. There is no need for a check after the loop. efi_guid_t is defined as 8 byte aligned but GUIDs in packed structures do not follow this alignment. Do not require the argument of get_guid_text() to be correctly aligned. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/efidebug.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index 1fff4390de..45ed5be885 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -254,24 +254,27 @@ static const struct {
};
/**
- * get_guid_text - get string of protocol guid
- * @guid: Protocol guid
- * Return: String
+ * get_guid_text - get string of GUID
*
- * Return string for display to represent the protocol.
+ * Return description of GUID.
+ *
+ * @guid: GUID
+ * Return: description of GUID or NULL
*/
-static const char *get_guid_text(const efi_guid_t *guid)
+static const char *get_guid_text(const void *guid)
{
int i;
- for (i = 0; i < ARRAY_SIZE(guid_list); i++)
+ for (i = 0; i < ARRAY_SIZE(guid_list); i++) {
+ /*
+ * As guidcmp uses memcmp() we can safely accept unaligned
+ * GUIDs.
+ */
if (!guidcmp(&guid_list[i].guid, guid))
- break;
+ return guid_list[i].text;
+ }
- if (i != ARRAY_SIZE(guid_list))
- return guid_list[i].text;
- else
- return NULL;
+ return NULL;
}
/**