Skip to content

Commit c3a568c

Browse files
Vasant Hegdestewartsmith
authored andcommitted
hdat: Use dt_add_property_nstr instead of duplicating code
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
1 parent 54c4dd2 commit c3a568c

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

hdata/vpd.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -562,18 +562,12 @@ static void sysvpd_parse_legacy(const void *sysvpd, unsigned int sysvpd_sz)
562562
const char *model;
563563
const char *system_id;
564564
const char *brand;
565-
char *str;
566565
uint8_t sz;
567566

568567
model = vpd_find(sysvpd, sysvpd_sz, "VSYS", "TM", &sz);
569-
if (model) {
570-
str = zalloc(sz + 1);
571-
if (str) {
572-
memcpy(str, model, sz);
573-
dt_add_property_string(dt_root, "model", str);
574-
free(str);
575-
}
576-
} else
568+
if (model)
569+
dt_add_property_nstr(dt_root, "model", model, sz);
570+
else
577571
dt_add_property_string(dt_root, "model", "Unknown");
578572

579573
system_id = vpd_find(sysvpd, sysvpd_sz, "VSYS", "SE", &sz);

0 commit comments

Comments
 (0)