From 38d1a349271731f100f0e4b3daa10cf601892591 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 18 Apr 2009 16:59:47 -0400 Subject: [PATCH] Replace memeq/streq functions with memcmp/strcmp. The standard functions are better known and not harder to implement. --- src/cdrom.c | 2 +- src/coreboot.c | 4 ++-- src/util.c | 12 ++++++------ src/util.h | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cdrom.c b/src/cdrom.c index 71a8b84..8f9e7d0 100644 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -417,7 +417,7 @@ cdrom_boot(int cdid) // Validity checks if (buffer[0]) return 4; - if (!streq((char*)&buffer[1], "CD001\001EL TORITO SPECIFICATION")) + if (strcmp((char*)&buffer[1], "CD001\001EL TORITO SPECIFICATION") != 0) return 5; // ok, now we calculate the Boot catalog address diff --git a/src/coreboot.c b/src/coreboot.c index feccad3..cdb13ba 100644 --- a/src/coreboot.c +++ b/src/coreboot.c @@ -362,7 +362,7 @@ cbfs_findfile(const char *fname) struct cbfs_file *file; for (file = cbfs_getfirst(); file; file = cbfs_getnext(file)) { dprintf(3, "Found CBFS file %s\n", file->filename); - if (streq(fname, file->filename)) + if (strcmp(fname, file->filename) == 0) return file; } return NULL; @@ -379,7 +379,7 @@ cbfs_findNprefix(const char *prefix, int n) struct cbfs_file *file; for (file = cbfs_getfirst(); file; file = cbfs_getnext(file)) { dprintf(3, "Found CBFS file %s\n", file->filename); - if (memeq(prefix, file->filename, len)) { + if (memcmp(prefix, file->filename, len) == 0) { if (n <= 0) return file->filename; n--; diff --git a/src/util.c b/src/util.c index ceceed8..88f134c 100644 --- a/src/util.c +++ b/src/util.c @@ -132,27 +132,27 @@ strlen(const char *s) // Compare two areas of memory. int -memeq(const void *s1, const void *s2, size_t n) +memcmp(const void *s1, const void *s2, size_t n) { while (n) { if (*(u8*)s1 != *(u8*)s2) - return 0; + return *(u8*)s1 < *(u8*)s2 ? -1 : 1; s1++; s2++; n--; } - return 1; + return 0; } // Compare two strings. int -streq(const char *s1, const char *s2) +strcmp(const char *s1, const char *s2) { for (;;) { if (*s1 != *s2) - return 0; + return *s1 < *s2 ? -1 : 1; if (! *s1) - return 1; + return 0; s1++; s2++; } diff --git a/src/util.h b/src/util.h index cb2d46f..f260e27 100644 --- a/src/util.h +++ b/src/util.h @@ -69,9 +69,9 @@ static inline u64 rdtscll(void) inline u32 stack_hop(u32 eax, u32 edx, u32 ecx, void *func); u8 checksum_far(u16 buf_seg, void *buf_far, u32 len); u8 checksum(void *buf, u32 len); -int memeq(const void *s1, const void *s2, size_t n); +int memcmp(const void *s1, const void *s2, size_t n); size_t strlen(const char *s); -int streq(const char *s1, const char *s2); +int strcmp(const char *s1, const char *s2); void *memset(void *s, int c, size_t n); void *memcpy(void *d1, const void *s1, size_t len); inline void memcpy_far(u16 d_seg, void *d_far -- 2.25.1