Replace memeq/streq functions with memcmp/strcmp.
The standard functions are better known and not harder to implement.
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 @@
// 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 @@
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 @@
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 @@
// 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 @@
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