aboutsummaryrefslogtreecommitdiff
path: root/src/cmocka.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2020-10-07 17:01:15 +0200
committerAndreas Schneider <asn@cryptomilk.org>2020-10-12 08:25:26 +0200
commita4fc3dd7705c277e3a57432895e9852ea105dac9 (patch)
tree004fbc228654f65a2923da50faae37636e0f2a72 /src/cmocka.c
parent1003e764721d82c09bb3584b244e50cd657c8de9 (diff)
downloadcmocka-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.c37
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);
}