Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1626457 > unrolled thread

Re: [PATCH 1/2] hp-wmi: Fix error value for hp_wmi_tablet_state

Started byAndy Shevchenko <andy.shevchenko@gmail.com>
First post2017-04-19 18:30 +0200
Last post2017-04-19 18:30 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 1/2] hp-wmi: Fix error value for hp_wmi_tablet_state Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-04-19 18:30 +0200
    Re: [PATCH 1/2] hp-wmi: Fix error value for hp_wmi_tablet_state Carlo Caione <carlo@endlessm.com> - 2017-04-19 18:30 +0200
      Re: [PATCH 1/2] hp-wmi: Fix error value for hp_wmi_tablet_state Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-04-19 18:30 +0200

#1626457 — Re: [PATCH 1/2] hp-wmi: Fix error value for hp_wmi_tablet_state

FromAndy Shevchenko <andy.shevchenko@gmail.com>
Date2017-04-19 18:30 +0200
SubjectRe: [PATCH 1/2] hp-wmi: Fix error value for hp_wmi_tablet_state
Message-ID<ty0Eq-5Fr-15@gated-at.bofh.it>
On Sun, Apr 9, 2017 at 4:56 PM, Carlo Caione <carlo@caione.org> wrote:
> From: Carlo Caione <carlo@endlessm.com>
>
> 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

[toc] | [next] | [standalone]


#1626459

FromCarlo Caione <carlo@endlessm.com>
Date2017-04-19 18:30 +0200
Message-ID<ty0Eq-5Fr-13@gated-at.bofh.it>
In reply to#1626457
On Wed, Apr 19, 2017 at 6:21 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Sun, Apr 9, 2017 at 4:56 PM, Carlo Caione <carlo@caione.org> wrote:
>> From: Carlo Caione <carlo@endlessm.com>
>>
>> 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

[toc] | [prev] | [next] | [standalone]


#1626466

FromAndy Shevchenko <andy.shevchenko@gmail.com>
Date2017-04-19 18:30 +0200
Message-ID<ty0Eq-5Fr-33@gated-at.bofh.it>
In reply to#1626459
On Wed, Apr 19, 2017 at 7:24 PM, Carlo Caione <carlo@endlessm.com> wrote:
> On Wed, Apr 19, 2017 at 6:21 PM, Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
>> On Sun, Apr 9, 2017 at 4:56 PM, Carlo Caione <carlo@caione.org> wrote:
>>> From: Carlo Caione <carlo@endlessm.com>
>>>
>>> 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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web