netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next][V2] bpf: remove redundant assignment to err
@ 2019-06-04  8:21 Colin King
  2019-06-04 11:58 ` Jesper Dangaard Brouer
  2019-06-04 15:04 ` Daniel Borkmann
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2019-06-04  8:21 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, David S . Miller,
	Jakub Kicinski, Jesper Dangaard Brouer, John Fastabend,
	Björn Töpel, Magnus Karlsson, netdev, xdp-newbies, bpf
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The variable err is assigned with the value -EINVAL that is never
read and it is re-assigned a new value later on.  The assignment is
redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>

---

V2: reorder variables as recommended by Jakub Kicinski to keep in
    the networking code style.

---
 kernel/bpf/devmap.c | 2 +-
 kernel/bpf/xskmap.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 5ae7cce5ef16..b58a33ca8a27 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -88,8 +88,8 @@ static u64 dev_map_bitmap_size(const union bpf_attr *attr)
 static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
 {
 	struct bpf_dtab *dtab;
-	int err = -EINVAL;
 	u64 cost;
+	int err;
 
 	if (!capable(CAP_NET_ADMIN))
 		return ERR_PTR(-EPERM);
diff --git a/kernel/bpf/xskmap.c b/kernel/bpf/xskmap.c
index 22066c28ba61..413d75f4fc72 100644
--- a/kernel/bpf/xskmap.c
+++ b/kernel/bpf/xskmap.c
@@ -17,8 +17,8 @@ struct xsk_map {
 
 static struct bpf_map *xsk_map_alloc(union bpf_attr *attr)
 {
-	int cpu, err = -EINVAL;
 	struct xsk_map *m;
+	int cpu, err;
 	u64 cost;
 
 	if (!capable(CAP_NET_ADMIN))
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][next][V2] bpf: remove redundant assignment to err
  2019-06-04  8:21 [PATCH][next][V2] bpf: remove redundant assignment to err Colin King
@ 2019-06-04 11:58 ` Jesper Dangaard Brouer
  2019-06-04 15:04 ` Daniel Borkmann
  1 sibling, 0 replies; 3+ messages in thread
From: Jesper Dangaard Brouer @ 2019-06-04 11:58 UTC (permalink / raw)
  To: Colin King
  Cc: Alexei Starovoitov, Daniel Borkmann, David S . Miller,
	Jakub Kicinski, Jesper Dangaard Brouer, John Fastabend,
	Björn Töpel, Magnus Karlsson, netdev, xdp-newbies, bpf,
	kernel-janitors, linux-kernel, brouer

On Tue,  4 Jun 2019 09:21:46 +0100
Colin King <colin.king@canonical.com> wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> The variable err is assigned with the value -EINVAL that is never
> read and it is re-assigned a new value later on.  The assignment is
> redundant and can be removed.
> 
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> 
> ---
> 
> V2: reorder variables as recommended by Jakub Kicinski to keep in
>     the networking code style.

Thank you for following the networking coding style.

Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next][V2] bpf: remove redundant assignment to err
  2019-06-04  8:21 [PATCH][next][V2] bpf: remove redundant assignment to err Colin King
  2019-06-04 11:58 ` Jesper Dangaard Brouer
@ 2019-06-04 15:04 ` Daniel Borkmann
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2019-06-04 15:04 UTC (permalink / raw)
  To: Colin King, Alexei Starovoitov, David S . Miller, Jakub Kicinski,
	Jesper Dangaard Brouer, John Fastabend, Björn Töpel,
	Magnus Karlsson, netdev, xdp-newbies, bpf
  Cc: kernel-janitors, linux-kernel

On 06/04/2019 10:21 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The variable err is assigned with the value -EINVAL that is never
> read and it is re-assigned a new value later on.  The assignment is
> redundant and can be removed.
> 
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-04 15:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-04  8:21 [PATCH][next][V2] bpf: remove redundant assignment to err Colin King
2019-06-04 11:58 ` Jesper Dangaard Brouer
2019-06-04 15:04 ` Daniel Borkmann

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).