Skip to content

Commit

Permalink
Comments and style
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gperciva committed Feb 7, 2024
1 parent f70da0e commit d93780a
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions netbuf/netbuf_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions netbuf/netbuf_ssl_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
4 changes: 2 additions & 2 deletions netbuf/netbuf_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions tests/crc32/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions tests/crypto_aesctr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/mpool/visualize-mpool.gnuplot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/readpass_file/test_readpass_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion tests/shared_test_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d93780a

Please sign in to comment.