All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Daniel Machon <daniel.machon@microchip.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, lars.povlsen@microchip.com,
	Steen.Hegelund@microchip.com, UNGLinuxDriver@microchip.com,
	joe@perches.com, horatiu.vultur@microchip.com,
	Julia.Lawall@inria.fr, petrm@nvidia.com, vladimir.oltean@nxp.com,
	maxime.chevallier@bootlin.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 3/6] net: dcb: add new rewrite table
Date: Fri, 13 Jan 2023 10:04:38 +0300	[thread overview]
Message-ID: <Y8EChkENXkUjfUQf@kadam> (raw)
In-Reply-To: <20230112201554.752144-4-daniel.machon@microchip.com>

On Thu, Jan 12, 2023 at 09:15:51PM +0100, Daniel Machon wrote:
> +/* Get protocol value from rewrite entry. */
> +u16 dcb_getrewr(struct net_device *dev, struct dcb_app *app)
   ^^^

> +{
> +	struct dcb_app_type *itr;
> +	u8 proto = 0;

Should "proto" be a u16 to match itr->app.protocol and the return type?

> +
> +	spin_lock_bh(&dcb_lock);
> +	itr = dcb_rewr_lookup(app, dev->ifindex, -1);
> +	if (itr)
> +		proto = itr->app.protocol;
> +	spin_unlock_bh(&dcb_lock);
> +
> +	return proto;
> +}
> +EXPORT_SYMBOL(dcb_getrewr);
> +
> + /* Add rewrite entry to the rewrite list. */
> +int dcb_setrewr(struct net_device *dev, struct dcb_app *new)
> +{
> +	int err = 0;

No need to initialize this.  It only disables static checkers and
triggers a false positive about dead stores.

> +
> +	spin_lock_bh(&dcb_lock);
> +	/* Search for existing match and abort if found. */
> +	if (dcb_rewr_lookup(new, dev->ifindex, new->protocol)) {
> +		err = -EEXIST;
> +		goto out;
> +	}
> +
> +	err = dcb_app_add(&dcb_rewr_list, new, dev->ifindex);
> +out:
> +	spin_unlock_bh(&dcb_lock);
> +
> +	return err;
> +}

regards,
dan carpenter

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <error27@gmail.com>
To: Daniel Machon <daniel.machon@microchip.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, lars.povlsen@microchip.com,
	Steen.Hegelund@microchip.com, UNGLinuxDriver@microchip.com,
	joe@perches.com, horatiu.vultur@microchip.com,
	Julia.Lawall@inria.fr, petrm@nvidia.com, vladimir.oltean@nxp.com,
	maxime.chevallier@bootlin.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 3/6] net: dcb: add new rewrite table
Date: Fri, 13 Jan 2023 10:04:38 +0300	[thread overview]
Message-ID: <Y8EChkENXkUjfUQf@kadam> (raw)
In-Reply-To: <20230112201554.752144-4-daniel.machon@microchip.com>

On Thu, Jan 12, 2023 at 09:15:51PM +0100, Daniel Machon wrote:
> +/* Get protocol value from rewrite entry. */
> +u16 dcb_getrewr(struct net_device *dev, struct dcb_app *app)
   ^^^

> +{
> +	struct dcb_app_type *itr;
> +	u8 proto = 0;

Should "proto" be a u16 to match itr->app.protocol and the return type?

> +
> +	spin_lock_bh(&dcb_lock);
> +	itr = dcb_rewr_lookup(app, dev->ifindex, -1);
> +	if (itr)
> +		proto = itr->app.protocol;
> +	spin_unlock_bh(&dcb_lock);
> +
> +	return proto;
> +}
> +EXPORT_SYMBOL(dcb_getrewr);
> +
> + /* Add rewrite entry to the rewrite list. */
> +int dcb_setrewr(struct net_device *dev, struct dcb_app *new)
> +{
> +	int err = 0;

No need to initialize this.  It only disables static checkers and
triggers a false positive about dead stores.

> +
> +	spin_lock_bh(&dcb_lock);
> +	/* Search for existing match and abort if found. */
> +	if (dcb_rewr_lookup(new, dev->ifindex, new->protocol)) {
> +		err = -EEXIST;
> +		goto out;
> +	}
> +
> +	err = dcb_app_add(&dcb_rewr_list, new, dev->ifindex);
> +out:
> +	spin_unlock_bh(&dcb_lock);
> +
> +	return err;
> +}

regards,
dan carpenter

  reply	other threads:[~2023-01-13  7:06 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12 20:15 [PATCH net-next 0/6] Introduce new DCB rewrite table Daniel Machon
2023-01-12 20:15 ` Daniel Machon
2023-01-12 20:15 ` [PATCH net-next 1/6] net: dcb: modify dcb_app_add to take list_head ptr as parameter Daniel Machon
2023-01-12 20:15   ` Daniel Machon
2023-01-12 20:15 ` [PATCH net-next 2/6] net: dcb: add new common function for set/del of app/rewr entries Daniel Machon
2023-01-12 20:15   ` Daniel Machon
2023-01-13 14:52   ` Petr Machata
2023-01-13 14:52     ` Petr Machata
2023-01-16 13:00     ` Daniel.Machon
2023-01-16 13:00       ` Daniel.Machon
2023-01-12 20:15 ` [PATCH net-next 3/6] net: dcb: add new rewrite table Daniel Machon
2023-01-12 20:15   ` Daniel Machon
2023-01-13  7:04   ` Dan Carpenter [this message]
2023-01-13  7:04     ` Dan Carpenter
2023-01-16 12:52     ` Daniel.Machon
2023-01-16 12:52       ` Daniel.Machon
2023-01-13 15:51   ` Petr Machata
2023-01-13 15:51     ` Petr Machata
2023-01-12 20:15 ` [PATCH net-next 4/6] net: dcb: add helper functions to retrieve PCP and DSCP rewrite maps Daniel Machon
2023-01-12 20:15   ` Daniel Machon
2023-01-12 20:15 ` [PATCH net-next 5/6] net: microchip: sparx5: add support for PCP rewrite Daniel Machon
2023-01-12 20:15   ` Daniel Machon
2023-01-12 20:15 ` [PATCH net-next 6/6] net: microchip: sparx5: add support for DSCP rewrite Daniel Machon
2023-01-12 20:15   ` Daniel Machon
2023-01-13 16:11 ` [PATCH net-next 0/6] Introduce new DCB rewrite table Petr Machata
2023-01-13 16:11   ` Petr Machata

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=Y8EChkENXkUjfUQf@kadam \
    --to=error27@gmail.com \
    --cc=Julia.Lawall@inria.fr \
    --cc=Steen.Hegelund@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=daniel.machon@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=joe@perches.com \
    --cc=kuba@kernel.org \
    --cc=lars.povlsen@microchip.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=vladimir.oltean@nxp.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.