Re: [PATCH 1/2] hp-wmi: Fix error value for hp_wmi_tablet_state
On Wed, Apr 19, 2017 at 7:24 PM, Carlo Caione wrote: > On Wed, Apr 19, 2017 at 6:21 PM, Andy Shevchenko > wrote: >> On Sun, Apr 9, 2017 at 4:56 PM, Carlo Caione wrote: >>> From: Carlo Caione >>> >>> hp_wmi_tablet_state() fails to return the correct error code when >>> hp_wmi_perform_query() returns the HP WMI query specific error code >>> that is a positive value. >> >>> int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state, >>>sizeof(state), sizeof(state)); >>> if (ret) >>> - return ret; >>> + return -EINVAL; >> >> Shouldn't be something like >> >> if (ret) >> return ret < 0 ? ret : -EINVAL; >> >> Looking into the code it looks like it may return all possible values: >> 0, negative, positive. > > When the HP WMI query returns a positive value something went wrong. > hp_wmi_perform_query() returns 0 on success. Yes, that's what I didn't object anyhow. My point is not to shadow negative errors if any. -- With Best Regards, Andy Shevchenko
Re: [PATCH 1/2] hp-wmi: Fix error value for hp_wmi_tablet_state
On Wed, Apr 19, 2017 at 6:21 PM, Andy Shevchenko wrote: > On Sun, Apr 9, 2017 at 4:56 PM, Carlo Caione wrote: >> From: Carlo Caione >> >> hp_wmi_tablet_state() fails to return the correct error code when >> hp_wmi_perform_query() returns the HP WMI query specific error code >> that is a positive value. > >> int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state, >>sizeof(state), sizeof(state)); >> if (ret) >> - return ret; >> + return -EINVAL; > > Shouldn't be something like > > if (ret) > return ret < 0 ? ret : -EINVAL; > > Looking into the code it looks like it may return all possible values: > 0, negative, positive. When the HP WMI query returns a positive value something went wrong. hp_wmi_perform_query() returns 0 on success. -- Carlo Caione | +39.340.80.30.096 | Endless
Re: [PATCH 1/2] hp-wmi: Fix error value for hp_wmi_tablet_state
On Sun, Apr 9, 2017 at 4:56 PM, Carlo Caione wrote: > From: Carlo Caione > > hp_wmi_tablet_state() fails to return the correct error code when > hp_wmi_perform_query() returns the HP WMI query specific error code > that is a positive value. > int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state, >sizeof(state), sizeof(state)); > if (ret) > - return ret; > + return -EINVAL; Shouldn't be something like if (ret) return ret < 0 ? ret : -EINVAL; Looking into the code it looks like it may return all possible values: 0, negative, positive. -- With Best Regards, Andy Shevchenko