[Skiboot] [PATCH] Fix comparing array to null is always true

Stewart Smith stewart at linux.vnet.ibm.com
Tue Sep 8 15:44:59 AEST 2015


This should be a strlen() comparison instead of comparing the
truthiness of an array.

This should be safe as everywhere does populate label, if only with
an empty string.

Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
 core/pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/pci.c b/core/pci.c
index b55ef35..26ed48c 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -1129,8 +1129,8 @@ static void pci_add_slot_properties(struct phb *phb, struct pci_slot_info *info,
 		base_loc_code_len = strlen(phb->base_loc_code);
 		strcpy(loc_code, phb->base_loc_code);
 	}
-	if (info->label) {
-		slot_label_len = strlen(info->label);
+	slot_label_len = strlen(info->label);
+	if (slot_label_len) {
 		if ((base_loc_code_len + slot_label_len + 1) < LOC_CODE_SIZE) {
 			if (base_loc_code_len)
 				strcat(loc_code, "-");
-- 
2.1.4



More information about the Skiboot mailing list