bug-tar
[Top][All Lists]
Advanced

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

Re: [Bug-tar] [PATCH] tar: remove some set-but-unused/unused variables


From: Paul Eggert
Subject: Re: [Bug-tar] [PATCH] tar: remove some set-but-unused/unused variables
Date: Sun, 11 Mar 2012 13:05:10 -0700
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

Thanks for the heads-up, I did a lint pass and committed
the following bigger fix; the last hunk fixes what appears to be
a real bug.

>From d1cb18980bf3cbdddc86271241c8cb48f1c046fa Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Sun, 11 Mar 2012 13:00:52 -0700
Subject: [PATCH] tar: remove lint

This lint was found by GCC 4.6.2 on Fedora 15 x86-64.
* src/buffer.c (buffer_write_global_xheader, mv_end, set_start_time)
(compute_duration, print_total_stats, flush_read, flush_write):
* src/checkpoint.c (checkpoint_finish_compile):
* src/list.c (test_archive_label):
* src/misc.c (chdir_count):
* src/names.c (const):
* src/unlink.c (finish_deferred_unlinks):
Define with (void) instead of with (), for slightly-better C type
checking and to avoid a GCC warning.
* src/compare.c (diff_dumpdir):
* src/tar.c (parse_owner_group): Remove unused local.
* src/misc.c (chdir_do):
* src/tar.c (add_exclude_array): Rename local to avoid shadowing.
(LOW_DENSITY_NUM, MID_DENSITY_NUM, HIGH_DENSITY_NUM):
Define only if needed.
* src/update.c (update_archive): Initialize a local; this fixes
what appears to be a real bug.
---
 src/buffer.c     |   14 +++++++-------
 src/checkpoint.c |    2 +-
 src/compare.c    |    3 ---
 src/list.c       |    2 +-
 src/misc.c       |    8 ++++----
 src/names.c      |    2 +-
 src/tar.c        |   23 ++++++++++++-----------
 src/unlink.c     |    2 +-
 src/update.c     |    2 +-
 9 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 4a980b5..7638bb1 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -193,7 +193,7 @@ bufmap_reset (struct bufmap *map, ssize_t fixup)
 static struct tar_stat_info dummy;
 
 void
-buffer_write_global_xheader ()
+buffer_write_global_xheader (void)
 {
   xheader_write_global (&dummy.xhdr);
 }
@@ -205,7 +205,7 @@ mv_begin_read (struct tar_stat_info *st)
 }
 
 void
-mv_end ()
+mv_end (void)
 {
   if (multi_volume_option)
     bufmap_free (NULL);
@@ -233,7 +233,7 @@ clear_read_error_count (void)
 double duration;
 
 void
-set_start_time ()
+set_start_time (void)
 {
   gettime (&start_time);
   volume_start_time = start_time;
@@ -248,7 +248,7 @@ set_volume_start_time (void)
 }
 
 void
-compute_duration ()
+compute_duration (void)
 {
   struct timespec now;
   gettime (&now);
@@ -509,7 +509,7 @@ print_stats (FILE *fp, const char *text, tarlong numbytes)
 }
 
 void
-print_total_stats ()
+print_total_stats (void)
 {
   switch (subcommand_option)
     {
@@ -1928,13 +1928,13 @@ gnu_flush_write (size_t buffer_level)
 }
 
 void
-flush_read ()
+flush_read (void)
 {
   flush_read_ptr ();
 }
 
 void
-flush_write ()
+flush_write (void)
 {
   flush_write_ptr (record_size);
 }
diff --git a/src/checkpoint.c b/src/checkpoint.c
index f2f17a2..eb83cd3 100644
--- a/src/checkpoint.c
+++ b/src/checkpoint.c
@@ -113,7 +113,7 @@ checkpoint_compile_action (const char *str)
 }
 
 void
-checkpoint_finish_compile ()
+checkpoint_finish_compile (void)
 {
   if (checkpoint_option)
     {
diff --git a/src/compare.c b/src/compare.c
index 2fc72b7..ea41cb3 100644
--- a/src/compare.c
+++ b/src/compare.c
@@ -362,7 +362,6 @@ static void
 diff_dumpdir (struct tar_stat_info *dir)
 {
   const char *dumpdir_buffer;
-  dev_t dev = 0;
   struct stat stat_data;
 
   if (deref_stat (dir->file_name, &stat_data) != 0)
@@ -372,8 +371,6 @@ diff_dumpdir (struct tar_stat_info *dir)
       else
        stat_error (dir->file_name);
     }
-  else
-    dev = stat_data.st_dev;
 
   if (dir->fd == 0)
     {
diff --git a/src/list.c b/src/list.c
index 7e1319c..4f85fb5 100644
--- a/src/list.c
+++ b/src/list.c
@@ -1415,7 +1415,7 @@ skip_member (void)
 }
 
 void
-test_archive_label ()
+test_archive_label (void)
 {
   base64_init ();
   name_gather ();
diff --git a/src/misc.c b/src/misc.c
index 126161b..734dc4e 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -713,7 +713,7 @@ static int wdcache[CHDIR_CACHE_SIZE];
 static size_t wdcache_count;
 
 int
-chdir_count ()
+chdir_count (void)
 {
   if (wd_count == 0)
     return wd_count;
@@ -814,11 +814,11 @@ chdir_do (int i)
          int prev = wdcache[0];
          for (ci = 1; prev != i; ci++)
            {
-             int curr = wdcache[ci];
+             int cur = wdcache[ci];
              wdcache[ci] = prev;
-             if (curr == i)
+             if (cur == i)
                break;
-             prev = curr;
+             prev = cur;
            }
          wdcache[0] = i;
        }
diff --git a/src/names.c b/src/names.c
index f533c08..eee6bde 100644
--- a/src/names.c
+++ b/src/names.c
@@ -1100,7 +1100,7 @@ name_scan (const char *file_name)
 struct name *gnu_list_name;
 
 struct name const *
-name_from_list ()
+name_from_list (void)
 {
   if (!gnu_list_name)
     gnu_list_name = namelist;
diff --git a/src/tar.c b/src/tar.c
index 4f68534..ec7ebab 100644
--- a/src/tar.c
+++ b/src/tar.c
@@ -897,12 +897,12 @@ static char const * const backup_file_table[] = {
 };
 
 static void
-add_exclude_array (char const * const * fv, int options)
+add_exclude_array (char const * const * fv, int opts)
 {
   int i;
 
   for (i = 0; fv[i]; i++)
-    add_exclude (excluded, fv[i], options);
+    add_exclude (excluded, fv[i], opts);
 }
 
 
@@ -1152,16 +1152,18 @@ add_file_id (const char *filename)
 
 /* Default density numbers for [0-9][lmh] device specifications */
 
-#ifndef LOW_DENSITY_NUM
-# define LOW_DENSITY_NUM 0
-#endif
+#if defined DEVICE_PREFIX && !defined DENSITY_LETTER
+# ifndef LOW_DENSITY_NUM
+#  define LOW_DENSITY_NUM 0
+# endif
 
-#ifndef MID_DENSITY_NUM
-# define MID_DENSITY_NUM 8
-#endif
+# ifndef MID_DENSITY_NUM
+#  define MID_DENSITY_NUM 8
+# endif
 
-#ifndef HIGH_DENSITY_NUM
-# define HIGH_DENSITY_NUM 16
+# ifndef HIGH_DENSITY_NUM
+#  define HIGH_DENSITY_NUM 16
+# endif
 #endif
 
 static void
@@ -1375,7 +1377,6 @@ expand_pax_option (struct tar_args *targs, const char 
*arg)
 static uintmax_t
 parse_owner_group (char *arg, uintmax_t field_max, char const **name_option)
 {
-  strtol_error err;
   uintmax_t u = UINTMAX_MAX;
   char *end;
   char const *name = 0;
diff --git a/src/unlink.c b/src/unlink.c
index b281636..522ae11 100644
--- a/src/unlink.c
+++ b/src/unlink.c
@@ -123,7 +123,7 @@ flush_deferred_unlinks (bool force)
 }
 
 void
-finish_deferred_unlinks ()
+finish_deferred_unlinks (void)
 {
   flush_deferred_unlinks (true);
   while (dunlink_avail)
diff --git a/src/update.c b/src/update.c
index e3228d4..17f9e05 100644
--- a/src/update.c
+++ b/src/update.c
@@ -145,7 +145,7 @@ update_archive (void)
                    if (S_ISDIR (s.st_mode))
                      {
                        char *p, *dirp;
-                       DIR *stream;
+                       DIR *stream = NULL;
                        int fd = openat (chdir_fd, name->name,
                                         open_read_flags | O_DIRECTORY);
                        if (fd < 0)
-- 
1.7.6.5




reply via email to

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