On Wed, 26 Nov 2025 17:55:14 +0100 Matthieu Baerts wrote:
> I confirm this, I can reproduce the warning with Clang 21.
> 
> It is indeed a false positive, because the code does that:
> 
> 
>   if (addr.ss_family == AF_INET)
>           raw_addr = &(((struct sockaddr_in *)&addr)->sin_addr);
>   else if (addr.ss_family == AF_INET6)
>           raw_addr = &(((struct sockaddr_in6 *)&addr)->sin6_addr);
>   else
>           xerror("bad family");
> 
> 
> "xerror()" calls "exit(1)", so "raw_addr" is never used uninitialized.
> 
> I'm not sure why Clang 21 reports that now, and not before, but well,
> the modification you did in the selftests doesn't hurt:

I think annotating xerror with __noreturn is a better fix.
Including kselftest.h will be needed.
-- 
pw-bot: cr

Reply via email to