bug-tar
[Top][All Lists]
Advanced

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

[Bug-tar] avoid compiler warnings, adapt to latest gnulib


From: Jim Meyering
Subject: [Bug-tar] avoid compiler warnings, adapt to latest gnulib
Date: Sat, 25 Aug 2007 21:59:48 +0200

Hi Sergey,

tar doesn't build against the latest gnulib.
Here is a patch to fix that, along with changes to avoid a bunch of warnings:

2007-08-25  Jim Meyering  <address@hidden>

        Don't include <getline.h>.  No longer needed.
        * src/incremen.c: Don't include <getline.h>.  No longer needed.
        * src/buffer.c: Likewise.
        * src/system.c: Likewise.
        * src/tar.c: Likewise.

        Avoid shadowing and unused-variable warnings.
        * src/create.c (check_exclusion_tags): Remove declaration of unused
        local, "ret".
        * src/compare.c (diff_dumpdir): Rename stat->stat_data to avoid
        shadowing the syscall.
        * src/buffer.c (do_checkpoint): Don't shadow the write syscall.
        (try_new_volume): Avoid shadowing "access".
        * src/tar.c (decode_options): Rename index->idx to avoid shadowing.
        (find_argp_option): Rename option->o to avoid shadowing.
        * src/incremen.c (scan_directory): Rename local, dir_name->dir,
        to avoid shadowing the function.
        (get_directory_contents): Likewise.
        * src/system.c (global_pid): Rename from "pid", to avoid being
        shadowed by locals.
        * src/extract.c (apply_nonancestor_delayed_set_stat):
        Rename st->sb to avoid shadowing another local.

Index: src/incremen.c
===================================================================
RCS file: /cvsroot/tar/tar/src/incremen.c,v
retrieving revision 1.55
diff -u -p -r1.55 incremen.c
--- src/incremen.c      27 Jun 2007 13:30:14 -0000      1.55
+++ src/incremen.c      25 Aug 2007 19:56:10 -0000
@@ -18,7 +18,6 @@
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */

 #include <system.h>
-#include <getline.h>
 #include <hash.h>
 #include <quotearg.h>
 #include "common.h"
@@ -455,9 +454,9 @@ makedumpdir (struct directory *directory

 /* Recursively scan the given directory. */
 static char *
-scan_directory (char *dir_name, dev_t device)
+scan_directory (char *dir, dev_t device)
 {
-  char *dirp = savedir (dir_name);     /* for scanning directory */
+  char *dirp = savedir (dir);  /* for scanning directory */
   char *name_buffer;           /* directory, `/', and directory member */
   size_t name_buffer_size;     /* allocated size of name_buffer, minus 2 */
   size_t name_length;          /* used length in name_buffer */
@@ -465,12 +464,12 @@ scan_directory (char *dir_name, dev_t de
   struct directory *directory;

   if (! dirp)
-    savedir_error (dir_name);
+    savedir_error (dir);

-  name_buffer_size = strlen (dir_name) + NAME_FIELD_SIZE;
+  name_buffer_size = strlen (dir) + NAME_FIELD_SIZE;
   name_buffer = xmalloc (name_buffer_size + 2);
-  strcpy (name_buffer, dir_name);
-  if (! ISSLASH (dir_name[strlen (dir_name) - 1]))
+  strcpy (name_buffer, dir);
+  if (! ISSLASH (dir[strlen (dir) - 1]))
     strcat (name_buffer, "/");
   name_length = strlen (name_buffer);

@@ -552,9 +551,9 @@ scan_directory (char *dir_name, dev_t de
 }

 char *
-get_directory_contents (char *dir_name, dev_t device)
+get_directory_contents (char *dir, dev_t device)
 {
-  return scan_directory (dir_name, device);
+  return scan_directory (dir, device);
 }

 
Index: src/buffer.c
===================================================================
RCS file: /cvsroot/tar/tar/src/buffer.c,v
retrieving revision 1.111
diff -u -p -r1.111 buffer.c
--- src/buffer.c        24 Aug 2007 12:07:32 -0000      1.111
+++ src/buffer.c        25 Aug 2007 19:56:11 -0000
@@ -26,7 +26,6 @@

 #include <closeout.h>
 #include <fnmatch.h>
-#include <getline.h>
 #include <human.h>
 #include <quotearg.h>

@@ -591,7 +590,7 @@ _open_archive (enum access_mode wanted_a
 }

 static void
-do_checkpoint (bool write)
+do_checkpoint (bool do_write)
 {
   if (checkpoint_option && !(++checkpoint % checkpoint_option))
     {
@@ -603,7 +602,7 @@ do_checkpoint (bool write)
          break;

        case checkpoint_text:
-         if (write)
+         if (do_write)
            /* TRANSLATORS: This is a ``checkpoint of write operation'',
             *not* ``Writing a checkpoint''.
             E.g. in Spanish ``Punto de comprobaci@'on de escritura'',
@@ -1137,22 +1136,22 @@ try_new_volume ()
 {
   size_t status;
   union block *header;
-  int access;
+  enum access_mode acc;
   
   switch (subcommand_option)
     {
     case APPEND_SUBCOMMAND:
     case CAT_SUBCOMMAND:
     case UPDATE_SUBCOMMAND:
-      access = ACCESS_UPDATE;
+      acc = ACCESS_UPDATE;
       break;

     default:
-      access = ACCESS_READ;
+      acc = ACCESS_READ;
       break;
     }

-  if (!new_volume (access))
+  if (!new_volume (acc))
     return true;
   
   while ((status = rmtread (archive, record_start->buffer, record_size))
Index: src/system.c
===================================================================
RCS file: /cvsroot/tar/tar/src/system.c,v
retrieving revision 1.20
diff -u -p -r1.20 system.c
--- src/system.c        27 Jun 2007 13:30:15 -0000      1.20
+++ src/system.c        25 Aug 2007 19:56:11 -0000
@@ -17,7 +17,6 @@
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */

 #include <system.h>
-#include <getline.h>
 #include <setenv.h>

 #include "common.h"
@@ -697,7 +696,7 @@ stat_to_env (char *name, char type, stru
     }
 }

-static pid_t pid;
+static pid_t global_pid;
 static RETSIGTYPE (*pipe_handler) (int sig);

 int
@@ -708,9 +707,9 @@ sys_exec_command (char *file_name, int t

   xpipe (p);
   pipe_handler = signal (SIGPIPE, SIG_IGN);
-  pid = xfork ();
+  global_pid = xfork ();

-  if (pid != 0)
+  if (global_pid != 0)
     {
       xclose (p[PREAD]);
       return p[PWRITE];
@@ -737,14 +736,14 @@ sys_wait_command (void)
 {
   int status;

-  if (pid < 0)
+  if (global_pid < 0)
     return;

   signal (SIGPIPE, pipe_handler);
-  while (waitpid (pid, &status, 0) == -1)
+  while (waitpid (global_pid, &status, 0) == -1)
     if (errno != EINTR)
       {
-        pid = -1;
+        global_pid = -1;
         waitpid_error (to_command_option);
         return;
       }
@@ -753,18 +752,18 @@ sys_wait_command (void)
     {
       if (!ignore_command_error_option && WEXITSTATUS (status))
        ERROR ((0, 0, _("%lu: Child returned status %d"),
-               (unsigned long) pid, WEXITSTATUS (status)));
+               (unsigned long) global_pid, WEXITSTATUS (status)));
     }
   else if (WIFSIGNALED (status))
     {
       WARN ((0, 0, _("%lu: Child terminated on signal %d"),
-            (unsigned long) pid, WTERMSIG (status)));
+            (unsigned long) global_pid, WTERMSIG (status)));
     }
   else
     ERROR ((0, 0, _("%lu: Child terminated on unknown reason"),
-           (unsigned long) pid));
+           (unsigned long) global_pid));

-  pid = -1;
+  global_pid = -1;
 }

 int
Index: src/tar.c
===================================================================
RCS file: /cvsroot/tar/tar/src/tar.c,v
retrieving revision 1.169
diff -u -p -r1.169 tar.c
--- src/tar.c   27 Jun 2007 13:30:15 -0000      1.169
+++ src/tar.c   25 Aug 2007 19:56:12 -0000
@@ -22,7 +22,6 @@
 #include <system.h>

 #include <fnmatch.h>
-#include <getline.h>
 #include <argp.h>
 #include <argp-namefrob.h>
 #include <argp-fmtstream.h>
@@ -1934,23 +1933,23 @@ usage (int status)
 /* Parse the options for tar.  */

 static struct argp_option *
-find_argp_option (struct argp_option *options, int letter)
+find_argp_option (struct argp_option *o, int letter)
 {
   for (;
-       !(options->name == NULL
-        && options->key == 0
-        && options->arg == 0
-        && options->flags == 0
-        && options->doc == NULL); options++)
-    if (options->key == letter)
-      return options;
+       !(o->name == NULL
+        && o->key == 0
+        && o->arg == 0
+        && o->flags == 0
+        && o->doc == NULL); o++)
+    if (o->key == letter)
+      return o;
   return NULL;
 }

 static void
 decode_options (int argc, char **argv)
 {
-  int index;
+  int idx;
   struct tar_args args;

   /* Set some default option values.  */
@@ -2041,7 +2040,7 @@ decode_options (int argc, char **argv)
   prepend_default_options (getenv ("TAR_OPTIONS"), &argc, &argv);

   if (argp_parse (&argp, argc, argv, ARGP_IN_ORDER|ARGP_NO_HELP,
-                 &index, &args))
+                 &idx, &args))
     exit (TAREXIT_FAILURE);


@@ -2069,9 +2068,9 @@ decode_options (int argc, char **argv)
     }

   /* Handle operands after any "--" argument.  */
-  for (; index < argc; index++)
+  for (; idx < argc; idx++)
     {
-      name_add_name (argv[index], MAKE_INCL_OPTIONS (&args));
+      name_add_name (argv[idx], MAKE_INCL_OPTIONS (&args));
       args.input_files = true;
     }

Index: src/create.c
===================================================================
RCS file: /cvsroot/tar/tar/src/create.c,v
retrieving revision 1.127
diff -u -p -r1.127 create.c
--- src/create.c        27 Jun 2007 13:30:14 -0000      1.127
+++ src/create.c        25 Aug 2007 19:56:12 -0000
@@ -78,7 +78,6 @@ check_exclusion_tags (char *dirname, con
   struct exclusion_tag *tag;
   size_t dlen = strlen (dirname);
   char *nptr = NULL;
-  char *ret = NULL;
   
   for (tag = exclusion_tags; tag; tag = tag->next)
     {
Index: src/compare.c
===================================================================
RCS file: /cvsroot/tar/tar/src/compare.c,v
retrieving revision 1.39
diff -u -p -r1.39 compare.c
--- src/compare.c       27 Jun 2007 13:30:14 -0000      1.39
+++ src/compare.c       25 Aug 2007 19:56:12 -0000
@@ -368,9 +368,9 @@ diff_dumpdir (void)
 {
   char *dumpdir_buffer;
   dev_t dev = 0;
-  struct stat stat;
+  struct stat stat_data;

-  if (deref_stat (true, current_stat_info.file_name, &stat))
+  if (deref_stat (true, current_stat_info.file_name, &stat_data))
     {
       if (errno == ENOENT)
        stat_warn (current_stat_info.file_name);
@@ -378,7 +378,7 @@ diff_dumpdir (void)
        stat_error (current_stat_info.file_name);
     }
   else
-    dev = stat.st_dev;
+    dev = stat_data.st_dev;

   dumpdir_buffer = get_directory_contents (current_stat_info.file_name, dev);

Index: src/extract.c
===================================================================
RCS file: /cvsroot/tar/tar/src/extract.c,v
retrieving revision 1.103
diff -u -p -r1.103 extract.c
--- src/extract.c       27 Jun 2007 13:30:14 -0000      1.103
+++ src/extract.c       25 Aug 2007 19:56:13 -0000
@@ -1,7 +1,7 @@
 /* Extract files from a tar archive.

    Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1998, 1999, 2000,
-   2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+   2001, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.

    Written by John Gilmore, on 1985-11-19.

@@ -593,13 +593,13 @@ apply_nonancestor_delayed_set_stat (char

       if (! skip_this_one)
        {
-         struct tar_stat_info st;
-         st.stat.st_mode = data->mode;
-         st.stat.st_uid = data->uid;
-         st.stat.st_gid = data->gid;
-         st.atime = data->atime;
-         st.mtime = data->mtime;
-         set_stat (data->file_name, &st, cur_info,
+         struct tar_stat_info sb;
+         sb.stat.st_mode = data->mode;
+         sb.stat.st_uid = data->uid;
+         sb.stat.st_gid = data->gid;
+         sb.atime = data->atime;
+         sb.mtime = data->mtime;
+         set_stat (data->file_name, &sb, cur_info,
                    data->invert_permissions, data->permstatus, DIRTYPE);
        }





reply via email to

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