Replace memeq/streq functions with memcmp/strcmp.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 18 Apr 2009 20:59:47 +0000 (16:59 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 18 Apr 2009 20:59:47 +0000 (16:59 -0400)
The standard functions are better known and not harder to implement.

src/cdrom.c
src/coreboot.c
src/util.c
src/util.h

index 71a8b849c6ad18e5b3c99863a855457b61bc5c8a..8f9e7d0a45096a1e8d9856d3a2ece57948c88dce 100644 (file)
@@ -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
index feccad352ac93fabdcb92c30cd855c3768e48e61..cdb13ba5da2de2bd5c7e45c03e59f4824bc7ad9b 100644 (file)
@@ -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--;
index ceceed828c35f44a67e47ab0e05206d77974dab1..88f134cafa8c65e1ba0362da7ac779a539fce69c 100644 (file)
@@ -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++;
     }
index cb2d46f422fa6a25b207fe7a26bca1f97f0ce143..f260e277e456e76437f3741879e7081e8a4da460 100644 (file)
@@ -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