Skip to contentSkip to conversation

osdep: work around Coverity parsing errors

PATCH In review Paolo Bonzini 3 participants 4 messages Jun 25, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 osdep: work around Coverity parsing errors

Coverity does not like the new _Float* types that are used by recent glibc, and croaks on every single file that includes stdlib.h. Add dummy typedefs to please it.

---
I've been using this patch for a couple months, and Peter pointed out that other projects are doing similar hacks. So it's probably time to send it upstream.

Note that this is a parse error, so it cannot be fixed in the model file.

 include/qemu/osdep.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/qemu/osdep.h +8 -0
index 9ed62423c0..0084f3fa71 100644
@@ -33,6 +33,14 @@
 #else
 #include "exec/poison.h"
 #endif
+#ifdef __COVERITY__
+typedef float _Float32;
+typedef double _Float32x;
+typedef double _Float64;
+typedef __float80 _Float64x;
+typedef __float128 _Float128;
+#endif
+
 #include "qemu/compiler.h"
 
 /* Older versions of C++ don't get definitions of various macros from
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Paolo Bonzini

Coverity does not like the new _Float* types that are used by recent glibc, and croaks on every single file that includes stdlib.h. Add dummy typedefs to please it.

---
I've been using this patch for a couple months, and Peter pointed out that other projects are doing similar hacks. So it's probably time to send it upstream.

Note that this is a parse error, so it cannot be fixed in the model file.

 include/qemu/osdep.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/qemu/osdep.h +0 -0
index 9ed62423c0..0084f3fa71 100644

include/qemu/osdep.h line 42

Quoted 10 lines
include/qemu/osdep.h +7 -0
@@ -33,6 +33,14 @@
 #else
 #include "exec/poison.h"
 #endif
+#ifdef __COVERITY__
+typedef float _Float32;
+typedef double _Float32x;
+typedef double _Float64;
+typedef __float80 _Float64x;
+typedef __float128 _Float128;
+#endif

I think it would help to repeat the rationale in a comment here, to avoid the necessity to dig it out of the git log.

Otherwise

thanks
-- PMM

#2 lore raw
Quoted 2 lines · Peter Maydell

I think it would help to repeat the rationale in a comment here, to avoid the necessity to dig it out of the git log.

Good idea, I'll copy the commit message in there.

Paolo

Quoted 2 lines

Otherwise

Reviewed-by on v1 1/1
#3 lore raw
In reply to Paolo Bonzini
Quoted 3 lines · Paolo Bonzini

Coverity does not like the new _Float* types that are used by recent glibc, and croaks on every single file that includes stdlib.h. Add dummy typedefs to please it.

This matches http://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc/Floating-Types.html

Quoted 2 lines
Quoted 31 lines

---
I've been using this patch for a couple months, and Peter pointed out that other projects are doing similar hacks. So it's probably time to send it upstream.

Note that this is a parse error, so it cannot be fixed in the model file.

 include/qemu/osdep.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/qemu/osdep.h +8 -0
index 9ed62423c0..0084f3fa71 100644
@@ -33,6 +33,14 @@
 #else
 #include "exec/poison.h"
 #endif
+#ifdef __COVERITY__
+typedef float _Float32;
+typedef double _Float32x;
+typedef double _Float64;
+typedef __float80 _Float64x;
+typedef __float128 _Float128;
+#endif
+
 #include "qemu/compiler.h"
 
 /* Older versions of C++ don't get definitions of various macros from