Skip to content

Commit

Permalink
Merge pull request #603 from Tarsnap/nitpicks
Browse files Browse the repository at this point in the history
Nitpicks
  • Loading branch information
cperciva authored Dec 20, 2023
2 parents dfcc22d + c3b3b7e commit f4560d8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
16 changes: 8 additions & 8 deletions lib/crypto/crypto_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@
#endif /* LIBRESSL_VERSION_NUMBER */

/**
* crypto_compat_RSA_valid_size(rsa):
* Return nonzero if ${rsa} has a valid size, and zero for an invalid size.
* crypto_compat_RSA_valid_size(key):
* Return nonzero if ${key} has a valid size, and zero for an invalid size.
*/
int
crypto_compat_RSA_valid_size(const RSA * const rsa)
crypto_compat_RSA_valid_size(const RSA * const key)
{

/* Sanity checks. */
assert(rsa != NULL);
assert(key != NULL);

#if OPENSSL_VERSION_NUMBER < 0x10100000L
assert(rsa->n != NULL);
return ((RSA_size(rsa) == 256) && (BN_num_bits(rsa->n) == 2048));
assert(key->n != NULL);
return ((RSA_size(key) == 256) && (BN_num_bits(key->n) == 2048));
#else
return ((RSA_size(rsa) == 256) && (RSA_bits(rsa) == 2048));
return ((RSA_size(key) == 256) && (RSA_bits(key) == 2048));
#endif
}

Expand Down Expand Up @@ -255,7 +255,7 @@ crypto_compat_free(void)
OPENSSL_cleanup();
CRYPTO_cleanup_all_ex_data();
#else
/* Easerlier versions of OpenSSL and LibreSSL. */
/* Earlier versions of OpenSSL and LibreSSL. */

/* Free OpenSSL error queue. */
#if OPENSSL_VERSION_NUMBER < 0x10000000L
Expand Down
4 changes: 2 additions & 2 deletions lib/crypto/crypto_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <openssl/ossl_typ.h>

/**
* crypto_compat_RSA_valid_size(rsa):
* Return nonzero if ${rsa} has a valid size, and zero for an invalid size.
* crypto_compat_RSA_valid_size(key):
* Return nonzero if ${key} has a valid size, and zero for an invalid size.
*/
int crypto_compat_RSA_valid_size(const RSA * const key);

Expand Down
2 changes: 1 addition & 1 deletion lib/network/tsnetwork_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct network_buf_cookie {
int flags;
};

static int callback_buf(void * cookie, int timedout);
static int callback_buf(void * cookie, int status);
static int network_buf(int fd, uint8_t * buf, size_t buflen,
struct timeval * to0, struct timeval * to1,
network_callback * callback, void * cookie,
Expand Down
3 changes: 2 additions & 1 deletion libcperciva/crypto/crypto_entropy.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ static void generate(uint8_t *, size_t);

#ifdef CPUSUPPORT_X86_RDRAND
static void
update_from_rdrand(void) {
update_from_rdrand(void)
{
unsigned int buf[8];

/* This is only *extra* entropy, so it's ok if it fails. */
Expand Down
8 changes: 4 additions & 4 deletions libcperciva/events/events_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* for it to be larger than size_t unless there's an undocumented limit on
* the number of descriptors which can be polled (since poll takes an array,
* the size of which must fit into a size_t); and nfds_t should be able to
* the value INT_MAX + 1 (in case every possible file descriptor is in use
* and being polled for).
* store the value INT_MAX + 1 (in case every possible file descriptor is in
* use and being polled for).
*/
CTASSERT((nfds_t)(-1) <= (size_t)(-1));
CTASSERT((nfds_t)((size_t)(INT_MAX) + 1) == (size_t)(INT_MAX) + 1);
Expand Down Expand Up @@ -65,7 +65,7 @@ static size_t fdscanpos;
* S[i].reader != NULL <==> (fds[S[i].pollpos].events & POLLIN) != 0
* S[i].writer != NULL <==> (fds[S[i].pollpos].events & POLLOUT) != 0
* 5. We don't have events ready which we don't want:
* (fds[j].revents & (POLLIN | POLLOUT) & (~fds[j].events])) == 0
* (fds[j].revents & (POLLIN | POLLOUT) & (~fds[j].events)) == 0
* 6. Returned events are in position to be scanned later:
* fds[j].revents != 0 ==> f < fdscanpos.
*/
Expand Down Expand Up @@ -451,7 +451,7 @@ events_network_get(void)
break;
}

/* Are we ready for reading? */
/* Are we ready for writing? */
if (fds[fdscanpos].revents & POLLOUT) {
r = socketlist_get(S,
(size_t)fds[fdscanpos].fd)->writer;
Expand Down
2 changes: 2 additions & 0 deletions libcperciva/util/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ sock_resolve_unix(const char * addr)
if ((sa_un = calloc(1, sizeof(struct sockaddr_un))) == NULL)
goto err0;
sa_un->sun_family = AF_UNIX;

/* Safely copy addr into the structure. */
if (strlen(addr) >= sizeof(sa_un->sun_path)) {
warn0("socket path too long: %s", addr);
goto err1;
Expand Down

0 comments on commit f4560d8

Please sign in to comment.