Re: [PATCH V5] net: phy: tja11xx: Add TJA11xx PHY driver

2019-05-22 Thread Marek Vasut
On 5/23/19 12:14 AM, Andrew Lunn wrote:
> On Wed, May 22, 2019 at 11:48:06PM +0200, Marek Vasut wrote:
>> On 5/18/19 4:14 PM, Andrew Lunn wrote:
>>> On Sat, May 18, 2019 at 01:51:23AM +0200, Marek Vasut wrote:
 Add driver for the NXP TJA1100 and TJA1101 PHYs. These PHYs are special
 BroadRReach 100BaseT1 PHYs used in automotive.
>>>
>>> Hi Marek
>>>
 +  }, {
 +  PHY_ID_MATCH_MODEL(PHY_ID_TJA1101),
 +  .name   = "NXP TJA1101",
 +  .features   = PHY_BASIC_T1_FEATURES,
>>>
>>> One thing i would like to do before this patch goes in is define
>>> ETHTOOL_LINK_MODE_100baseT1_Full_BIT in ethtool.h, and use it here.
>>> We could not do it earlier because were ran out of bits. But with
>>> PHYLIB now using bitmaps, rather than u32, we can.
>>
>> So now that "[PATCH net-next 0/2] net: phy: T1 support" is posted, does
>> this patch require any change ? I don't think it does ?
> 
> Hi Marek
> 
> In the end, no it does not need any changes because of my patchset.

OK, thanks.

-- 
Best regards,
Marek Vasut


Re: [PATCH] hwmon: (smsc47m1) fix outside array bounds warnings

2019-05-22 Thread Jean Delvare
Hi Masahiro,

On Tue, 21 May 2019 13:44:56 +0900, Masahiro Yamada wrote:
> Kbuild test robot reports outside array bounds warnings:
> 
>   CC [M]  drivers/hwmon/smsc47m1.o
> drivers/hwmon/smsc47m1.c: In function 'fan_div_store':
> drivers/hwmon/smsc47m1.c:370:49: warning: array subscript [0, 2] is outside 
> array bounds of 'u8[3]' {aka 'unsigned char[3]'} [-Warray-bounds]
>   tmp = 192 - (old_div * (192 - data->fan_preload[nr])
> ~^~~~
> drivers/hwmon/smsc47m1.c:372:19: warning: array subscript [0, 2] is outside 
> array bounds of 'u8[3]' {aka 'unsigned char[3]'} [-Warray-bounds]
>   data->fan_preload[nr] = clamp_val(tmp, 0, 191);
>   ~^~~~
> drivers/hwmon/smsc47m1.c:373:53: warning: array subscript [0, 2] is outside 
> array bounds of 'const u8[3]' {aka 'const unsigned char[3]'} [-Warray-bounds]
>   smsc47m1_write_value(data, SMSC47M1_REG_FAN_PRELOAD[nr],
>  ^~~~

These messages are pretty confusing. Subscript [0, 2] would refer to a
bi-dimensional array, while these are 1-dimension arrays. If [0, 2]
means something else, I still don't get it, because both indexes 0 and
2 are perfectly within bounds of a 3-element array. So what do these
messages mean exactly? Looks like a bogus checker to me.

> The index field in the SENSOR_DEVICE_ATTR_R* defines is 0, 1, or 2.
> However, the compiler never knows the fact that the default in the
> switch statement is unreachable.
> 
> Reported-by: kbuild test robot 
> Signed-off-by: Masahiro Yamada 
> ---
> 
>  drivers/hwmon/smsc47m1.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
> index 5f92eab24c62..e00102e05666 100644
> --- a/drivers/hwmon/smsc47m1.c
> +++ b/drivers/hwmon/smsc47m1.c
> @@ -364,6 +364,10 @@ static ssize_t fan_div_store(struct device *dev,
>   tmp |= data->fan_div[2] << 4;
>   smsc47m1_write_value(data, SMSC47M2_REG_FANDIV3, tmp);
>   break;
> + default:
> + WARN_ON(1);
> + mutex_unlock(>update_lock);
> + return -EINVAL;
>   }

So basically the code is fine, the checker (which checker, BTW?)
incorrectly thinks it isn't, and you propose to add dead code to make
the checker happy?

I disagree with this approach. Ideally the checker must be improved to
understand that the code is correct. If that's not possible, we should
be allowed to annotate the code to skip that specific check on these
specific lines, because it has been inspected by a knowledgeable human
and confirmed to be correct.

And if that it still not "possible", then the least intrusive fix would
be to make one of the valid cases the default. But adding new code
which will never be executed, but must still be compiled and stored,
no, thank you. Another code checker could legitimately complain about
that actually.

IMHO if code checkers return false positives then they are not helping
us and should not be used in the first place.

-- 
Jean Delvare
SUSE L3 Support