bug-tar
[Top][All Lists]
Advanced

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

[Bug-tar] [PATCH 1/5] Make the multi-volume code more generic


From: Pavel Raiskup
Subject: [Bug-tar] [PATCH 1/5] Make the multi-volume code more generic
Date: Fri, 2 Nov 2012 14:45:41 +0100

* buffer.c: created general "return" macros for error cases, make the
  in-case-of-error behavior consistent - always "warn only"
---
 src/buffer.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 7638bb1..562996f 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1322,6 +1322,23 @@ read_header0 (struct tar_stat_info *info)
   return false;
 }
 
+#define RETURN_BAD_ARCHIVE                                              \
+  do                                                                    \
+    {                                                                   \
+      WARN ((0, 0, _("This does not look like a tar archive")));        \
+      return false;                                                     \
+    }                                                                   \
+  while (0)
+
+#define RETURN_NOT_CONTINUED                                            \
+  do                                                                    \
+    {                                                                   \
+      WARN ((0, 0, _("%s is not continued on this volume"),             \
+            quote (bufmap_head->file_name)));                           \
+            return false;                                               \
+    }                                                                   \
+  while (0)
+
 static bool
 try_new_volume (void)
 {
@@ -1363,10 +1380,7 @@ try_new_volume (void)
        tar_stat_init (&dummy);
        if (read_header (&header, &dummy, read_header_x_global)
            != HEADER_SUCCESS_EXTENDED)
-         {
-           ERROR ((0, 0, _("This does not look like a tar archive")));
-           return false;
-         }
+         RETURN_BAD_ARCHIVE;
 
         xheader_decode (&dummy); /* decodes values from the global header */
         tar_stat_destroy (&dummy);
@@ -1393,8 +1407,7 @@ try_new_volume (void)
            break;
 
          default:
-           ERROR ((0, 0, _("This does not look like a tar archive")));
-           return false;
+           RETURN_BAD_ARCHIVE;
          }
         break;
       }
@@ -1439,11 +1452,7 @@ try_new_volume (void)
  _("%s is possibly continued on this volume: header contains truncated name"),
                    quote (bufmap_head->file_name)));
           else
-            {
-              WARN ((0, 0, _("%s is not continued on this volume"),
-                     quote (bufmap_head->file_name)));
-              return false;
-            }
+            RETURN_NOT_CONTINUED;
         }
 
       s = continued_file_size + continued_file_offset;
-- 
1.7.11.7




reply via email to

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