reduce compiler warnings during unit tests
This commit is contained in:
parent
80328bccf9
commit
90529e9952
@ -73,7 +73,7 @@ int main() {
|
|||||||
// now try to provoke integer overflow
|
// now try to provoke integer overflow
|
||||||
bs_init_membuf(&bs, (const unsigned char*)"\x34\x12", 2);
|
bs_init_membuf(&bs, (const unsigned char*)"\x34\x12", 2);
|
||||||
assert(bs_get(&bs) == 0x34);
|
assert(bs_get(&bs) == 0x34);
|
||||||
assert(prs_readblob(&bs, buf, (size_t)-1) == -1);
|
assert(prs_readblob(&bs, buf, (size_t)-1) == -1); // ignore compiler warning pls
|
||||||
// a bad implementation would add 0xffffffff to the 1 we already read and wrap to 0
|
// a bad implementation would add 0xffffffff to the 1 we already read and wrap to 0
|
||||||
// our code makes sure not to wrap and also limits the length of the
|
// our code makes sure not to wrap and also limits the length of the
|
||||||
// blob to max_ssize_t (0x7fffffff).
|
// blob to max_ssize_t (0x7fffffff).
|
||||||
|
1
ent.c
1
ent.c
@ -1,4 +1,5 @@
|
|||||||
#define _BSD_SOURCE
|
#define _BSD_SOURCE
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -32,7 +32,7 @@ int main() {
|
|||||||
if (sizeof(i)==4)
|
if (sizeof(i)==4)
|
||||||
assert(scan_xlongn("fefec0debaad",14,&i)==8 && i==0xfefec0de); // test truncation
|
assert(scan_xlongn("fefec0debaad",14,&i)==8 && i==0xfefec0de); // test truncation
|
||||||
else if (sizeof(i)==8)
|
else if (sizeof(i)==8)
|
||||||
assert(scan_xlongn("fefec0debaadc0debl06",40,&i)==16 && i==0xfefec0debaadc0de); // test truncation
|
assert(scan_xlongn("fefec0debaadc0debl06",21,&i)==16 && i==0xfefec0debaadc0de); // test truncation
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user