[PATCH 3/3] drmgr/drslot_chrp_hea: Prefer strlen() to check for valid string length

1 view
Skip to first unread message

John Paul Adrian Glaubitz

<glaubitz@physik.fu-berlin.de>
unread,
Dec 26, 2022, 4:54:43 AM12/26/22
to powerpc-utils-devel@googlegroups.com, debian-powerpc@lists.debian.org, tyreld@linux.ibm.com, John Paul Adrian Glaubitz
This fixes the following warning when building with gcc-12 that is
the result of sysfs_dev_path being a fixed-sized array which means
that (char *)sysfs_dev_path never be NULL:

src/drmgr/drslot_chrp_hea.c: In function 'hotplug_port':
src/drmgr/drslot_chrp_hea.c:124:13: error: the comparison will always evaluate as 'true' for the address of 'sysfs_dev_path' will never be NULL [-Werror=address]
124 | if (! hea->sysfs_dev_path) {
| ^
In file included from src/drmgr/drpci.h:25,
from src/drmgr/rtas_calls.h:25,
from src/drmgr/dr.h:30,
from src/drmgr/drslot_chrp_hea.c:31:
src/drmgr/ofdt.h:84:25: note: 'sysfs_dev_path' declared here
84 | char sysfs_dev_path[DR_PATH_MAX];
| ^~~~~~~~~~~~~~

Signed-off-by: John Paul Adrian Glaubitz <glau...@physik.fu-berlin.de>
---
src/drmgr/drslot_chrp_hea.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/drmgr/drslot_chrp_hea.c b/src/drmgr/drslot_chrp_hea.c
index 98b96e0..714752a 100644
--- a/src/drmgr/drslot_chrp_hea.c
+++ b/src/drmgr/drslot_chrp_hea.c
@@ -121,7 +121,7 @@ hotplug_port(int action, struct dr_node *hea, struct dr_node *port)

say(DEBUG, "Attempting to hotplug %s Port.\n", action_str);

- if (! hea->sysfs_dev_path) {
+ if (!strlen(hea->sysfs_dev_path)) {
say(DEBUG, "Non-existant sysfs dev path for Port, hotplug "
"failed.\n");
return -EINVAL;
--
2.30.2

Reply all
Reply to author
Forward
0 new messages