diff options
author | Nicholas Piggin <npiggin@gmail.com> | 2019-05-08 16:17:49 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.ibm.com> | 2019-05-15 16:22:23 +1000 |
commit | 78040c772b5f63f432271a4576065a2efd4bf175 (patch) | |
tree | 3d999fe5d62a9d91533e1468f51a664eb7658462 /core | |
parent | a8343d5f1a0da3c099230d8199c82b652326f01d (diff) | |
download | skiboot-78040c772b5f63f432271a4576065a2efd4bf175.zip skiboot-78040c772b5f63f432271a4576065a2efd4bf175.tar.gz skiboot-78040c772b5f63f432271a4576065a2efd4bf175.tar.bz2 |
core/pci: pci_slot_add_loc use null-terminated strings
Use null-terminated strings consistently, making the maximum string
length in all cases the same, and avoiding dt_add_property_nstr.
This avoids the following warning that appears after adding more
checking to string ops:
core/pci-slot.c: In function ‘pci_slot_add_loc’:
skiboot/libc/include/string.h:19:17: warning: ‘__builtin_strncpy’
specified bound 80 equals destination size [-Wstringop-truncation]
#define strncpy __builtin_strncpy
core/pci-slot.c:244:3: note: in expansion of macro ‘strncpy’
strncpy(loc_code, label, sizeof(loc_code));
^~~~~~~
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/pci-slot.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/pci-slot.c b/core/pci-slot.c index 497d0a4..d8c8024 100644 --- a/core/pci-slot.c +++ b/core/pci-slot.c @@ -241,10 +241,10 @@ void pci_slot_add_loc(struct pci_slot *slot, snprintf(loc_code, sizeof(loc_code), "%s-%s", phb->base_loc_code, label); } else { - strncpy(loc_code, label, sizeof(loc_code)); + strncpy(loc_code, label, sizeof(loc_code) - 1); + loc_code[LOC_CODE_SIZE - 1] = '\0'; } dt_add_property_string(np, "ibm,slot-label", label); - dt_add_property_nstr(np, "ibm,slot-location-code", loc_code, - sizeof(loc_code)); + dt_add_property_string(np, "ibm,slot-location-code", loc_code); } |