Skip to contentSkip to conversation

qemu-upstream compile failure in intel_iommu.c:vtd_context_device_invalidate

Qemu-devel Olaf Hering 3 participants 3 messages Jan 27, 2016 – Jan 28, 2016

lore
Share & tools
lore
#0 lore raw

Compiling qemu-xen at 2ce1d30 ("xenfb.c: avoid expensive loops when prod <= out_cons") leads to this error with -O1:

xen.git/tools/qemu-xen-dir/hw/i386/intel_iommu.c: In function ‘vtd_context_device_invalidate’:
xen.git/tools/qemu-xen-dir/hw/i386/intel_iommu.c:911:46: error: ‘mask’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

             if (vtd_as && ((devfn_it & mask) == (devfn & mask))) {
                                              ^

It works with -O2. From the code flow its clear that mask is always initialized. Looks like gcc 5.2.1 does no proper diagnostic at -O1. What should be done with such issues, are they fixed in the code?

Olaf

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#1 lore raw
Quoted 8 lines · Olaf Hering

xen.git/tools/qemu-xen-dir/hw/i386/intel_iommu.c: In function ‘vtd_context_device_invalidate’:
xen.git/tools/qemu-xen-dir/hw/i386/intel_iommu.c:911:46: error: ‘mask’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

             if (vtd_as && ((devfn_it & mask) == (devfn & mask))) {
                                              ^

It works with -O2. From the code flow its clear that mask is always initialized. Looks like gcc 5.2.1 does no proper diagnostic at -O1. What should be done with such issues, are they fixed in the code?

It's probably simplest to add a

	default:
	    abort();

to the switch statement above.

Paolo

#2 lore raw
Quoted 12 lines · Paolo Bonzini
Quoted 8 lines · Olaf Hering

xen.git/tools/qemu-xen-dir/hw/i386/intel_iommu.c: In function ‘vtd_context_device_invalidate’:
xen.git/tools/qemu-xen-dir/hw/i386/intel_iommu.c:911:46: error: ‘mask’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

             if (vtd_as && ((devfn_it & mask) == (devfn & mask))) {
                                              ^

It works with -O2. From the code flow its clear that mask is always initialized. Looks like gcc 5.2.1 does no proper diagnostic at -O1. What should be done with such issues, are they fixed in the code?

Quoted 6 lines

It's probably simplest to add a

        default:
            abort();

to the switch statement above.

glib provides a g_assert_not_reached() for this purpose, which is slightly more self-documenting.

thanks
-- PMM