From: David Miller <davem@davemloft.net>
To: mzhivich@akamai.com
Cc: netdev@vger.kernel.org, dledford@redhat.com, andrew@lunn.ch,
LinoSanfilippo@gmx.de, thomas.lendacky@amd.com,
iyappan@os.amperecomputing.com, quan@os.amperecomputing.com,
jcliburn@gmail.com, siva.kallam@broadcom.com,
sgoutham@cavium.com, shshaikh@marvell.com, bh74.an@samsung.com,
peppe.cavallaro@st.com, mcoquelin.stm32@gmail.com,
hkallweit1@gmail.com
Subject: Re: [PATCH] ethtool: fix SPEED_UNKNOWN definition to avoid signed-unsigned comparison
Date: Tue, 02 Apr 2019 13:26:30 -0700 (PDT) [thread overview]
Message-ID: <20190402.132630.845370282468217165.davem@davemloft.net> (raw)
In-Reply-To: <1554138868-7220-1-git-send-email-mzhivich@akamai.com>
From: Michael Zhivich <mzhivich@akamai.com>
Date: Mon, 1 Apr 2019 13:14:28 -0400
> When building C++ userspace code that includes ethtool.h
> with "-Werror -Wall", g++ complains about signed-unsigned comparison in
> ethtool_validate_speed() due to definition of SPEED_UNKNOWN as -1.
>
> Change definition of SPEED_UNKNOWN to UINT_MAX to match the type of
> ethtool_validate_speed() argument (__u32).
>
> Update storage type for link speed in drivers to use u32 instead of int
> or u16 to bring drivers up-to-date with ethtool.h which includes SPEED_*
> constants larger than range of u16.
>
> Fix usage of SPEED_* constants in
> drivers/net/ethernet/cavium/thunder/thunder_bgx.c and
> drivers/infiniband/ulp/ipoib/ipoib_ethtool.c.
>
> Signed-off-by: Michael Zhivich <mzhivich@akamai.com>
Waaaaay too many changes in one patch. Do one thing at a time.
Also, are you absolutely sure that the things you changed from 'int'
aren't used in other ways where the signedness matters? For example
for error returns?
And maybe the drivers using u16 are legitimate because they are
operating on speeds only within that bitmap range. Type matching is
not an end to itself. So I don't want to see u16 --> u32 conversions
where they aren't even necessary.
Also:
> /* Return lane speed in unit of 1e6 bit/sec */
> -static inline int ib_speed_enum_to_int(int speed)
> +static inline u32 ib_speed_enum_to_int(int speed)
This is sloppy.
You are changing the return type, but not adjusting the name of the
function appropriately. The function name says it converts to
an 'int' but now it actually converts to and returns a u32.
You need to split up, audit, and present these changes more carefully
and properly.
Thank you.
next prev parent reply other threads:[~2019-04-02 20:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-01 17:14 [PATCH] ethtool: fix SPEED_UNKNOWN definition to avoid signed-unsigned comparison Michael Zhivich
2019-04-02 20:26 ` David Miller [this message]
2019-04-03 17:40 ` Zhivich, Michael
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190402.132630.845370282468217165.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=LinoSanfilippo@gmx.de \
--cc=andrew@lunn.ch \
--cc=bh74.an@samsung.com \
--cc=dledford@redhat.com \
--cc=hkallweit1@gmail.com \
--cc=iyappan@os.amperecomputing.com \
--cc=jcliburn@gmail.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=mzhivich@akamai.com \
--cc=netdev@vger.kernel.org \
--cc=peppe.cavallaro@st.com \
--cc=quan@os.amperecomputing.com \
--cc=sgoutham@cavium.com \
--cc=shshaikh@marvell.com \
--cc=siva.kallam@broadcom.com \
--cc=thomas.lendacky@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).