Netdev List
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Colin Ian King <colin.king@canonical.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@st.com>,
	netdev <netdev@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net: stmmac: ensure jumbo_frm error return is correctly checked for -ve value
Date: Sat, 3 Jun 2017 18:53:36 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1706031847280.2014@hadrien> (raw)
In-Reply-To: <40331b09-5829-9041-f815-7f1426960bd8@canonical.com>



On Sat, 3 Jun 2017, Colin Ian King wrote:

> On 03/06/17 16:55, Andy Shevchenko wrote:
> > On Fri, Jun 2, 2017 at 5:58 PM, Colin King <colin.king@canonical.com> wrote:
> >> The current comparison of entry < 0 will never be true since entry is an
> >> unsigned integer. Cast entry to an int to ensure -ve error return values
> >> from the call to jumbo_frm are correctly being caught.
> >
> >>         if (unlikely(is_jumbo) && likely(priv->synopsys_id <
> >>                                          DWMAC_CORE_4_00)) {
> >>                 entry = priv->hw->mode->jumbo_frm(tx_q, skb, csum_insertion);
> >> -               if (unlikely(entry < 0))
> >> +               if (unlikely((int)entry < 0))
> >
> > It feels like a hiding some other issue.
> >
>
> The alternative is:
>
> 		int rc = priv->hw->mode->jumbo_frm(tx_q, skb, csum_insertion);
> 		if (unlikely(rc < 0))
> 			goto dma_map_err;
>
> 		entry = rc;
>
> however, that is effectively the same. The cast I'm using is a well used
> idiom in the kernel, it used in almost a hundred similar cases.
>
> git grep "< 0" | grep "(int)" | wc -l
> 95

Does entry really have to be unsigned?  The jumbo_frm function returns an
int, not an unsigned int, so it seems unpleasant to make it unsigned
prematurely just to put a cast afterwards.  The remaining computation
seems to involve only small numbers.

julia

  reply	other threads:[~2017-06-03 16:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-02 14:58 [PATCH] net: stmmac: ensure jumbo_frm error return is correctly checked for -ve value Colin King
2017-06-03 15:55 ` Andy Shevchenko
2017-06-03 16:35   ` Colin Ian King
2017-06-03 16:53     ` Julia Lawall [this message]
2017-06-03 17:18     ` Andy Shevchenko
2017-06-04 23:58 ` 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=alpine.DEB.2.20.1706031847280.2014@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=alexandre.torgue@st.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=colin.king@canonical.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.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