Rajaram-Regupathy / libtypec

“libtypec” is aimed to provide a generic interface abstracting all platform complexity for user space to develop tools for efficient USB-C port management. The library can also enable development of diagnostic and debug tools to debug system issues around USB-C/USB PD topology.
34 stars 4 forks source link

missing return from libtypec_exit() #19

Closed ColinIanKing closed 10 months ago

ColinIanKing commented 1 year ago

Function libtypec_exit returns a value only when the if statement is true. There is no explicit return value on the false path of the if statement.

The code is currently effectively this logic:

{ if (condition) return cur_libtypec_os_backend->exit();

/ missing return value in this code path / }

Unfortunately the condition check checks if cur_libtypec_os_backend->exit is null and will call the function if the pointer is null. So this looks wrong to me.

int libtypec_exit(void)
{
    if (!cur_libtypec_os_backend || !cur_libtypec_os_backend->exit )
    /* clear session info */

    return cur_libtypec_os_backend->exit();
}
Rajaram-Regupathy commented 10 months ago

resolved