All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH ethtool] ethtool: qsfp: fix special value comparison
@ 2019-03-14 18:33 Michal Kubecek
  2019-03-14 18:43 ` John W. Linville
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Kubecek @ 2019-03-14 18:33 UTC (permalink / raw
  To: John W. Linville; +Cc: netdev, Vidya Sagar Ravipati

One of the warnings gcc issues when building ethtool with -Wall seems to
point to an actual problem:

qsfp.c: In function 'sff8636_show_dom':
qsfp.c:709:57: warning: comparison is always false due to limited range of data type [-Wtype-limits]
  if ((sd.sfp_temp[MCURR] == 0x0) || (sd.sfp_temp[MCURR] == 0xFFFF))
                                                          ^~

Rather than writing the special value as -1 which would be a bit confusing,
cast 0xFFFF to __s16.

Fixes: a5e73bb05ee4 ("ethtool:QSFP Plus/QSFP28 Diagnostics Information Support")
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 qsfp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qsfp.c b/qsfp.c
index d196aa1753de..d0774b0445c8 100644
--- a/qsfp.c
+++ b/qsfp.c
@@ -706,7 +706,8 @@ static void sff8636_show_dom(const __u8 *id, __u32 eeprom_len)
 	 * current fields are supported or not. A valid temperature
 	 * reading is used as existence for TX/RX power.
 	 */
-	if ((sd.sfp_temp[MCURR] == 0x0) || (sd.sfp_temp[MCURR] == 0xFFFF))
+	if ((sd.sfp_temp[MCURR] == 0x0) ||
+	    (sd.sfp_temp[MCURR] == (__s16)0xFFFF))
 		return;
 
 	printf("\t%-41s : %s\n", "Alarm/warning flags implemented",
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH ethtool] ethtool: qsfp: fix special value comparison
  2019-03-14 18:33 [PATCH ethtool] ethtool: qsfp: fix special value comparison Michal Kubecek
@ 2019-03-14 18:43 ` John W. Linville
  0 siblings, 0 replies; 2+ messages in thread
From: John W. Linville @ 2019-03-14 18:43 UTC (permalink / raw
  To: Michal Kubecek; +Cc: netdev, Vidya Sagar Ravipati

On Thu, Mar 14, 2019 at 07:33:16PM +0100, Michal Kubecek wrote:
> One of the warnings gcc issues when building ethtool with -Wall seems to
> point to an actual problem:
> 
> qsfp.c: In function 'sff8636_show_dom':
> qsfp.c:709:57: warning: comparison is always false due to limited range of data type [-Wtype-limits]
>   if ((sd.sfp_temp[MCURR] == 0x0) || (sd.sfp_temp[MCURR] == 0xFFFF))
>                                                           ^~
> 
> Rather than writing the special value as -1 which would be a bit confusing,
> cast 0xFFFF to __s16.
> 
> Fixes: a5e73bb05ee4 ("ethtool:QSFP Plus/QSFP28 Diagnostics Information Support")
> Signed-off-by: Michal Kubecek <mkubecek@suse.cz>

LGTM -- queued for next release.

Thanks,

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-14 18:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-14 18:33 [PATCH ethtool] ethtool: qsfp: fix special value comparison Michal Kubecek
2019-03-14 18:43 ` John W. Linville

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.