From 62ca7f9242d602929cdeeac2b0f73e7cdc2d5350 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 7 Mar 2017 16:38:02 +0100 Subject: [PATCH] crypto: fix cppcheck warnings --- sys/crypto/chacha.c | 2 ++ sys/crypto/modes/cbc.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/crypto/chacha.c b/sys/crypto/chacha.c index 5697cd64d0c8..b382e74230b4 100644 --- a/sys/crypto/chacha.c +++ b/sys/crypto/chacha.c @@ -53,6 +53,8 @@ static void _doubleround(void *output_, const uint32_t input[16], uint8_t rounds rounds *= 4; for (unsigned i = 0; i < rounds; ++i) { + /* cppcheck-suppress duplicateExpressionTernary + * (reason: Externally imported code beautification) */ uint32_t *a = &output[((i + ((i & 4) ? 0 : 0)) & 3) + (4 * 0)]; uint32_t *b = &output[((i + ((i & 4) ? 1 : 0)) & 3) + (4 * 1)]; uint32_t *c = &output[((i + ((i & 4) ? 2 : 0)) & 3) + (4 * 2)]; diff --git a/sys/crypto/modes/cbc.c b/sys/crypto/modes/cbc.c index ab36a10f0dd1..b5ffdeb84552 100644 --- a/sys/crypto/modes/cbc.c +++ b/sys/crypto/modes/cbc.c @@ -58,7 +58,7 @@ int cipher_decrypt_cbc(cipher_t* cipher, uint8_t iv[16], uint8_t* input, size_t length, uint8_t* output) { size_t offset = 0; - uint8_t* input_block, *output_block, *input_block_last, block_size; + uint8_t* input_block, *input_block_last, block_size; block_size = cipher_get_block_size(cipher); @@ -69,7 +69,7 @@ int cipher_decrypt_cbc(cipher_t* cipher, uint8_t iv[16], input_block_last = iv; do { input_block = input + offset; - output_block = output + offset; + uint8_t *output_block = output + offset; if (cipher_decrypt(cipher, input_block, output_block) != 1) { return CIPHER_ERR_DEC_FAILED;