Eliminate magic numbers
authorPhilip Prindeville <philipp@redfish-solutions.com>
Sat, 24 Dec 2011 01:45:33 +0000 (18:45 -0700)
committerPatrick Georgi <patrick@georgi-clan.de>
Sat, 7 Jan 2012 10:50:16 +0000 (11:50 +0100)
Use sizeof() on vendor and part# rather than explicit memory length.

Change-Id: I2b7e0e4a8df6448d027cc61867382f161eb990d3
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Reviewed-on: http://review.coreboot.org/504
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
payloads/coreinfo/coreboot_module.c

index d33ea9ee60219ab5c02d0c5b2c54e0684cbab635..77a4bb2d8b65200ae2c13548e6b5e8b4c18064d2 100644 (file)
@@ -142,8 +142,8 @@ static void parse_mainboard(unsigned char *ptr)
 {
        struct cb_mainboard *mb = (struct cb_mainboard *)ptr;
 
-       strncpy(cb_info.vendor, cb_mb_vendor_part(mb), 31);
-       strncpy(cb_info.part, cb_mb_part_string(mb), 31);
+       strncpy(cb_info.vendor, cb_mb_vendor_part(mb), sizeof(cb_info.vendor) - 1);
+       strncpy(cb_info.part, cb_mb_part_string(mb), sizeof(cb_info.part) - 1);
 }
 
 static void parse_strings(unsigned char *ptr)