netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Jeff Kirsher <jeffrey.t.kirsher@intel.com>, davem@davemloft.net
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com
Subject: Re: [net-next v3 1/5] ixgbe: Ensure MAC filter was added before setting MACVLAN
Date: Wed, 19 Jul 2017 03:54:55 -0700	[thread overview]
Message-ID: <1500461695.25934.35.camel@perches.com> (raw)
In-Reply-To: <20170719012305.76795-2-jeffrey.t.kirsher@intel.com>

On Tue, 2017-07-18 at 18:23 -0700, Jeff Kirsher wrote:
> This patch adds a check to ensure that adding the MAC filter was
> successful before setting the MACVLAN.  If it was unsuccessful, propagate
> the error.
[]
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
[]
> @@ -681,6 +681,7 @@ static int ixgbe_set_vf_macvlan(struct ixgbe_adapter *adapter,
>  {
>  	struct list_head *pos;
>  	struct vf_macvlans *entry;
> +	s32 retval = 0;

This function returns int, why use s32 here?
 
>  	if (index <= 1) {
>  		list_for_each(pos, &adapter->vf_mvs.l) {
> @@ -721,14 +722,15 @@ static int ixgbe_set_vf_macvlan(struct ixgbe_adapter *adapter,
>  	if (!entry || !entry->free)
>  		return -ENOSPC;
>  
> -	entry->free = false;
> -	entry->is_macvlan = true;
> -	entry->vf = vf;
> -	memcpy(entry->vf_macvlan, mac_addr, ETH_ALEN);
> -
> -	ixgbe_add_mac_filter(adapter, mac_addr, vf);
> +	retval = ixgbe_add_mac_filter(adapter, mac_addr, vf);
> +	if (retval >= 0) {
> +		entry->free = false;
> +		entry->is_macvlan = true;
> +		entry->vf = vf;
> +		memcpy(entry->vf_macvlan, mac_addr, ETH_ALEN);
> +	}
>  
> -	return 0;
> +	return retval;

This is also backwards logic from typical style
and unnecessarily indents code.

	retval = ixgbe_add_mac_filter(adapter, mac_addr, vf);
	if (retval < 0)
		return retval;

	entry->free = false;
	entry->is_macvlan = true;
	entry->vf = vf;
	memcpy(entry->vf_macvlan, mac_addr, ETH_ALEN);> 

	return 0;
}

This patch also sets the return value to a
possible positive value.

Is that really desired?

The only code that seems to use a possible
positive value also limits its return to 0

static int ixgbe_uc_sync(struct net_device *netdev, const unsigned char *addr)
{
	struct ixgbe_adapter *adapter = netdev_priv(netdev);
	int ret;

	ret = ixgbe_add_mac_filter(adapter, addr, VMDQ_P(0));

	return min_t(int, ret, 0);
}

  reply	other threads:[~2017-07-19 10:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-19  1:23 [net-next v3 0/5][pull request] 10GbE Intel Wired LAN Driver Updates 2017-07-18 Jeff Kirsher
2017-07-19  1:23 ` [net-next v3 1/5] ixgbe: Ensure MAC filter was added before setting MACVLAN Jeff Kirsher
2017-07-19 10:54   ` Joe Perches [this message]
2017-07-19 17:09     ` Nguyen, Anthony L
2017-07-19  1:23 ` [net-next v3 2/5] ixgbe: Enable LASI interrupts for X552 devices Jeff Kirsher
2017-07-19  1:23 ` [net-next v3 3/5] ixgbe: Update NW_MNG_IF_SEL support for X553 Jeff Kirsher
2017-07-19  1:23 ` [net-next v3 4/5] ixgbe: Do not support flow control autonegotiation " Jeff Kirsher
2017-07-19  1:23 ` [net-next v3 5/5] ixgbe: Disable flow control for XFI Jeff Kirsher

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=1500461695.25934.35.camel@perches.com \
    --to=joe@perches.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=jogreene@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.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).