Skip to content

Commit

Permalink
Minor comment clarifications and trivial rewrites
Browse files Browse the repository at this point in the history
cpusupport-ARM-AES.c: the info about _u32 was in a git commit message,
    but it's worth adding a 1-line comment about it.

cpusupport-X86-SSE42*.c: our STYLE says that we should never use
    (unsigned char).  That's what the definition of _mm_crc32_u8() uses,
    but the code in alg/crc32_sse42.c uses (uint8_t), so there's no
    point violating our STYLE by using (unsigned char) here.

network_ssl_compat.c: fix style of assignment & checking.

imalloc.h: split the "return (NULL)" cases from the actual malloc().
  • Loading branch information
gperciva committed Jan 13, 2025
1 parent 6ab15e3 commit 5863733
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions libcperciva/cpusupport/Build/cpusupport-ARM-AES.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ main(void)
uint32x4_t lanes = {0};
uint8_t arr[16] = {0};

/* Check AES. */
data = vld1q_u8(arr);
output = vaeseq_u8(data, key);
(void)output; /* UNUSED */

/* Check _u32: some compilers only support the _u8 variant. */
lanes = vdupq_laneq_u32(lanes, 0);

/* Success! */
Expand Down
7 changes: 4 additions & 3 deletions libcperciva/util/imalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ imalloc(size_t nrec, size_t reclen)
/* Sanity check. */
assert(reclen != 0);

/* Handle cases where we don't allocate memory. */
if (nrec == 0)
return (NULL);

if (nrec > SIZE_MAX / reclen) {
errno = ENOMEM;
return (NULL);
} else {
return (malloc(nrec * reclen));
}

/* Allocate memory. */
return (malloc(nrec * reclen));
}

/**
Expand Down

0 comments on commit 5863733

Please sign in to comment.