diff options
author | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2024-01-29 18:01:27 +0100 |
---|---|---|
committer | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2024-02-02 19:56:54 +0100 |
commit | c11f176ab16a3488c0b057fed41d76ef96091564 (patch) | |
tree | 08580222bae2330e8c8294dccf1180a08b38dd22 | |
parent | e799f8a48d1d4930402078a766dd9e999e63471b (diff) |
cmd: smbios: replace missing string by 'Not Specified'
A missing string value is indicated by a string index of 0. In this case
print 'Not Specified' like the Linux dmidecode command does.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
-rw-r--r-- | cmd/smbios.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd/smbios.c b/cmd/smbios.c index 62935ecd1a..95bdff6026 100644 --- a/cmd/smbios.c +++ b/cmd/smbios.c @@ -25,6 +25,10 @@ static const char *smbios_get_string(void *table, int index) { const char *str = (char *)table + ((struct smbios_header *)table)->length; + static const char fallback[] = "Not Specified"; + + if (!index) + return fallback; if (!*str) ++str; @@ -41,7 +45,7 @@ static struct smbios_header *next_table(struct smbios_header *table) if (table->type == SMBIOS_END_OF_TABLE) return NULL; - str = smbios_get_string(table, 0); + str = smbios_get_string(table, -1); return (struct smbios_header *)(++str); } |