Subject: Re: [PATCH] net/xdp: remove unused macro REG_STATE_NEW

From: Jesper Dangaard Brouer <[email-masked]>
Date: Fri, 6 Nov 2020 17:13:52 +0100

On Fri,  6 Nov 2020 13:43:51 +0800
Alex Shi <[email-masked]> wrote:

> To tame gcc warning on it:
> net/core/xdp.c:20:0: warning: macro "REG_STATE_NEW" is not used
> [-Wunused-macros]

Hmm... REG_STATE_NEW is zero, so it is implicitly set via memset zero.
But it is true that it is technically not directly used or referenced.

It is mentioned in a comment, so please send V2 with this additional change:

$ git diff
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 48aba933a5a8..6e1430971ac2 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -175,7 +175,7 @@ int xdp_rxq_info_reg(struct xdp_rxq_info *xdp_rxq,
                return -ENODEV;
        }
 
-       /* State either UNREGISTERED or NEW */
+       /* State either UNREGISTERED or zero */
        xdp_rxq_info_init(xdp_rxq);
        xdp_rxq->dev = dev;
        xdp_rxq->queue_index = queue_index;

> Signed-off-by: Alex Shi <[email-masked]>
> Cc: "David S. Miller" <[email-masked]> 
> Cc: Jakub Kicinski <[email-masked]> 
> Cc: Alexei Starovoitov <[email-masked]> 
> Cc: Daniel Borkmann <[email-masked]> 
> Cc: Jesper Dangaard Brouer <[email-masked]> 
> Cc: John Fastabend <[email-masked]> 
> Cc: [email-masked] 
> Cc: [email-masked] 
> Cc: [email-masked] 
> ---
>  net/core/xdp.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/net/core/xdp.c b/net/core/xdp.c
> index 48aba933a5a8..3d88aab19c89 100644
> --- a/net/core/xdp.c
> +++ b/net/core/xdp.c
> @@ -19,7 +19,6 @@
>  #include <trace/events/xdp.h>
>  #include <net/xdp_sock_drv.h>
>  
> -#define REG_STATE_NEW		0x0
>  #define REG_STATE_REGISTERED	0x1
>  #define REG_STATE_UNREGISTERED	0x2
>  #define REG_STATE_UNUSED	0x3

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