Hi Adrian, On Mon, Dec 26, 2022 at 4:55 AM John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de> wrote: > > 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 <glaub...@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
Do you need strlen? It looks like you only care that the path is non-empty. You may be able to save on the call to strlen, and instead, check the first char of the string. So maybe something like: > - if (node->ofdt_path == NULL) > + if (! node->ofdt_path[0]) > return 0; My apologies if I am mis-parsing things. Jeff