bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

coreutils 6.6 c89 build failures


From: Matthew Woehlke
Subject: coreutils 6.6 c89 build failures
Date: Wed, 22 Nov 2006 12:14:48 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.8) Gecko/20061025 Thunderbird/1.5.0.8 Mnenhy/0.7.4.0

Ok... would it be too much to ask for people making check-ins to first check that building with '-Wdeclaration-after-statement' is clean?

remove.c bombs (*badly*) on non-c99 compilers (in my case, Solaris 5.7, but I know that's not my only non-c99 platform); rm.c and shred.c also fail (if less spectacularly). Patch attached.

I'm not sure that this is the best patch for shred; based on the really cursory glance at the 'verify' macro, I have no idea what it is supposed to be doing. Possibly verify.h should be fixed instead.

--
Matthew
"Two IIRC's must make a right" -- Larry Hall (paraphrased)
--- src/remove.c        2006-10-24 07:50:47.000000000 -0700
+++ src/remove.c.new    2006-11-22 09:48:01.197062000 -0800
@@ -245,9 +245,9 @@
 {
   size_t n_lengths = obstack_object_size (&ds->len_stack) / sizeof (size_t);
   size_t *length = obstack_base (&ds->len_stack);
+  size_t top_len = length[n_lengths - 1];

   assert (n_lengths > 0);
-  size_t top_len = length[n_lengths - 1];
   assert (top_len >= 2);

   /* Pop the specified length of file name.  */
@@ -379,10 +379,12 @@
 static void
 AD_stack_pop (Dirstack_state *ds)
 {
+  /* operate on Active_dir.  pop and free top entry */
+  struct AD_ent *top;
+
   assert (0 < AD_stack_height (ds));
+  top = AD_stack_top (ds);

-  /* operate on Active_dir.  pop and free top entry */
-  struct AD_ent *top = AD_stack_top (ds);
   if (top->unremovable)
     hash_free (top->unremovable);
   obstack_blank (&ds->Active_dir, -(int) sizeof (struct AD_ent));
@@ -542,6 +544,7 @@
 static void
 AD_mark_helper (Hash_table **ht, char *filename)
 {
+  void *ent;
   if (*ht == NULL)
     {
       *ht = hash_initialize (HT_UNREMOVABLE_INITIAL_CAPACITY, NULL, hash_pjw,
@@ -549,7 +552,7 @@
       if (*ht == NULL)
        xalloc_die ();
     }
-  void *ent = hash_insert (*ht, filename);
+  ent = hash_insert (*ht, filename);
   if (ent == NULL)
     xalloc_die ();
   else
@@ -1111,6 +1114,7 @@
 {
   int open_flags = O_RDONLY | O_NOCTTY | O_NOFOLLOW | O_NONBLOCK;
   int fd_sub = openat_permissive (fd_cwd, f, open_flags, 0, cwd_errno);
+  DIR *subdir_dirp;

   /* Record dev/ino of F.  We may compare them against saved values
      to thwart any attempt to subvert the traversal.  They are also used
@@ -1129,7 +1133,7 @@
       return NULL;
     }

-  DIR *subdir_dirp = fdopendir (fd_sub);
+  subdir_dirp = fdopendir (fd_sub);
   if (subdir_dirp == NULL)
     {
       close_preserve_errno (fd_sub);
@@ -1389,9 +1393,10 @@
        /* The name of the directory that we have just processed,
           nominally removing all of its contents.  */
        char *empty_dir;
+       int fd;

        AD_pop_and_chdir (&dirp, ds, &empty_dir);
-       int fd = (dirp != NULL ? dirfd (dirp) : AT_FDCWD);
+       fd = (dirp != NULL ? dirfd (dirp) : AT_FDCWD);
        assert (dirp != NULL || AD_stack_height (ds) == 1);

        /* Try to remove EMPTY_DIR only if remove_cwd_entries succeeded.  */
@@ -1403,9 +1408,10 @@
               But that's no big deal since we're interactive.  */
            struct stat empty_st;
            Ternary is_empty;
+           enum RM_status s;
            cache_stat_init (&empty_st);
-           enum RM_status s = prompt (fd, ds, empty_dir, &empty_st, x,
-                                      PA_REMOVE_DIR, &is_empty);
+           s = prompt (fd, ds, empty_dir, &empty_st, x,
+                       PA_REMOVE_DIR, &is_empty);

            if (s != RM_OK)
              {
@@ -1460,6 +1466,10 @@
       struct rm_options const *x, int *cwd_errno)
 {
   char const *base = last_component (filename);
+  struct stat st;
+  int fd_cwd;
+  enum RM_status status;
+
   if (dot_or_dotdot (base))
     {
       error (0, 0, _(base == filename
@@ -1469,7 +1479,6 @@
       return RM_ERROR;
     }

-  struct stat st;
   cache_stat_init (&st);
   if (x->root_dev_ino)
     {
@@ -1490,8 +1499,8 @@
   AD_push_initial (ds);
   AD_INIT_OTHER_MEMBERS ();

-  int fd_cwd = AT_FDCWD;
-  enum RM_status status = remove_entry (fd_cwd, ds, filename, &st, x, NULL);
+  fd_cwd = AT_FDCWD;
+  status = remove_entry (fd_cwd, ds, filename, &st, x, NULL);
   if (status == RM_NONEMPTY_DIR)
     {
       /* In the event that remove_dir->remove_cwd_entries detects
@@ -1522,6 +1531,8 @@

   for (i = 0; i < n_files; i++)
     {
+      enum RM_status s;
+
       if (cwd_errno && IS_RELATIVE_FILE_NAME (file[i]))
        {
          error (0, 0, _("cannot remove relative-named %s"), quote (file[i]));
@@ -1530,7 +1541,7 @@
        }

       cycle_check_init (&ds->cycle_check_state);
-      enum RM_status s = rm_1 (ds, file[i], x, &cwd_errno);
+      s = rm_1 (ds, file[i], x, &cwd_errno);
       assert (VALID_STATUS (s));
       UPDATE_STATUS (status, s);
     }
--- src/rm.c            2006-11-22 09:49:04.572788000 -0800
+++ src/rm.c.new        2006-11-22 09:49:10.063284000 -0800
@@ -358,6 +358,7 @@
   {
     size_t n_files = argc - optind;
     char const *const *file = (char const *const *) argv + optind;
+    enum RM_status status;

     if (prompt_once && (x.recursive || 3 < n_files))
       {
@@ -369,7 +370,7 @@
        if (!yesno ())
          exit (EXIT_SUCCESS);
       }
-    enum RM_status status = rm (n_files, file, &x);
+    status = rm (n_files, file, &x);
     assert (VALID_STATUS (status));
     exit (status == RM_ERROR ? EXIT_FAILURE : EXIT_SUCCESS);
   }
--- src/shred.c         2006-11-22 09:50:34.520927000 -0800
+++ src/shred.c.new     2006-11-22 09:57:34.338368000 -0800
@@ -460,7 +460,7 @@
                     out.  Thus, it shouldn't give up on bad blocks.  This
                     code works because lim is always a multiple of
                     SECTOR_SIZE, except at the end.  */
-                 verify (sizeof r % SECTOR_SIZE == 0);
+                 { verify (sizeof r % SECTOR_SIZE == 0); }
                  if (errnum == EIO && 0 <= size && (soff | SECTOR_MASK) < lim)
                    {
                      size_t soff1 = (soff | SECTOR_MASK) + 1;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]