1 #define LargestIntegralType unsigned long long
2 
3 
_assert_true(const LargestIntegralType result,const char * const expression,const char * const file,const int line)4 void _assert_true(const LargestIntegralType result,
5                   const char* const expression,
6                   const char * const file, const int line)
7 {
8     if (!result) {
9         __coverity_panic__();
10     }
11 }
12 
_assert_int_equal(const LargestIntegralType a,const LargestIntegralType b,const char * const file,const int line)13 void _assert_int_equal(
14     const LargestIntegralType a, const LargestIntegralType b,
15     const char * const file, const int line)
16 {
17     if (a != b) {
18         __coverity_panic__();
19     }
20 }
21 
_assert_int_not_equal(const LargestIntegralType a,const LargestIntegralType b,const char * const file,const int line)22 void _assert_int_not_equal(
23     const LargestIntegralType a, const LargestIntegralType b,
24     const char * const file, const int line)
25 {
26     if (a == b) {
27         __coverity_panic__();
28     }
29 }
30 
_assert_return_code(const LargestIntegralType result,size_t rlen,const LargestIntegralType error,const char * const expression,const char * const file,const int line)31 void _assert_return_code(const LargestIntegralType result,
32                          size_t rlen,
33                          const LargestIntegralType error,
34                          const char * const expression,
35                          const char * const file,
36                          const int line)
37 {
38     if (result != 0) {
39         __coverity_panic__();
40     }
41 }
42 
_assert_string_equal(const char * const a,const char * const b,const char * const file,const int line)43 void _assert_string_equal(const char * const a, const char * const b,
44                           const char * const file, const int line)
45 {
46     char ch;
47     int cmp;
48 
49     __coverity_weak_guard_sink__(a, b);
50     __coverity_weak_guard_sink__(b, a);
51 
52     ch = *((char *)a);
53     ch = *((char *)b);
54 
55     if (cmp != 0) {
56         __coverity_panic__();
57     }
58 }
59 
_assert_string_not_equal(const char * const a,const char * const b,const char * file,const int line)60 void _assert_string_not_equal(const char * const a, const char * const b,
61                               const char *file, const int line)
62 {
63     char ch;
64     int cmp;
65 
66     __coverity_weak_guard_sink__(a, b);
67     __coverity_weak_guard_sink__(b, a);
68 
69     ch = *((char *)a);
70     ch = *((char *)b);
71 
72     if (cmp == 0) {
73         __coverity_panic__();
74     }
75 }
76 
_assert_memory_equal(const void * const a,const void * const b,const size_t size,const char * const file,const int line)77 void _assert_memory_equal(const void * const a, const void * const b,
78                           const size_t size, const char* const file,
79                           const int line)
80 {
81     unsigned char ch;
82     int cmp;
83 
84     __coverity_weak_guard_sink__(a, b);
85     __coverity_weak_guard_sink__(b, a);
86 
87     ch = *((unsigned char *)a);
88     ch = *((unsigned char *)b);
89 
90     if (cmp != 0) {
91         __coverity_panic__();
92     }
93 }
94 
_assert_memory_not_equal(const void * const a,const void * const b,const size_t size,const char * const file,const int line)95 void _assert_memory_not_equal(const void * const a, const void * const b,
96                               const size_t size, const char* const file,
97                               const int line)
98 {
99     unsigned char ch;
100     int cmp;
101 
102     __coverity_weak_guard_sink__(a, b);
103     __coverity_weak_guard_sink__(b, a);
104 
105     ch = *((unsigned char *)a);
106     ch = *((unsigned char *)b);
107 
108     if (cmp == 0) {
109         __coverity_panic__();
110     }
111 }
112 
_assert_in_range(const LargestIntegralType value,const LargestIntegralType minimum,const LargestIntegralType maximum,const char * const file,const int line)113 void _assert_in_range(
114     const LargestIntegralType value, const LargestIntegralType minimum,
115     const LargestIntegralType maximum, const char* const file, const int line)
116 {
117     if (value < minimum || value > maximum) {
118         __coverity_panic__();
119     }
120 }
121 
_assert_not_in_range(const LargestIntegralType value,const LargestIntegralType minimum,const LargestIntegralType maximum,const char * const file,const int line)122 void _assert_not_in_range(
123     const LargestIntegralType value, const LargestIntegralType minimum,
124     const LargestIntegralType maximum, const char* const file, const int line)
125 {
126     if (value > minimum && value < maximum) {
127         __coverity_panic__();
128     }
129 }
130 
_assert_in_set(const LargestIntegralType value,const LargestIntegralType values[],const size_t number_of_values,const char * const file,const int line)131 void _assert_in_set(
132     const LargestIntegralType value, const LargestIntegralType values[],
133     const size_t number_of_values, const char* const file, const int line)
134 {
135     size_t i;
136 
137     for (i = 0; i < number_of_values; i++) {
138         if (value == values[i]) {
139             return;
140         }
141     }
142     __coverity_panic__();
143 }
144 
_assert_not_in_set(const LargestIntegralType value,const LargestIntegralType values[],const size_t number_of_values,const char * const file,const int line)145 void _assert_not_in_set(
146     const LargestIntegralType value, const LargestIntegralType values[],
147     const size_t number_of_values, const char* const file, const int line)
148 {
149     size_t i;
150 
151     for (i = 0; i < number_of_values; i++) {
152         if (value == values[i]) {
153             __coverity_panic__();
154         }
155     }
156 }
157