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

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Sun Apr 2 21:07:29 AEST 2017


Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 hdata/vpd.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

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);
-- 
2.9.3



More information about the Skiboot mailing list