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

    From John Paul Adrian Glaubitz@21:1/5 to All on Mon Dec 26 11:00:01 2022
    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 <[email protected]>
    ---
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)