Re: [kvm-unit-tests PATCH] x86: setjmp: ignore clang's "-Wsomtimes-uninitialized" flag

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

 



On Tue, Sep 10, 2019 at 09:46:36AM -0700, Jim Mattson wrote:
> On Mon, Sep 9, 2019 at 2:10 PM Bill Wendling <morbo@xxxxxxxxxx> wrote:
> >
> > Clang complains that "i" might be uninitialized in the "printf"
> > statement. This is a false negative, because it's set in the "if"
> > statement and then incremented in the loop created by the "longjmp".
> >
> > Signed-off-by: Bill Wendling <morbo@xxxxxxxxxx>
> > ---
> >  x86/setjmp.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/x86/setjmp.c b/x86/setjmp.c
> > index 976a632..cf9adcb 100644
> > --- a/x86/setjmp.c
> > +++ b/x86/setjmp.c
> > @@ -1,6 +1,10 @@
> >  #include "libcflat.h"
> >  #include "setjmp.h"
> >
> > +#ifdef __clang__
> > +#pragma clang diagnostic ignored "-Wsometimes-uninitialized"
> > +#endif
> > +
> >  int main(void)
> >  {
> >      volatile int i;
> 
> Can we just add an initializer here instead?

Doing so would also be a good opportunity to actually report on the
expected vs. actual value of 'i' instead of printing numbers that are
meaningless without diving into the code.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux