From cfc97057514d903156705477ea4c3401a02c8b43 Mon Sep 17 00:00:00 2001 From: Douglas Stebila Date: Wed, 10 Apr 2019 21:23:33 -0400 Subject: [PATCH] test_format wasn't actually checking output of astyle It was only checking the return code, but astyle was always returning 0. Changed to parse the output and look for the string "Formatted" --- crypto_kem/frodokem1344shake/clean/util.c | 2 +- crypto_kem/frodokem640shake/clean/util.c | 2 +- crypto_kem/frodokem976shake/clean/util.c | 2 +- test/test_format.py | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crypto_kem/frodokem1344shake/clean/util.c b/crypto_kem/frodokem1344shake/clean/util.c index 4a71e4b1..946f5a1c 100644 --- a/crypto_kem/frodokem1344shake/clean/util.c +++ b/crypto_kem/frodokem1344shake/clean/util.c @@ -13,7 +13,7 @@ #define min(x, y) (((x) < (y)) ? (x) : (y)) uint16_t PQCLEAN_FRODOKEM1344SHAKE_CLEAN_LE_TO_UINT16(const uint16_t n) { - return (((uint8_t *) &(n))[0] | (((uint8_t *) &(n))[1] << 8)); + return (((uint8_t *) &n)[0] | (((uint8_t *) &n)[1] << 8)); } uint16_t PQCLEAN_FRODOKEM1344SHAKE_CLEAN_UINT16_TO_LE(const uint16_t n) { diff --git a/crypto_kem/frodokem640shake/clean/util.c b/crypto_kem/frodokem640shake/clean/util.c index ba038d1d..50e5a074 100644 --- a/crypto_kem/frodokem640shake/clean/util.c +++ b/crypto_kem/frodokem640shake/clean/util.c @@ -13,7 +13,7 @@ #define min(x, y) (((x) < (y)) ? (x) : (y)) uint16_t PQCLEAN_FRODOKEM640SHAKE_CLEAN_LE_TO_UINT16(const uint16_t n) { - return (((uint8_t *) &(n))[0] | (((uint8_t *) &(n))[1] << 8)); + return (((uint8_t *) &n)[0] | (((uint8_t *) &n)[1] << 8)); } uint16_t PQCLEAN_FRODOKEM640SHAKE_CLEAN_UINT16_TO_LE(const uint16_t n) { diff --git a/crypto_kem/frodokem976shake/clean/util.c b/crypto_kem/frodokem976shake/clean/util.c index add8866a..28a119b8 100644 --- a/crypto_kem/frodokem976shake/clean/util.c +++ b/crypto_kem/frodokem976shake/clean/util.c @@ -13,7 +13,7 @@ #define min(x, y) (((x) < (y)) ? (x) : (y)) uint16_t PQCLEAN_FRODOKEM976SHAKE_CLEAN_LE_TO_UINT16(const uint16_t n) { - return (((uint8_t *) &(n))[0] | (((uint8_t *) &(n))[1] << 8)); + return (((uint8_t *) &n)[0] | (((uint8_t *) &n)[1] << 8)); } uint16_t PQCLEAN_FRODOKEM976SHAKE_CLEAN_UINT16_TO_LE(const uint16_t n) { diff --git a/test/test_format.py b/test/test_format.py index 427a98a0..a55c78ef 100644 --- a/test/test_format.py +++ b/test/test_format.py @@ -13,11 +13,12 @@ def check_format(implementation: pqclean.Implementation): helpers.ensure_available('astyle') cfiles = implementation.cfiles() hfiles = implementation.hfiles() - helpers.run_subprocess(['astyle', + result = helpers.run_subprocess(['astyle', '--dry-run', '--options=../.astylerc', *cfiles, *hfiles]) + assert(not('Formatted' in result)) if __name__ == "__main__":