[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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



This fixes the following warning when building with gcc-12 that is
the result of ofdt_path being a fixed-sized array which means that
(char *)ofdt_path never be NULL:

src/drmgr/common_pci.c: In function 'devspec_check_node':
src/drmgr/common_pci.c:465:29: error: the comparison will always evaluate as 'false' for the address of 'ofdt_path' will never be NULL [-Werror=address]
  465 |         if (node->ofdt_path == NULL)
      |                             ^~
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/common_pci.c:31:
src/drmgr/ofdt.h:78:25: note: 'ofdt_path' declared here
   78 |         char            ofdt_path[DR_PATH_MAX];
      |

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

diff --git a/src/drmgr/common_pci.c b/src/drmgr/common_pci.c
index cbd48c9..c6dcfdf 100644
--- a/src/drmgr/common_pci.c
+++ b/src/drmgr/common_pci.c
@@ -462,7 +462,7 @@ devspec_check_node(struct dr_node *node, char *sysfs_path,
 
 	*found = 0;
 
-	if (node->ofdt_path == NULL)
+	if (!strlen(node->ofdt_path))
 		return 0;
 
 	if (! strcmp(full_of_path, node->ofdt_path)) {
-- 
2.30.2


Reply to: