All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, dan.carpenter@oracle.com
Subject: Re: [PATCH net-next] net: of_get_phy_mode: Change API to solve int/unit warnings
Date: Thu, 24 Oct 2019 04:49:35 +0200	[thread overview]
Message-ID: <20191024024935.GM5707@lunn.ch> (raw)
In-Reply-To: <20191023.191320.2221170454789484606.davem@davemloft.net>

On Wed, Oct 23, 2019 at 07:13:20PM -0700, David Miller wrote:
> From: Andrew Lunn <andrew@lunn.ch>
> Date: Tue, 22 Oct 2019 03:18:17 +0200
> 
> > Before this change of_get_phy_mode() returned an enum,
> > phy_interface_t. On error, -ENODEV etc, is returned. If the result of
> > the function is stored in a variable of type phy_interface_t, and the
> > compiler has decided to represent this as an unsigned int, comparision
> > with -ENODEV etc, is a signed vs unsigned comparision.
> > 
> > Fix this problem by changing the API. Make the function return an
> > error, or 0 on success, and pass a pointer, of type phy_interface_t,
> > where the phy mode should be stored.
> > 
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> 
> So now we have code that uses the 'interface' value without checking
> the error return value which means it's potentially uninitialized.

Hi David

If it did not check before, it was passing -ENODEV to something. So it
was already broken. But an uninitialized value is worse. I can see
about adding error checking where there are none.

> There are also a bunch of reverse christmas tree violations created
> by this patch as well :-) :-) :-)

I tried to avoid that, but a lot of drivers are not reverse christmas
to start with. In which case i tried to not break it any more. But i
can review my changes.

    Andrew

  reply	other threads:[~2019-10-24  2:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-22  1:18 [PATCH net-next] net: of_get_phy_mode: Change API to solve int/unit warnings Andrew Lunn
2019-10-24  2:13 ` David Miller
2019-10-24  2:49   ` Andrew Lunn [this message]
2019-10-24  4:33     ` David Miller
2019-10-24  8:46     ` Dan Carpenter

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=20191024024935.GM5707@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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.