diff mbox

[4/4] hdat: Use dt_add_property_nstr instead of duplicating code

Message ID 20170402110729.4785-4-hegdevasant@linux.vnet.ibm.com
State Accepted
Headers show

Commit Message

Vasant Hegde April 2, 2017, 11:07 a.m. UTC
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
---
 hdata/vpd.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/hdata/vpd.c b/hdata/vpd.c
index 5a66140..7f3954a 100644
--- a/hdata/vpd.c
+++ b/hdata/vpd.c
@@ -562,18 +562,12 @@  static void sysvpd_parse_legacy(const void *sysvpd, unsigned int sysvpd_sz)
 	const char *model;
 	const char *system_id;
 	const char *brand;
-	char *str;
 	uint8_t sz;
 
 	model = vpd_find(sysvpd, sysvpd_sz, "VSYS", "TM", &sz);
-	if (model) {
-		str = zalloc(sz + 1);
-		if (str) {
-			memcpy(str, model, sz);
-			dt_add_property_string(dt_root, "model", str);
-			free(str);
-		}
-	} else
+	if (model)
+		dt_add_property_nstr(dt_root, "model", model, sz);
+	else
 		dt_add_property_string(dt_root, "model", "Unknown");
 
 	system_id = vpd_find(sysvpd, sysvpd_sz, "VSYS", "SE", &sz);