diff mbox series

[net-next,1/2] bpf: btf: avoid -Wreturn-type warning

Message ID 20180525213331.2115471-1-arnd@arndb.de
State New
Headers show
Series [net-next,1/2] bpf: btf: avoid -Wreturn-type warning | expand

Commit Message

Arnd Bergmann May 25, 2018, 9:33 p.m. UTC
gcc warns about a noreturn function possibly returning in
some configurations:

kernel/bpf/btf.c: In function 'env_type_is_resolve_sink':
kernel/bpf/btf.c:729:1: error: control reaches end of non-void function [-Werror=return-type]

Using BUG() instead of BUG_ON() avoids that warning and otherwise
does the exact same thing.

Fixes: eb3f595dab40 ("bpf: btf: Validate type reference")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 kernel/bpf/btf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.9.0

Comments

Song Liu May 25, 2018, 9:53 p.m. UTC | #1
> On May 25, 2018, at 2:33 PM, Arnd Bergmann <arnd@arndb.de> wrote:

> 

> gcc warns about a noreturn function possibly returning in

> some configurations:

> 

> kernel/bpf/btf.c: In function 'env_type_is_resolve_sink':

> kernel/bpf/btf.c:729:1: error: control reaches end of non-void function [-Werror=return-type]

> 

> Using BUG() instead of BUG_ON() avoids that warning and otherwise

> does the exact same thing.

> 

> Fixes: eb3f595dab40 ("bpf: btf: Validate type reference")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> ---

> kernel/bpf/btf.c | 2 +-

> 1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c

> index 9cbeabb5aca3..2822a0cf4f48 100644

> --- a/kernel/bpf/btf.c

> +++ b/kernel/bpf/btf.c

> @@ -749,7 +749,7 @@ static bool env_type_is_resolve_sink(const struct btf_verifier_env *env,

> 			!btf_type_is_array(next_type) &&

> 			!btf_type_is_struct(next_type);

> 	default:

> -		BUG_ON(1);

> +		BUG();

> 	}

> }

> 

> -- 

> 2.9.0

> 


Acked-by: Song Liu <songliubraving@fb.com>
Daniel Borkmann May 27, 2018, 10:36 p.m. UTC | #2
On 05/25/2018 11:33 PM, Arnd Bergmann wrote:
> gcc warns about a noreturn function possibly returning in

> some configurations:

> 

> kernel/bpf/btf.c: In function 'env_type_is_resolve_sink':

> kernel/bpf/btf.c:729:1: error: control reaches end of non-void function [-Werror=return-type]

> 

> Using BUG() instead of BUG_ON() avoids that warning and otherwise

> does the exact same thing.

> 

> Fixes: eb3f595dab40 ("bpf: btf: Validate type reference")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


Applied to bpf-next, thanks Arnd!
diff mbox series

Patch

diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 9cbeabb5aca3..2822a0cf4f48 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -749,7 +749,7 @@  static bool env_type_is_resolve_sink(const struct btf_verifier_env *env,
 			!btf_type_is_array(next_type) &&
 			!btf_type_is_struct(next_type);
 	default:
-		BUG_ON(1);
+		BUG();
 	}
 }