summaryrefslogtreecommitdiff
path: root/dmioem.c
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2021-01-19 16:26:05 +0100
committerJean Delvare <jdelvare@suse.de>2021-01-19 16:26:05 +0100
commita4b31b2bc537f8703c9bfeff1d5604f6e5684db5 (patch)
treea3e8b477584a310e9809f6bb9653e28ff6017d1d /dmioem.c
parent11e134e54d15e67a64c39a623f492a28df922517 (diff)
downloaddmidecode-git-a4b31b2bc537f8703c9bfeff1d5604f6e5684db5.tar.gz
dmioem: Present HPE type 240 attributes in a nicer way
Present HPE type 240 attributes as a proper list instead of packing them on a single line. This makes it more readable overall, and will also scale better if the number of attributes increases. Signed-off-by: Jean Delvare <jdelvare@suse.de>
Diffstat (limited to 'dmioem.c')
-rw-r--r--dmioem.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/dmioem.c b/dmioem.c
index 8fe84e0..3cdfdea 100644
--- a/dmioem.c
+++ b/dmioem.c
@@ -187,21 +187,24 @@ static int dmi_hpegen(const char *s)
return (dmi_vendor == VENDOR_HPE) ? G10P : G6;
}
-static void dmi_hp_240_attr(const char *fname, u64 code)
+static void dmi_hp_240_attr(u64 defined, u64 set)
{
- char attr[80] = "";
-
- if (code.l & (1ULL << 0))
- strcat(attr, "Updatable ");
- if (code.l & (1ULL << 1))
- strcat(attr, "ResetRequired ");
- if (code.l & (1ULL << 2))
- strcat(attr, "AuthenticationRequired ");
- if (code.l & (1ULL << 3))
- strcat(attr, "InUse ");
- if (code.l & (1ULL << 4))
- strcat(attr, "UefiImage");
- pr_attr(fname, "%s", attr);
+ static const char *attributes[] = {
+ "Updatable",
+ "Reset Required",
+ "Authentication Required",
+ "In Use",
+ "UEFI Image",
+ };
+ unsigned int i;
+
+ pr_attr("Attributes Defined/Set", NULL);
+ for (i = 0; i < ARRAY_SIZE(attributes); i++)
+ {
+ if (!(defined.l & (1UL << i)))
+ continue;
+ pr_subattr(attributes[i], "%s", set.l & (1UL << i) ? "Yes" : "No");
+ }
}
static void dmi_hp_203_assoc_hndl(const char *fname, u16 num)
@@ -591,8 +594,7 @@ static int dmi_decode_hp(const struct dmi_header *h)
else
pr_attr("Image Size", "Not Available");
- dmi_hp_240_attr("Attributes Def", QWORD(data + 0x13));
- dmi_hp_240_attr("Attributes Set", QWORD(data + 0x1B));
+ dmi_hp_240_attr(QWORD(data + 0x13), QWORD(data + 0x1B));
if (DWORD(data + 0x23))
pr_attr("Lowest Supported Version", "0x%08X", DWORD(data + 0x23));