netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@stusta.de>
To: Jeremy Fitzhardinge <jeremy@xensource.com>,
	Chris Wright <chrisw@sous-sol.org>, Jeff Garzik <jeff@garzik.org>
Cc: xen-devel@lists.xensource.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: drivers/net/xen-netfront.c: bogus code
Date: Mon, 23 Jul 2007 01:26:18 +0200	[thread overview]
Message-ID: <20070722232618.GO26212@stusta.de> (raw)

The Coverity checker spotted the following bogus code
in drivers/net/xen-netfront.c:

<--  snip  -->

...
static void xennet_alloc_rx_buffers(struct net_device *dev)
{
...
        for (nr_flips = i = 0; ; i++) {
                skb = __skb_dequeue(&np->rx_batch);
                if (skb == NULL)
                        break;

                skb->dev = dev;

                id = xennet_rxidx(req_prod + i);

                BUG_ON(np->rx_skbs[id]);
                np->rx_skbs[id] = skb;

                ref = gnttab_claim_grant_reference(&np->gref_rx_head);
                BUG_ON((signed short)ref < 0);
                np->grant_rx_ref[id] = ref;

                pfn = page_to_pfn(skb_shinfo(skb)->frags[0].page);
                vaddr = page_address(skb_shinfo(skb)->frags[0].page);

                req = RING_GET_REQUEST(&np->rx, req_prod + i);
                gnttab_grant_foreign_access_ref(ref,
                                                np->xbdev->otherend_id,
                                                pfn_to_mfn(pfn),
                                                0);

                req->id = id;
                req->gref = ref;
        }

        if (nr_flips != 0) {
...

<--  snip  -->

Note that "nr_flips" is always 0 in the last line.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


             reply	other threads:[~2007-07-22 23:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-22 23:26 Adrian Bunk [this message]
2007-07-23  6:46 ` drivers/net/xen-netfront.c: bogus code Jeremy Fitzhardinge

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=20070722232618.GO26212@stusta.de \
    --to=bunk@stusta.de \
    --cc=chrisw@sous-sol.org \
    --cc=jeff@garzik.org \
    --cc=jeremy@xensource.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=xen-devel@lists.xensource.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).