]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Avoid multiarch memcmp in tzdata-update
authorH.J. Lu <hongjiu.lu@intel.com>
Tue, 13 Apr 2010 08:36:21 +0000 (10:36 +0200)
committerAndreas Schwab <schwab@redhat.com>
Tue, 13 Apr 2010 12:01:08 +0000 (14:01 +0200)
fedora/tzdata-update.c

index 988fb556367288ced8d8808dfa407ea8ae63c48a..33bb8c67e379c88dc4af0fcbf5dc33c55973302f 100644 (file)
@@ -397,6 +397,16 @@ char buffer[32768], data[32768];
 size_t datasize;
 char zonename[1024];
 
+static int
+simple_memcmp (const char *s1, const char *s2, size_t n)
+{
+  int ret = 0;
+
+  while (n--
+        && (ret = *(unsigned char *) s1++ - *(unsigned char *) s2++) == 0);
+  return ret;
+}
+
 ssize_t
 readall (int fd, void *buf, size_t len)
 {
@@ -455,7 +465,8 @@ update (const char *filename)
   if (ret <= 0 || (size_t) ret == sizeof (buffer))
     return;
   /* Don't update the file unnecessarily.  */
-  if ((size_t) ret == datasize && memcmp (buffer, data, datasize) == 0)
+  if ((size_t) ret == datasize
+      && simple_memcmp (buffer, data, datasize) == 0)
     return;
   size_t len = strlen (filename);
   char tempfilename[len + sizeof (".tzupdate")];
@@ -507,7 +518,7 @@ main (int argc, char **argv)
   while (p != NULL)
     {
       while (*p == ' ' || *p == '\t') p++;
-      if (memcmp (p, "ZONE", 4) == 0)
+      if (simple_memcmp (p, "ZONE", 4) == 0)
        {
          p += 4;
          while (*p == ' ' || *p == '\t') p++;