diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2020-10-07 17:01:15 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2020-10-12 08:25:26 +0200 |
commit | a4fc3dd7705c277e3a57432895e9852ea105dac9 (patch) | |
tree | 004fbc228654f65a2923da50faae37636e0f2a72 /src/cmocka.c | |
parent | 1003e764721d82c09bb3584b244e50cd657c8de9 (diff) | |
download | cmocka-a4fc3dd7705c277e3a57432895e9852ea105dac9.tar.gz cmocka-a4fc3dd7705c277e3a57432895e9852ea105dac9.tar.xz cmocka-a4fc3dd7705c277e3a57432895e9852ea105dac9.zip |
cmocka: Use intmax_t for assert_return_code()
Fixes #31
Diffstat (limited to 'src/cmocka.c')
-rw-r--r-- | src/cmocka.c | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/src/cmocka.c b/src/cmocka.c index 479587a..633ba2b 100644 --- a/src/cmocka.c +++ b/src/cmocka.c @@ -1824,41 +1824,18 @@ void _assert_true(const uintmax_t result, } } -void _assert_return_code(const uintmax_t result, - size_t rlen, - const uintmax_t error, +void _assert_return_code(const intmax_t result, + const int32_t error, const char * const expression, const char * const file, const int line) { - uintmax_t valmax; - - - switch (rlen) { - case 1: - valmax = 255; - break; - case 2: - valmax = 32767; - break; - case 4: - valmax = 2147483647; - break; - case 8: - default: - if (rlen > sizeof(valmax)) { - valmax = 2147483647; - } else { - valmax = 9223372036854775807L; - } - break; - } - - if (result > valmax - 1) { + if (result < 0) { if (error > 0) { - cm_print_error("%s < 0, errno(" - UintMaxTypePrintfFormatDecimal "): %s\n", - expression, error, strerror((int)error)); + cm_print_error("%s < 0, errno(%d): %s\n", + expression, + error, + strerror(error)); } else { cm_print_error("%s < 0\n", expression); } |