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? > Signed-off-by: Thomas Huth <th...@redhat.com> > --- > pc-bios/s390-ccw/s390-ccw.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h > index 6cd92669e9..79db69ff54 100644 > --- a/pc-bios/s390-ccw/s390-ccw.h > +++ b/pc-bios/s390-ccw/s390-ccw.h > @@ -89,6 +89,7 @@ bool menu_is_enabled_enum(void); > > #define MAX_BOOT_ENTRIES 31 > > +__attribute__ ((__noreturn__)) > static inline void panic(const char *string) > { > sclp_print(string); >