Re: [PATCH] bpf: fix check against plain integer v 'NULL'

From: Yonghong Song
Date: Thu Jul 14 2022 - 16:28:40 EST




On 7/14/22 3:03 AM, Ben Dooks wrote:
When checking with sparse, btf_show_type_value() is causing a
warning about checking integer vs NULL when the macro is passed
a pointer, due to the 'value != 0' check. Stop sparse complaining
about any type-casting by adding a cast to the typeof(value).

This fixes the following sparse warnings:

kernel/bpf/btf.c:2579:17: warning: Using plain integer as NULL pointer
kernel/bpf/btf.c:2581:17: warning: Using plain integer as NULL pointer
kernel/bpf/btf.c:3407:17: warning: Using plain integer as NULL pointer
kernel/bpf/btf.c:3758:9: warning: Using plain integer as NULL pointer

Signed-off-by: Ben Dooks <ben.dooks@xxxxxxxxxx>

Acked-by: Yonghong Song <yhs@xxxxxx>