Add test cases and improvements for PR #3240. (#3242)

This commit is contained in:
keinflue 2021-05-03 08:45:37 +00:00 committed by GitHub
parent cb8ee825fd
commit f47fd20e14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 3 deletions

View File

@ -28,7 +28,7 @@
<function name="bswap_16">
<noreturn>false</noreturn>
<use-retval/>
<returnValue type="uint16_t"/>
<returnValue type="uint16_t">((arg1 &amp; 0xff00u) &gt;&gt; 8) | ((arg1 &amp; 0x00ffu) &lt;&lt; 8)</returnValue>
<leak-ignore/>
<const/>
<arg nr="1" direction="in">
@ -42,7 +42,7 @@
<function name="bswap_32">
<noreturn>false</noreturn>
<use-retval/>
<returnValue type="uint32_t"/>
<returnValue type="uint32_t">((arg1 &amp; 0xff000000ul) &gt;&gt; 24) | ((arg1 &amp; 0x00ff0000ul) &gt;&gt; 8) | ((arg1 &amp; 0x0000ff00ul) &lt;&lt; 8) | ((arg1 &amp; 0x000000fful) &lt;&lt; 24)</returnValue>
<leak-ignore/>
<const/>
<arg nr="1" direction="in">
@ -56,7 +56,7 @@
<function name="bswap_64">
<noreturn>false</noreturn>
<use-retval/>
<returnValue type="uint64_t"/>
<returnValue type="uint64_t">((arg1 &amp; 0xff00000000000000ull) &gt;&gt; 56) | ((arg1 &amp; 0x00ff000000000000ull) &gt;&gt; 40) | ((arg1 &amp; 0x0000ff0000000000ull) &gt;&gt; 24) | ((arg1 &amp; 0x000000ff00000000ull) &gt;&gt; 8) | ((arg1 &amp; 0x00000000ff000000ull) &lt;&lt; 8) | ((arg1 &amp; 0x0000000000ff0000ull) &lt;&lt; 24) | ((arg1 &amp; 0x000000000000ff00ull) &lt;&lt; 40) | ((arg1 &amp; 0x00000000000000ffull) &lt;&lt; 56)</returnValue>
<leak-ignore/>
<const/>
<arg nr="1" direction="in">

View File

@ -153,6 +153,26 @@ void valid_code(int argInt1, va_list valist_arg, int * parg)
void * p_mmap = mmap(NULL, 1, PROT_NONE, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
printf("%p", p_mmap);
munmap(p_mmap, 1);
uint16_t i16_1 = 0, i16_2;
// cppcheck-suppress unreadVariable
i16_2 = __builtin_bswap16(i16_1++);
uint32_t i32_1 = 0, i32_2;
// cppcheck-suppress unreadVariable
i32_2 = __builtin_bswap32(i32_1++);
uint64_t i64_1 = 0, i64_2;
// cppcheck-suppress unreadVariable
i64_2 = __builtin_bswap64(i64_1++);
// cppcheck-suppress zerodiv
// cppcheck-suppress unreadVariable
i16_1 /= bswap_16(0x1234) - 0x3412;
// cppcheck-suppress zerodiv
// cppcheck-suppress unreadVariable
i32_1 /= bswap_32(0x12345678) - 0x78563412;
// cppcheck-suppress zerodiv
// cppcheck-suppress unreadVariable
i64_1 /= bswap_64(0x023456789abcde0f) - 0x0fdebc9a78563402;
}
void ignoreleak(void)