[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/4] pc-bios/s390-ccw: Silence warning from Clang by marking

From: Philippe Mathieu-Daudé
Subject: Re: [PATCH 1/4] pc-bios/s390-ccw: Silence warning from Clang by marking panic() as noreturn
Date: Mon, 3 May 2021 09:40:42 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

On 5/3/21 6:53 AM, Thomas Huth wrote:
> On 02/05/2021 20.57, Philippe Mathieu-Daudé wrote:
>> On 5/2/21 7:48 PM, Thomas Huth wrote:
>>> When compiling the s390-ccw bios with Clang, the compiler emits a
>>> warning:
>>>   pc-bios/s390-ccw/main.c:210:5: warning: variable 'found' is used
>>> uninitialized
>>>    whenever switch default is taken [-Wsometimes-uninitialized]
>>>       default:
>>>       ^~~~~~~
>>>   pc-bios/s390-ccw/main.c:214:16: note: uninitialized use occurs here
>>>       IPL_assert(found, "Boot device not found\n");
>>>                  ^~~~~
>>> It's a false positive, it only happens because Clang is not smart enough
>>> to see that the panic() function in the "default:" case can never
>>> return.
>>> Anyway, let's explicitely mark panic() with "noreturn" to shut up the
>>> warning.
>> Why not simply initialize the variable instead?
> First, it's a false positive. If you only look at the code, someone
> might later wonder whether it's really necessary or not and try to
> remove it again (and since there is no warning with gcc, this patch
> would also have a good chance to get merged, bringing us back to where
> we are right now).
> Second, declaring panic() as noreturn is certainly more sustainable,
> since it might prevent similar situations in other parts of the code in
> the future.

Fine then:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]