From d93780aa17b3f34bcc9087dd88a585f912455825 Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Wed, 7 Feb 2024 11:20:36 -0800 Subject: [PATCH] Comments and style netbuf: - Agreement between API comments in header file and c files. - Use () for function names. tests/{crc32,crypto_aesctr}: - clarify that we're not using random() for anything cryptographic. (Static analyzers love to complain about this, so let's make it clear to humans that this isn't a problem.) Other: - Remove unnecessary double spaces. --- netbuf/netbuf_read.c | 4 ++-- netbuf/netbuf_ssl_internal.h | 8 ++++---- netbuf/netbuf_write.c | 4 ++-- tests/crc32/main.c | 3 +++ tests/crypto_aesctr/main.c | 3 +++ tests/mpool/visualize-mpool.gnuplot | 2 +- tests/readpass_file/test_readpass_file.sh | 2 +- tests/shared_test_functions.sh | 2 +- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/netbuf/netbuf_read.c b/netbuf/netbuf_read.c index 640fff47..f569df80 100644 --- a/netbuf/netbuf_read.c +++ b/netbuf/netbuf_read.c @@ -55,8 +55,8 @@ netbuf_read_init(int s) /** * netbuf_read_init2(s, ssl): - * Behave like netbuf_read_init if ${ssl} is NULL. If the SSL context ${ssl} - * is not NULL, use it and ignore ${s}. + * Behave like netbuf_read_init() if ${ssl} is NULL. If the SSL context + * ${ssl} is not NULL, use it and ignore ${s}. */ struct netbuf_read * netbuf_read_init2(int s, struct network_ssl_ctx * ssl) diff --git a/netbuf/netbuf_ssl_internal.h b/netbuf/netbuf_ssl_internal.h index 2722a9f6..9dd6ed0c 100644 --- a/netbuf/netbuf_ssl_internal.h +++ b/netbuf/netbuf_ssl_internal.h @@ -20,15 +20,15 @@ extern void (* netbuf_write_ssl_cancel_func)(void *); /** * netbuf_read_init2(s, ssl): - * Behave like netbuf_read_init if ${ssl} is NULL. If the SSL context ${ssl} - * is not NULL, use it and ignore ${s}. + * Behave like netbuf_read_init() if ${ssl} is NULL. If the SSL context + * ${ssl} is not NULL, use it and ignore ${s}. */ struct netbuf_read * netbuf_read_init2(int, struct network_ssl_ctx *); /** * netbuf_write_init2(s, ssl, fail_callback, fail_cookie): - * Behave like netbuf_write_init if ${ssl} is NULL. If the SSL context ${ssl} - * is not NULL, use it and ignore ${s}. + * Behave like netbuf_write_init() if ${ssl} is NULL. If the SSL context + * ${ssl} is not NULL, use it and ignore ${s}. */ struct netbuf_write * netbuf_write_init2(int, struct network_ssl_ctx *, int (*)(void *), void *); diff --git a/netbuf/netbuf_write.c b/netbuf/netbuf_write.c index dd8b97f7..0c36927a 100644 --- a/netbuf/netbuf_write.c +++ b/netbuf/netbuf_write.c @@ -165,8 +165,8 @@ netbuf_write_init(int s, int (* fail_callback)(void *), void * fail_cookie) /** * netbuf_write_init2(s, ssl, fail_callback, fail_cookie): - * Behave like netbuf_write_init() if ${ssl} is NULL. If the SSL context ${ssl} - * is not NULL, use it and ignore ${s}. + * Behave like netbuf_write_init() if ${ssl} is NULL. If the SSL context + * ${ssl} is not NULL, use it and ignore ${s}. */ struct netbuf_write * netbuf_write_init2(int s, struct network_ssl_ctx * ssl, diff --git a/tests/crc32/main.c b/tests/crc32/main.c index c9cb4c95..783dff9b 100644 --- a/tests/crc32/main.c +++ b/tests/crc32/main.c @@ -180,7 +180,10 @@ selftest(void) CRC32C_Init(&ctx); bytes_processed = 0; while (bytes_processed < LARGE_BUFSIZE - MAX_CHUNK) { + /* Get an insecure random number; not used for cryptography. */ new_chunk = ((unsigned long int)random()) % MAX_CHUNK; + + /* Process that amount of data. */ CRC32C_Update(&ctx, (const uint8_t *)&largebuf[bytes_processed], new_chunk); bytes_processed += new_chunk; diff --git a/tests/crypto_aesctr/main.c b/tests/crypto_aesctr/main.c index 6bdfb8f2..82c34bc5 100644 --- a/tests/crypto_aesctr/main.c +++ b/tests/crypto_aesctr/main.c @@ -367,7 +367,10 @@ selftest_unaligned_access(size_t keylen) goto err4; bytes_processed = 0; while (bytes_processed < LARGE_BUFSIZE - MAX_CHUNK) { + /* Get an insecure random number; not used for cryptography. */ new_chunk = ((unsigned long int)random()) % MAX_CHUNK; + + /* Process that amount of data. */ crypto_aesctr_stream(aesctr, &largebuf[bytes_processed], &largebuf_out2[bytes_processed], new_chunk); bytes_processed += new_chunk; diff --git a/tests/mpool/visualize-mpool.gnuplot b/tests/mpool/visualize-mpool.gnuplot index a21e0cb5..64db1f84 100644 --- a/tests/mpool/visualize-mpool.gnuplot +++ b/tests/mpool/visualize-mpool.gnuplot @@ -17,7 +17,7 @@ set key at screen 1, screen 1 set style fill solid 0.5 border -1 set style boxplot outliers pointtype 7 set style data boxplot -set boxwidth 0.45 +set boxwidth 0.45 set pointsize 0.5 # Ticks diff --git a/tests/readpass_file/test_readpass_file.sh b/tests/readpass_file/test_readpass_file.sh index 4422e101..9556620d 100755 --- a/tests/readpass_file/test_readpass_file.sh +++ b/tests/readpass_file/test_readpass_file.sh @@ -34,6 +34,6 @@ printf "%s\n" "--- should fail:" ./test_readpass_file bad-extra-newline.pass && exit 1 -./test_readpass_file bad-extra-material.pass && exit 1 +./test_readpass_file bad-extra-material.pass && exit 1 printf "\nok\n" diff --git a/tests/shared_test_functions.sh b/tests/shared_test_functions.sh index 1c23bb07..a37639a4 100644 --- a/tests/shared_test_functions.sh +++ b/tests/shared_test_functions.sh @@ -148,7 +148,7 @@ wait_while() { fi # Wait using the appropriate binary - if [ -n "${msleep:-}" ]; then + if [ -n "${msleep:-}" ]; then "${msleep}" 100 _wait_while_ms=$((_wait_while_ms + 100)) else