Subject: Re: linux-next: build warning after merge of the bpf-next tree

From: Martin KaFai Lau <[email-masked]>
Date: Fri, 13 Oct 2023 09:54:35 -0700

On 10/12/23 10:30 PM, Stephen Rothwell wrote:
> Hi all,
> 
> On Fri, 13 Oct 2023 11:40:07 +1100 Stephen Rothwell <[email-masked]> wrote:
>>
>> After merging the bpf-next tree, today's linux-next build (arm
>> multi_v7_defconfig) produced this warning:
>>
>> net/ipv4/af_inet.c: In function 'inet_getname':
>> net/ipv4/af_inet.c:791:13: warning: unused variable 'sin_addr_len' [-Wunused-variable]
>>    791 |         int sin_addr_len = sizeof(*sin);
>>        |             ^~~~~~~~~~~~
>>
>> Introduced by commit
>>
>>    fefba7d1ae19 ("bpf: Propagate modified uaddrlen from cgroup sockaddr programs")
> 
> This became a build failure for the i386 defconfig build, so I applied
> the following patch:
> 
> From: Stephen Rothwell <[email-masked]>
> Date: Fri, 13 Oct 2023 16:25:08 +1100
> Subject: [PATCH] fix up for "bpf: Propagate modified uaddrlen from cgroup sockaddr programs"
> 
> Signed-off-by: Stephen Rothwell <[email-masked]>
> ---
>   net/ipv4/af_inet.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
> index 7e27ad37b939..0fcab6b6cb04 100644
> --- a/net/ipv4/af_inet.c
> +++ b/net/ipv4/af_inet.c
> @@ -788,7 +788,9 @@ int inet_getname(struct socket *sock, struct sockaddr *uaddr,
>   	struct sock *sk		= sock->sk;
>   	struct inet_sock *inet	= inet_sk(sk);
>   	DECLARE_SOCKADDR(struct sockaddr_in *, sin, uaddr);
> +#ifdef CONFIG_CGROUP_BPF
>   	int sin_addr_len = sizeof(*sin);
> +#endif

Thanks for the report and taking care of it.

Daan, something that was missed in ipv4 getname. It should be done similar to 
inet6_getname() in af_inet6.c such that it "return sin_addr_len;" in this 
function to avoid the compiler warning here in ipv4.