On 08.09.2007 21:36, svn@openbios.org wrote:
Author: uwe Date: 2007-09-08 21:36:35 +0200 (Sat, 08 Sep 2007) New Revision: 496
Modified: LinuxBIOSv3/include/string.h LinuxBIOSv3/lib/lar.c Log: Add a simple strncmp() implementation in include/string.h.
Change lib/lar.c to use strncmp() for magic check. Current code depends on that the len field will never hold a value bigger than 0xffffff, which is a working assumption given current flash sizes, but my next patch might affect this.
Signed-off-by: Alex Beregszaszi alex@rtfs.hu Acked-by: Uwe Hermann uwe@hermann-uwe.de
Minor comment below:
Modified: LinuxBIOSv3/include/string.h
--- LinuxBIOSv3/include/string.h 2007-09-07 17:53:47 UTC (rev 495) +++ LinuxBIOSv3/include/string.h 2007-09-08 19:36:35 UTC (rev 496) @@ -110,4 +110,24 @@ return c1 - c2; }
+/**
- Compare two strings with fixed length.
- @param s1 The first string.
- @param s2 The second string.
- @param maxlen Return at most maxlen characters as length of the string.
- @return A non-zero value if s1 and s2 differ, or zero if s1 equals s2.
- */
+static inline int strncmp(const char *s1, const char *s2, int maxlen)
Do we really want the "inline" keyword? Once we have more than one user, it is a waste of text size and with only one user AFAIK gcc inlines it automatically.
+{
- int i;
- for (i = 0; i < maxlen; i++) {
if (s1[i] != s2[i])
return s1[i] - s2[i];
- }
- return 0;
+}
#endif /* STRING_H */
Carl-Daniel