summary refs log tree commit diff
diff options
context:
space:
mode:
authorH.J. Lu <hongjiu.lu@intel.com>2010-04-13 10:36:21 +0200
committerAndreas Schwab <schwab@redhat.com>2010-04-13 14:01:08 +0200
commit4f7ee9b3d798442cdd85b8223df80272af9507cd (patch)
tree31d1e8921f8051013ba454b9b87c5f17c5de0aed
parent973dc1b24b6e0ee01d3e90b17f9b6d53ee1baa68 (diff)
downloadglibc-4f7ee9b3d798442cdd85b8223df80272af9507cd.tar.gz
glibc-4f7ee9b3d798442cdd85b8223df80272af9507cd.tar.xz
glibc-4f7ee9b3d798442cdd85b8223df80272af9507cd.zip
Avoid multiarch memcmp in tzdata-update
-rw-r--r--fedora/tzdata-update.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/fedora/tzdata-update.c b/fedora/tzdata-update.c
index 988fb55636..33bb8c67e3 100644
--- a/fedora/tzdata-update.c
+++ b/fedora/tzdata-update.c
@@ -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++;