diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2018-06-07 10:06:51 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-06-07 10:06:51 +0200 |
commit | 7008c6b55f8a762140e1d59d5895f293d49e63e7 (patch) | |
tree | 833995db889c66e1e91989d4ddebdd3e3b364c7f /src | |
parent | 0c92eed845ac0e9f7ae0e9bc6653ffc9b280f9cf (diff) | |
download | cmocka-7008c6b55f8a762140e1d59d5895f293d49e63e7.tar.gz cmocka-7008c6b55f8a762140e1d59d5895f293d49e63e7.tar.xz cmocka-7008c6b55f8a762140e1d59d5895f293d49e63e7.zip |
cmocka: Limit the display of memory if it is not equal
The buffer we have available is 1K, make sure we do not print more than
that.
Diffstat (limited to 'src')
-rw-r--r-- | src/cmocka.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/cmocka.c b/src/cmocka.c index aa5f0e1..920ab51 100644 --- a/src/cmocka.c +++ b/src/cmocka.c @@ -1193,12 +1193,17 @@ static int memory_equal_display_error(const char* const a, const char* const b, const char l = a[i]; const char r = b[i]; if (l != r) { - cm_print_error("difference at offset %" PRIdS " 0x%02x 0x%02x\n", - i, l, r); + if (differences < 16) { + cm_print_error("difference at offset %" PRIdS " 0x%02x 0x%02x\n", + i, l, r); + } differences ++; } } - if (differences) { + if (differences > 0) { + if (differences >= 16) { + cm_print_error("...\n"); + } cm_print_error("%d bytes of %p and %p differ\n", differences, (void *)a, (void *)b); return 0; |