All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: David Miller <davem@davemloft.net>
Cc: alvaro.gamez@hazent.com, dan.carpenter@oracle.com,
	radhey.shyam.pandey@xilinx.com, michal.simek@xilinx.com,
	linux@armlinux.org.uk, netdev@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH net] net: axienet: fix a signedness bug in probe
Date: Wed, 25 Sep 2019 12:14:06 +0000	[thread overview]
Message-ID: <20190925121406.GA1864@lunn.ch> (raw)
In-Reply-To: <20190925.133507.2083224833639646147.davem@davemloft.net>

On Wed, Sep 25, 2019 at 01:35:07PM +0200, David Miller wrote:
> From: "Alvaro G. M" <alvaro.gamez@hazent.com>
> Date: Wed, 25 Sep 2019 13:05:43 +0200
> 
> > Hi, Dan
> > 
> > On Wed, Sep 25, 2019 at 01:59:11PM +0300, Dan Carpenter wrote:
> >> The "lp->phy_mode" is an enum but in this context GCC treats it as an
> >> unsigned int so the error handling is never triggered.
> >> 
> >>  		lp->phy_mode = of_get_phy_mode(pdev->dev.of_node);
> >> -		if (lp->phy_mode < 0) {
> >> +		if ((int)lp->phy_mode < 0) {
> > 
> > This (almost) exact code appears in a lot of different drivers too,
> > so maybe it'd be nice to review them all and apply the same cast if needed?
> 
> Or make the thing an int if negative values are never valid 32-bit phy_mode
> values anyways.

Maybe we should change the API

int of_get_phy_mode(struct device_node *np, phy_interface_t *phy_mode);

Separate the error from the value we are getting.

	 Andrew

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Lunn <andrew@lunn.ch>
To: David Miller <davem@davemloft.net>
Cc: alvaro.gamez@hazent.com, dan.carpenter@oracle.com,
	radhey.shyam.pandey@xilinx.com, michal.simek@xilinx.com,
	linux@armlinux.org.uk, netdev@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH net] net: axienet: fix a signedness bug in probe
Date: Wed, 25 Sep 2019 14:14:06 +0200	[thread overview]
Message-ID: <20190925121406.GA1864@lunn.ch> (raw)
In-Reply-To: <20190925.133507.2083224833639646147.davem@davemloft.net>

On Wed, Sep 25, 2019 at 01:35:07PM +0200, David Miller wrote:
> From: "Alvaro G. M" <alvaro.gamez@hazent.com>
> Date: Wed, 25 Sep 2019 13:05:43 +0200
> 
> > Hi, Dan
> > 
> > On Wed, Sep 25, 2019 at 01:59:11PM +0300, Dan Carpenter wrote:
> >> The "lp->phy_mode" is an enum but in this context GCC treats it as an
> >> unsigned int so the error handling is never triggered.
> >> 
> >>  		lp->phy_mode = of_get_phy_mode(pdev->dev.of_node);
> >> -		if (lp->phy_mode < 0) {
> >> +		if ((int)lp->phy_mode < 0) {
> > 
> > This (almost) exact code appears in a lot of different drivers too,
> > so maybe it'd be nice to review them all and apply the same cast if needed?
> 
> Or make the thing an int if negative values are never valid 32-bit phy_mode
> values anyways.

Maybe we should change the API

int of_get_phy_mode(struct device_node *np, phy_interface_t *phy_mode);

Separate the error from the value we are getting.

	 Andrew

  reply	other threads:[~2019-09-25 12:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-25 10:59 [PATCH net] net: axienet: fix a signedness bug in probe Dan Carpenter
2019-09-25 10:59 ` Dan Carpenter
2019-09-25 11:05 ` Alvaro G. M
2019-09-25 11:05   ` Alvaro G. M
2019-09-25 11:35   ` David Miller
2019-09-25 11:35     ` David Miller
2019-09-25 12:14     ` Andrew Lunn [this message]
2019-09-25 12:14       ` Andrew Lunn
2019-09-26 13:18   ` Dan Carpenter
2019-09-26 13:18     ` Dan Carpenter
2019-09-26 13:24     ` Andrew Lunn
2019-09-26 13:24       ` Andrew Lunn
2019-09-25 12:01 ` Radhey Shyam Pandey
2019-09-27  8:17 ` David Miller
2019-09-27  8:17   ` David Miller

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=20190925121406.GA1864@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=alvaro.gamez@hazent.com \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=michal.simek@xilinx.com \
    --cc=netdev@vger.kernel.org \
    --cc=radhey.shyam.pandey@xilinx.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 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.