Guest User

Untitled

a guest
Oct 19th, 2017
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.39 KB | None | 0 0
  1. From f156445e4295392b3bc4ac5714f5f558f1bc26f3 Mon Sep 17 00:00:00 2001
  2. From: Peter Jones <pjones@redhat.com>
  3. Date: Wed, 18 Oct 2017 12:25:37 -0400
  4. Subject: [PATCH] Work around coverity being a pretty lazy and poor tool.
  5.  
  6. I mean, come on, at least dynamically import the types you've missed
  7. from the version of GCC that's installed on the system and you're
  8. pretending to emulate.
  9.  
  10. Signed-off-by: Peter Jones <pjones@redhat.com>
  11. ---
  12. src/dbxtool.c | 2 ++
  13. src/esltree.c | 2 ++
  14. src/fix_coverity.h | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
  15. src/iter.c | 2 ++
  16. 4 files changed, 86 insertions(+)
  17. create mode 100644 src/fix_coverity.h
  18.  
  19. diff --git a/src/dbxtool.c b/src/dbxtool.c
  20. index 35b5041..5d5efc7 100644
  21. --- a/src/dbxtool.c
  22. +++ b/src/dbxtool.c
  23. @@ -17,6 +17,8 @@
  24. * Author(s): Peter Jones <pjones@redhat.com>
  25. */
  26.  
  27. +#include "fix_coverity.h"
  28. +
  29. #include <dirent.h>
  30. #include <efivar.h>
  31. #include <err.h>
  32. diff --git a/src/esltree.c b/src/esltree.c
  33. index 6a4be0c..93852ba 100644
  34. --- a/src/esltree.c
  35. +++ b/src/esltree.c
  36. @@ -17,6 +17,8 @@
  37. * Author(s): Peter Jones <pjones@redhat.com>
  38. */
  39.  
  40. +#include "fix_coverity.h"
  41. +
  42. #include <err.h>
  43. #include <search.h>
  44. #include <sys/param.h>
  45. diff --git a/src/fix_coverity.h b/src/fix_coverity.h
  46. new file mode 100644
  47. index 0000000..8660a25
  48. --- /dev/null
  49. +++ b/src/fix_coverity.h
  50. @@ -0,0 +1,80 @@
  51. +/*
  52. + * fix_coverity.h
  53. + * Copyright 2017 Peter Jones <pjones@redhat.com>
  54. + *
  55. + * Distributed under terms of the GPLv3 license.
  56. + */
  57. +
  58. +#ifndef FIX_COVERITY_H
  59. +#define FIX_COVERITY_H
  60. +
  61. +#ifndef __COVERITY_GCC_VERSION_AT_LEAST
  62. +#define __COVERITY_GCC_VERSION_AT_LEAST(x, y) 0
  63. +#define FAKE__COVERITY_GCC_VERSION_AT_LEAST__
  64. +#endif /* __COVERITY_GCC_VERSION_AT_LEAST */
  65. +
  66. +/* With gcc 7 on x86_64 (at least), coverity pretends to be GCC but
  67. + * accidentally doesn't create all of the types GCC would.
  68. + *
  69. + * In glibc's headers, bits/floatn.h has:
  70. + *
  71. + * #if (defined __x86_64__ \
  72. + * ? __GNUC_PREREQ (4, 3) \
  73. + * : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4)))
  74. + * # define __HAVE_FLOAT128 1
  75. + * #else
  76. + * # define __HAVE_FLOAT128 0
  77. + * #endif
  78. + *
  79. + * and stdlib.h has:
  80. + *
  81. + * #if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
  82. + * slash* Likewise for the '_Float128' format *slash
  83. + * extern _Float128 strtof128 (const char *__restrict __nptr,
  84. + * char **__restrict __endptr)
  85. + * __THROW __nonnull ((1));
  86. + * #endif
  87. + *
  88. + * Which then causes cov-emit to lose its shit:
  89. + *
  90. + * "/usr/include/stdlib.h", line 133: error #20: identifier "_Float128" is
  91. + * undefined
  92. + * extern _Float128 strtof128 (const char *__restrict __nptr,
  93. + * ^
  94. + * "/usr/include/stdlib.h", line 190: error #20: identifier "_Float128" is
  95. + * undefined
  96. + * _Float128 __f)
  97. + * ^
  98. + * "/usr/include/stdlib.h", line 236: error #20: identifier "_Float128" is
  99. + * undefined
  100. + * extern _Float128 strtof128_l (const char *__restrict __nptr,
  101. + * ^
  102. + *
  103. + * And then you'll notice something like this later on:
  104. + * [WARNING] Emitted 0 C/C++ compilation units (0%) successfully
  105. + *
  106. + * 0 C/C++ compilation units (0%) are ready for analysis
  107. + * For more details, please look at:
  108. + * /home/pjones/devel/github.com/dbxtool/master/cov-int/build-log.txt
  109. + *
  110. + * You would think that if you're writing something that pretends to be
  111. + * gcc, and you've got a "build a configuration by running shit through gcc
  112. + * and looking at the output" stage (which they do), you would run "gcc -da
  113. + * -fdump-tree-all -c -o foo.o foo.c" on an empty file and snarf up all the
  114. + * types defined in the foo.c.001t.tu output. Apparently, they do not.
  115. + *
  116. + * So if we're in that case, just define the type for the thing.
  117. + */
  118. +#ifdef __x86_64__
  119. +#if __COVERITY_GCC_VERSION_AT_LEAST(7, 0)
  120. +typedef float _Float128 __attribute__((__vector_size__(128)));
  121. +#endif
  122. +#endif
  123. +
  124. +#ifdef FAKE__COVERITY_GCC_VERSION_AT_LEAST__
  125. +#undef FAKE__COVERITY_GCC_VERSION_AT_LEAST
  126. +#undef __COVERITY_GCC_VERSION_AT_LEAST
  127. +#endif
  128. +
  129. +#endif /* !FIX_COVERITY_H */
  130. +// vim:fenc=utf-8:tw=75
  131. diff --git a/src/iter.c b/src/iter.c
  132. index 7336365..45ee059 100644
  133. --- a/src/iter.c
  134. +++ b/src/iter.c
  135. @@ -17,6 +17,8 @@
  136. * Author(s): Peter Jones <pjones@redhat.com>
  137. */
  138.  
  139. +#include "fix_coverity.h"
  140. +
  141. #include <err.h>
  142. #include <errno.h>
  143. #include <stdlib.h>
  144. --
  145. 2.14.2
Add Comment
Please, Sign In to add comment