[PATCH] phy: fix compiler array bounds warning on settings[]

2014-03-04 Thread Bjorn Helgaas
With -Werror=array-bounds, gcc v4.7.x warns that in phy_find_valid(), the settings[] "array subscript is above array bounds", I think because idx is a signed integer and if the caller supplied idx < 0, we pass the guard but still reference out of bounds. Fix this by making idx unsigned here and el

Re: [PATCH] phy: fix compiler array bounds warning on settings[]

2014-03-04 Thread Florian Fainelli
2014-03-04 16:35 GMT-08:00 Bjorn Helgaas : > With -Werror=array-bounds, gcc v4.7.x warns that in phy_find_valid(), the > settings[] "array subscript is above array bounds", I think because idx is > a signed integer and if the caller supplied idx < 0, we pass the guard but > still reference out of b

RE: [PATCH] phy: fix compiler array bounds warning on settings[]

2014-03-05 Thread David Laight
From: Bjorn Helgaas > With -Werror=array-bounds, gcc v4.7.x warns that in phy_find_valid(), the > settings[] "array subscript is above array bounds", I think because idx is > a signed integer and if the caller supplied idx < 0, we pass the guard but > still reference out of bounds. Not rejecting t

Re: [PATCH] phy: fix compiler array bounds warning on settings[]

2014-03-05 Thread Bjorn Helgaas
On Wed, Mar 5, 2014 at 2:10 AM, David Laight wrote: > From: Bjorn Helgaas >> With -Werror=array-bounds, gcc v4.7.x warns that in phy_find_valid(), the >> settings[] "array subscript is above array bounds", I think because idx is >> a signed integer and if the caller supplied idx < 0, we pass the g

RE: [PATCH] phy: fix compiler array bounds warning on settings[]

2014-03-05 Thread David Laight
From: Bjorn Helgaas > On Wed, Mar 5, 2014 at 2:10 AM, David Laight wrote: > > From: Bjorn Helgaas > >> With -Werror=array-bounds, gcc v4.7.x warns that in phy_find_valid(), the > >> settings[] "array subscript is above array bounds", I think because idx is > >> a signed integer and if the caller s

Re: [PATCH] phy: fix compiler array bounds warning on settings[]

2014-03-05 Thread Bjorn Helgaas
[+cc Florian] On Wed, Mar 5, 2014 at 2:10 AM, David Laight wrote: > From: Bjorn Helgaas >> With -Werror=array-bounds, gcc v4.7.x warns that in phy_find_valid(), the >> settings[] "array subscript is above array bounds", I think because idx is >> a signed integer and if the caller supplied idx < 0

RE: [PATCH] phy: fix compiler array bounds warning on settings[]

2014-03-06 Thread David Laight
From: Bjorn Helgaas > I'm stumped. phy_find_valid() is static and only called from one > place. The 'idx' argument is always the result of phy_find_setting(), > which should always return something between 0 and > ARRAY_SIZE(settings), so I don't see any way idx can be < 0. > > I stripped this d

Re: [PATCH] phy: fix compiler array bounds warning on settings[]

2014-03-06 Thread David Miller
From: Bjorn Helgaas Date: Tue, 04 Mar 2014 17:35:44 -0700 > With -Werror=array-bounds, gcc v4.7.x warns that in phy_find_valid(), the > settings[] "array subscript is above array bounds", I think because idx is > a signed integer and if the caller supplied idx < 0, we pass the guard but > still r