diff mbox

[net-next] bpf: Fix compilation warning in __bpf_lru_list_rotate_inactive

Message ID 1479236404-3906780-1-git-send-email-kafai@fb.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Martin KaFai Lau Nov. 15, 2016, 7 p.m. UTC
gcc-6.2.1 gives the following warning:
kernel/bpf/bpf_lru_list.c: In function ‘__bpf_lru_list_rotate_inactive.isra.3’:
kernel/bpf/bpf_lru_list.c:201:28: warning: ‘next’ may be used uninitialized in this function [-Wmaybe-uninitialized]

The "next" is currently initialized in the while() loop which must have >=1
iterations.

This patch initializes next to get rid of the compiler warning.

Fixes: 3a08c2fd7634 ("bpf: LRU List")
Reported-by: David Miller <davem@davemloft.net>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
---
 kernel/bpf/bpf_lru_list.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexei Starovoitov Nov. 15, 2016, 9:44 p.m. UTC | #1
On Tue, Nov 15, 2016 at 11:00:04AM -0800, Martin KaFai Lau wrote:
> gcc-6.2.1 gives the following warning:
> kernel/bpf/bpf_lru_list.c: In function ‘__bpf_lru_list_rotate_inactive.isra.3’:
> kernel/bpf/bpf_lru_list.c:201:28: warning: ‘next’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> 
> The "next" is currently initialized in the while() loop which must have >=1
> iterations.
> 
> This patch initializes next to get rid of the compiler warning.
> 
> Fixes: 3a08c2fd7634 ("bpf: LRU List")
> Reported-by: David Miller <davem@davemloft.net>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>

Acked-by: Alexei Starovoitov <ast@kernel.org>
David Miller Nov. 16, 2016, 4:32 p.m. UTC | #2
From: Martin KaFai Lau <kafai@fb.com>

Date: Tue, 15 Nov 2016 11:00:04 -0800

> gcc-6.2.1 gives the following warning:

> kernel/bpf/bpf_lru_list.c: In function ‘__bpf_lru_list_rotate_inactive.isra.3’:

> kernel/bpf/bpf_lru_list.c:201:28: warning: ‘next’ may be used uninitialized in this function [-Wmaybe-uninitialized]

> 

> The "next" is currently initialized in the while() loop which must have >=1

> iterations.

> 

> This patch initializes next to get rid of the compiler warning.

> 

> Fixes: 3a08c2fd7634 ("bpf: LRU List")

> Reported-by: David Miller <davem@davemloft.net>

> Signed-off-by: Martin KaFai Lau <kafai@fb.com>


Applied.
diff mbox

Patch

diff --git a/kernel/bpf/bpf_lru_list.c b/kernel/bpf/bpf_lru_list.c
index bfebff0..89b7ef4 100644
--- a/kernel/bpf/bpf_lru_list.c
+++ b/kernel/bpf/bpf_lru_list.c
@@ -170,7 +170,7 @@  static void __bpf_lru_list_rotate_inactive(struct bpf_lru *lru,
 					   struct bpf_lru_list *l)
 {
 	struct list_head *inactive = &l->lists[BPF_LRU_LIST_T_INACTIVE];
-	struct list_head *cur, *next, *last;
+	struct list_head *cur, *last, *next = inactive;
 	struct bpf_lru_node *node;
 	unsigned int i = 0;