From f73c86d096ba8744347f0ec1d67de89fd6308b97 Mon Sep 17 00:00:00 2001 From: Flavio Santes Date: Mon, 14 Nov 2016 02:29:53 -0600 Subject: [PATCH] tinycrypt: Fix style issues This commit solves some style issues found at the tests/include/test_utils.h file: - Lines over 80 characters - Unused arguments - Missing {} in if-else Change-Id: Ifaee81ec7c57a250b2c368b2efda38dc69d02c81 Signed-off-by: Flavio Santes --- tests/include/test_utils.h | 51 ++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/tests/include/test_utils.h b/tests/include/test_utils.h index 35879d155f5..bc2716adf6b 100644 --- a/tests/include/test_utils.h +++ b/tests/include/test_utils.h @@ -37,38 +37,47 @@ static inline void show_str(const char *label, const uint8_t *s, size_t len) { - uint32_t i; + uint32_t i; - TC_PRINT("%s = ", label); - for (i = 0; i < (uint32_t) len; ++i) { - TC_PRINT("%02x", s[i]); - } - TC_PRINT("\n"); + TC_PRINT("%s = ", label); + for (i = 0; i < (uint32_t)len; ++i) { + TC_PRINT("%02x", s[i]); + } + TC_PRINT("\n"); } -static inline void fatal(uint32_t testnum, const void *expected, size_t expectedlen, - const void *computed, size_t computedlen) +static inline +void fatal(uint32_t testnum, const void *expected, size_t expectedlen, + const void *computed, size_t computedlen) { - - TC_ERROR("\tTest #%d Failed!\n", testnum); - show_str("\t\tExpected", expected, expectedlen); - show_str("\t\tComputed ", computed, computedlen); - TC_PRINT("\n"); + TC_ERROR("\tTest #%d Failed!\n", testnum); + show_str("\t\tExpected", expected, expectedlen); + show_str("\t\tComputed ", computed, computedlen); + TC_PRINT("\n"); } -static inline uint32_t check_result(uint32_t testnum, const void *expected, size_t expectedlen, - const void *computed, size_t computedlen, uint32_t verbose) +static inline +uint32_t check_result(uint32_t testnum, const void *expected, + size_t expectedlen, const void *computed, + size_t computedlen, uint32_t verbose) { uint32_t result = TC_PASS; + ARG_UNUSED(verbose); + if (expectedlen != computedlen) { - TC_ERROR("The length of the computed buffer (%zu)", computedlen); - TC_ERROR("does not match the expected length (%zu).", expectedlen); + TC_ERROR("The length of the computed buffer (%zu)", + computedlen); + TC_ERROR("does not match the expected length (%zu).", + expectedlen); result = TC_FAIL; - } else if (memcmp(computed, expected, computedlen) != 0) { - fatal(testnum, expected, expectedlen, computed, computedlen); - result = TC_FAIL; - } + } else { + if (memcmp(computed, expected, computedlen) != 0) { + fatal(testnum, expected, expectedlen, + computed, computedlen); + result = TC_FAIL; + } + } return result; }