fw: use bool as return type for memeq

This commit is contained in:
Daniel Jobson 2024-09-18 11:11:13 +02:00
parent 80a155a1c2
commit 26045bfcd1
No known key found for this signature in database
GPG Key ID: 3707A9DBF4BB8F1A
2 changed files with 7 additions and 4 deletions

View File

@ -5,8 +5,10 @@
#include "lib.h"
#include "assert.h"
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
void *memset(void *dest, int c, unsigned n)
{
@ -52,15 +54,15 @@ void wordcpy_s(void *dest, size_t destsize, const void *src, size_t n)
}
}
int memeq(void *dest, const void *src, size_t n)
bool memeq(void *dest, const void *src, size_t n)
{
uint8_t *src_byte = (uint8_t *)src;
uint8_t *dest_byte = (uint8_t *)dest;
int res = -1;
bool res = true;
for (size_t i = 0; i < n; i++) {
if (dest_byte[i] != src_byte[i]) {
res = 0;
res = false;
}
}

View File

@ -8,11 +8,12 @@
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
void *memset(void *dest, int c, unsigned n);
void memcpy_s(void *dest, size_t destsize, const void *src, size_t n);
void wordcpy_s(void *dest, size_t destsize, const void *src, size_t n);
int memeq(void *dest, const void *src, size_t n);
bool memeq(void *dest, const void *src, size_t n);
void secure_wipe(void *v, size_t n);
#endif