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

assigned error return to variable ret is not being used in function libtypec_dbgfs_get_alternate_modes #23

Closed ColinIanKing closed 10 months ago

ColinIanKing commented 1 year ago

In function libtypec_dbgfs_get_alternate_modes() the failed call to get_ucsi_response are assigning -1 to ret to indicate an error has occurred but this variable is not being read so the failure is effectively being silently ignored. Is that expected to ignore these failure cases?

                        if(ret)
                        {
                                ret = get_ucsi_response(buf);
                                if(ret<31)
                                        ret = -1;

                                alt_mode_data[i].svid    = buf[28] << 12 | buf[29] <<8 | buf[30] << 4 | buf[31];
                                alt_mode_data[i].vdo     = buf[24] << 12 | buf[25] <<8 | buf[26] << 4 | buf[27];

                                if(alt_mode_data[i].svid == 0)
                                        break;
                        }
ColinIanKing commented 1 year ago

Same for libtypec_dbgfs_get_pdos_ops() too, ret being assigned but not checked.

Rajaram-Regupathy commented 10 months ago

resolved