aboutsummaryrefslogtreecommitdiffstats
path: root/librecrypt_encode.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-05-14 19:46:14 +0200
committerMattias Andrée <m@maandree.se>2026-05-14 19:46:14 +0200
commit5660c556a06916c2f1e004f7f8d5e368b3a88e25 (patch)
tree562217dbfa5f33ee7a73f6bdfc3b67dc9245b4d9 /librecrypt_encode.c
parentFix test bug only found with musl+clang (diff)
downloadlibrecrypt-5660c556a06916c2f1e004f7f8d5e368b3a88e25.tar.gz
librecrypt-5660c556a06916c2f1e004f7f8d5e368b3a88e25.tar.bz2
librecrypt-5660c556a06916c2f1e004f7f8d5e368b3a88e25.tar.xz
Clean up
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'librecrypt_encode.c')
-rw-r--r--librecrypt_encode.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/librecrypt_encode.c b/librecrypt_encode.c
index a15321e..6c81b33 100644
--- a/librecrypt_encode.c
+++ b/librecrypt_encode.c
@@ -39,7 +39,7 @@ librecrypt_encode(char *out_buffer, size_t size, const void *binary, size_t len,
/* NUL-terminate output */
size -= 1u;
- out_buffer[n < size ? n : size] = '\0';
+ out_buffer[MIN(n, size)] = '\0';
/* Deal with situation where number of bytes is not divisible
* byte there, and set excess bits to 0; padding characters are
@@ -168,8 +168,8 @@ check(const char *binary, size_t binary_len, const char *ascii, size_t ascii_len
for (i = 0u; i <= padded_ascii_len; i++) {
memset(buf, 99, sizeof(buf));
EXPECT(librecrypt_encode(buf, i + 1u, binary, binary_len, lut, '=') == padded_ascii_len);
- j = i < ascii_len ? i : ascii_len;
- n = i < padded_ascii_len ? i : padded_ascii_len;
+ j = MIN(i, ascii_len);
+ n = MIN(i, padded_ascii_len);
EXPECT(!memcmp(buf, ascii, j));
for (; j < n; j++)
EXPECT(buf[j] == '=');