[BZ #5441, BZ #5452, BZ #5454]
authorUlrich Drepper <drepper@redhat.com>
Fri, 7 Dec 2007 16:50:11 +0000 (16:50 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 7 Dec 2007 16:50:11 +0000 (16:50 +0000)
2007-12-07  Ulrich Drepper  <drepper@redhat.com>
[BZ #5441]
* stdio-common/vfscanf.c (_IO_vfwscanf): Don't free ptrs_to_free
structure, it's allocated with alloca.
* stdio-common/Makefile (tests): Add bug21.
* stdio-common/bug21.c: New file.

2007-12-06  Aurelien Jarno  <aurelien@aurel32.net>

[BZ #5452]
* sysdeps/unix/sysv/linux/bits/sched.h: Use __extension__
  keyword for gcc's braced-groups.

2007-12-07  Ulrich Drepper  <drepper@redhat.com>

[BZ #5454]
* inet/ether_line.c: Strip hostname of whitespaces.
* inet/Makefile (tests): Add tst-ether_line.
* inet/tst-ether_line.c: New file.

ChangeLog
inet/Makefile
inet/ether_line.c
inet/tst-ether_line.c [new file with mode: 0644]
nptl/ChangeLog
nptl/sysdeps/pthread/pthread.h
stdio-common/Makefile
stdio-common/bug21.c [new file with mode: 0644]
stdio-common/vfscanf.c
sysdeps/unix/sysv/linux/bits/sched.h

index a731b496b47f2411f8d5ce348561762a58780545..49fce28b4f4f571ee9022930e9d7e3bf5e6813bc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2007-12-07  Ulrich Drepper  <drepper@redhat.com>
+
+       [BZ #5441]
+       * stdio-common/vfscanf.c (_IO_vfwscanf): Don't free ptrs_to_free
+       structure, it's allocated with alloca.
+       * stdio-common/Makefile (tests): Add bug21.
+       * stdio-common/bug21.c: New file.
+
+2007-12-06  Aurelien Jarno  <aurelien@aurel32.net>
+
+       [BZ #5452]
+       * sysdeps/unix/sysv/linux/bits/sched.h: Use __extension__
+         keyword for gcc's braced-groups.
+
+2007-12-07  Ulrich Drepper  <drepper@redhat.com>
+
+       [BZ #5454]
+       * inet/ether_line.c: Strip hostname of whitespaces.
+       * inet/Makefile (tests): Add tst-ether_line.
+       * inet/tst-ether_line.c: New file.
+
 2007-12-03  Ulrich Drepper  <drepper@redhat.com>
 
        [BZ #5439]
index 2250cc6e8c4ab517504b4c3655fc867d49396894..d7139c1d7f9e092dfdc7ee20ffba02c22319905d 100644 (file)
@@ -52,7 +52,7 @@ routines := htonl htons               \
 aux := check_pf check_native ifreq
 
 tests := htontest test_ifindex tst-ntoa tst-ether_aton tst-network \
-        tst-gethnm test-ifaddrs bug-if1 test-inet6_opt
+        tst-gethnm test-ifaddrs bug-if1 test-inet6_opt tst-ether_line
 
 include ../Rules
 
index 7e871a6bd72e3789f676062ccb04163dd39dfc7e..13c5f394cfc2e1ecd7312358e0f219fbc45c1ba7 100644 (file)
@@ -61,19 +61,20 @@ ether_line (const char *line, struct ether_addr *addr, char *hostname)
        ++line;
     }
 
-  /* Remove trailing white space.  */
-  cp = __strchrnul (line, '#');
-  while (cp > line && isspace (cp[-1]))
-    --cp;
+  /* Skip initial whitespace.  */
+  while (isspace (*line))
+    ++line;
 
-  if (cp == line)
+  if (*line == '#' || *line == '\0')
     /* No hostname.  */
     return -1;
 
+  /* The hostname is up to the next non-space character.  */
   /* XXX This can cause trouble because the hostname might be too long
      but we have no possibility to check it here.  */
-  memcpy (hostname, line, cp - line);
-  hostname [cp - line] = '\0';
+  while (*line != '\0' && *line != '#' && !isspace (*line))
+    *hostname++ = *line++;
+  *hostname = '\0';
 
   return 0;
 }
diff --git a/inet/tst-ether_line.c b/inet/tst-ether_line.c
new file mode 100644 (file)
index 0000000..ff0560b
--- /dev/null
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <string.h>
+#include <netinet/ether.h>
+
+
+static int
+do_test (void)
+{
+  struct ether_addr a;
+  char buf[1000];
+  if (ether_line ("00:01:02:03:04:05       aaaaa   \n", &a, buf) != 0)
+    {
+      puts ("ether_line failed");
+      return 1;
+    }
+
+  int res = 0;
+  int i;
+  for (i = 0; i < ETH_ALEN; ++i)
+    {
+      printf ("%02x%s",
+             (int) a.ether_addr_octet[i], i + 1 == ETH_ALEN ? "" : ":");
+      if (a.ether_addr_octet[i] != i)
+       {
+         printf ("octet %d is %d, expected %d\n",
+                 i, (int) a.ether_addr_octet[i], i);
+         res = 1;
+       }
+    }
+
+  printf (" \"%s\"\n", buf);
+  res |= strcmp (buf, "aaaaa") != 0;
+
+  return res;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
index 05d95eb3b464a18b67fd9fbeaaa6355c4baa5415..c882028750fe9b4bd300ab35c74b7172586d9411 100644 (file)
@@ -1,3 +1,10 @@
+2007-12-07  Ulrich Drepper  <drepper@redhat.com>
+
+       [BZ #5455]
+       * sysdeps/pthread/pthread.h [!__EXCEPTIONS] (pthread_cleanup_pop):
+       Allow label before pthread_cleanup_pop.
+       (pthread_cleanup_pop_restore_np): Likewise.
+
 2007-12-04  Kaz Kojima  <kkojima@rr.iij4u.or.jp>
 
        * sysdeps/unix/sysv/linux/sh/lowlevellock.S (__lll_timedlock_wait):
index 59126fcf52c39a33472922fb94319543efbe222c..f3ab0ae7110b12e3f5c328e75d0a04f4bb381b91 100644 (file)
@@ -655,6 +655,7 @@ extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
 /* Remove a cleanup handler installed by the matching pthread_cleanup_push.
    If EXECUTE is non-zero, the handler function is called. */
 # define pthread_cleanup_pop(execute) \
+      do; while (0); /* Empty to allow label before pthread_cleanup_pop.  */  \
     } while (0);                                                             \
     __pthread_unregister_cancel (&__cancel_buf);                             \
     if (execute)                                                             \
@@ -690,6 +691,7 @@ extern void __pthread_register_cancel_defer (__pthread_unwind_buf_t *__buf)
    restores the cancellation type that was in effect when the matching
    pthread_cleanup_push_defer was called.  */
 #  define pthread_cleanup_pop_restore_np(execute) \
+      do; while (0); /* Empty to allow label before pthread_cleanup_pop.  */  \
     } while (0);                                                             \
     __pthread_unregister_cancel_restore (&__cancel_buf);                     \
     if (execute)                                                             \
index d5b1251993c992b2c47cf3f7891dedf90eb8ebc6..db622af22bd177f4ba1331f55863c219397f0e57 100644 (file)
@@ -57,7 +57,7 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
         tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 \
         tst-popen tst-unlockedio tst-fmemopen2 tst-put-error tst-fgets \
         tst-fwrite bug16 bug17 tst-swscanf tst-sprintf2 bug18 bug18a \
-        bug19 bug19a tst-popen2 scanf13 scanf14 scanf15 bug20
+        bug19 bug19a tst-popen2 scanf13 scanf14 scanf15 bug20 bug21
 
 test-srcs = tst-unbputc tst-printf
 
diff --git a/stdio-common/bug21.c b/stdio-common/bug21.c
new file mode 100644 (file)
index 0000000..d22b9c1
--- /dev/null
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+static int
+do_test (void)
+{
+  static const char buf[] = " ";
+  char *str;
+
+  int r = sscanf (buf, "%as", &str);
+  printf ("%d %p\n", r, str);
+
+  return r != -1 || str != NULL;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
index f550109a902eb73dcc7fa00f7748f11493444ad9..a03e19c4e3a8a4737fca8891952c36ce6a72af53 100644 (file)
@@ -2845,7 +2845,6 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
                  *p->ptrs[cnt] = NULL;
                }
              p = p->next;
-             free (ptrs_to_free);
              ptrs_to_free = p;
            }
        }
index 5eaa2fe528cf8add6e24bde16f1216bbbf7ec8db..5387b9cef0f8a0138d5d4872eba5a74da7bd4f19 100644 (file)
@@ -132,17 +132,21 @@ typedef struct
   } while (0)
 # endif
 # define __CPU_SET_S(cpu, setsize, cpusetp) \
-  ({ size_t __cpu = (cpu);                                                   \
-     __cpu < 8 * (setsize)                                                   \
-     ? ((cpusetp)->__bits[__CPUELT (__cpu)] |= __CPUMASK (__cpu)) : 0; })
+  (__extension__                                                             \
+   ({ size_t __cpu = (cpu);                                                  \
+      __cpu < 8 * (setsize)                                                  \
+      ? ((cpusetp)->__bits[__CPUELT (__cpu)] |= __CPUMASK (__cpu)) : 0; }))
 # define __CPU_CLR_S(cpu, setsize, cpusetp) \
-  ({ size_t __cpu = (cpu);                                                   \
-     __cpu < 8 * (setsize)                                                   \
-     ? ((cpusetp)->__bits[__CPUELT (__cpu)] &= ~__CPUMASK (__cpu)) : 0; })
+  (__extension__                                                             \
+   ({ size_t __cpu = (cpu);                                                  \
+      __cpu < 8 * (setsize)                                                  \
+      ? ((cpusetp)->__bits[__CPUELT (__cpu)] &= ~__CPUMASK (__cpu)) : 0; }))
 # define __CPU_ISSET_S(cpu, setsize, cpusetp) \
-  ({ size_t __cpu = (cpu);                                                   \
-     __cpu < 8 * (setsize)                                                   \
-     ? (((cpusetp)->__bits[__CPUELT (__cpu)] & __CPUMASK (__cpu))) != 0 : 0; })
+  (__extension__                                                             \
+   ({ size_t __cpu = (cpu);                                                  \
+      __cpu < 8 * (setsize)                                                  \
+      ? (((cpusetp)->__bits[__CPUELT (__cpu)] & __CPUMASK (__cpu))) != 0      \
+      : 0; }))
 
 # define __CPU_COUNT_S(setsize, cpusetp) \
   __sched_cpucount (setsize, cpusetp)
@@ -152,25 +156,27 @@ typedef struct
   (__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)
 # else
 #  define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
-  ({ cpu_set_t *__arr1 = (cpusetp1);                                         \
-     cpu_set_t *__arr2 = (cpusetp2);                                         \
-     size_t __imax = (setsize) / sizeof (__cpu_mask);                        \
-     size_t __i;                                                             \
-     for (__i = 0; __i < __imax; ++__i)                                              \
-       if (__arr1->__bits[__i] != __arr2->__bits[__i])                       \
-        break;                                                               \
-     __i == __imax; })
+  (__extension__                                                             \
+   ({ cpu_set_t *__arr1 = (cpusetp1);                                        \
+      cpu_set_t *__arr2 = (cpusetp2);                                        \
+      size_t __imax = (setsize) / sizeof (__cpu_mask);                       \
+      size_t __i;                                                            \
+      for (__i = 0; __i < __imax; ++__i)                                     \
+       if (__arr1->__bits[__i] != __arr2->__bits[__i])                       \
+         break;                                                              \
+      __i == __imax; }))
 # endif
 
 # define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \
-  ({ cpu_set_t *__dest = (destset);                                          \
-     cpu_set_t *__arr1 = (srcset1);                                          \
-     cpu_set_t *__arr2 = (srcset2);                                          \
-     size_t __imax = (setsize) / sizeof (__cpu_mask);                        \
-     size_t __i;                                                             \
-     for (__i = 0; __i < __imax; ++__i)                                              \
-       __dest->__bits[__i] = __arr1->__bits[__i] op __arr2->__bits[__i];      \
-     __dest; })
+  (__extension__                                                             \
+   ({ cpu_set_t *__dest = (destset);                                         \
+      cpu_set_t *__arr1 = (srcset1);                                         \
+      cpu_set_t *__arr2 = (srcset2);                                         \
+      size_t __imax = (setsize) / sizeof (__cpu_mask);                       \
+      size_t __i;                                                            \
+      for (__i = 0; __i < __imax; ++__i)                                     \
+       __dest->__bits[__i] = __arr1->__bits[__i] op __arr2->__bits[__i];     \
+      __dest; }))
 
 # define __CPU_ALLOC_SIZE(count) \
   ((((count) + __NCPUBITS - 1) / __NCPUBITS) * 8)