a8e481
From 610e732bda06aef9ff3b16df757ddc32d8368a1a Mon Sep 17 00:00:00 2001
a8e481
From: Sergey Poznyakoff <gray@gnu.org.ua>
a8e481
Date: Mon, 20 Feb 2012 19:51:27 +0200
a8e481
Subject: [PATCH] Always use 32 bit CRC
a8e481
a8e481
* src/cpiohdr.h (cpio_file_stat) <c_chksum>: Change type to
a8e481
uint32_t.
a8e481
* src/extern.h (crc): Change type to uint32_t.
a8e481
* src/global.c: Likewise.
a8e481
* src/copyout.c (read_for_checksum): Return uint32_t.
a8e481
* src/copyin.c: Fix printf formats.
a8e481
---
a8e481
 src/copyin.c  | 8 ++++----
a8e481
 src/copyout.c | 4 ++--
a8e481
 src/cpiohdr.h | 2 +-
a8e481
 src/extern.h  | 2 +-
a8e481
 src/global.c  | 2 +-
a8e481
 5 files changed, 9 insertions(+), 9 deletions(-)
a8e481
a8e481
diff --git a/src/copyin.c b/src/copyin.c
a8e481
index 29d0fb1..db8ee66 100644
a8e481
--- a/src/copyin.c
a8e481
+++ b/src/copyin.c
a8e481
@@ -193,7 +193,7 @@ list_file (struct cpio_file_stat* file_hdr, int in_file_des)
a8e481
 #endif
a8e481
       if (crc != file_hdr->c_chksum)
a8e481
 	{
a8e481
-	  error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
a8e481
+	  error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
a8e481
 		 file_hdr->c_name, crc, file_hdr->c_chksum);
a8e481
 	}
a8e481
     }
a8e481
@@ -540,7 +540,7 @@ copyin_regular_file (struct cpio_file_stat* file_hdr, int in_file_des)
a8e481
       if (archive_format == arf_crcascii)
a8e481
 	{
a8e481
 	  if (crc != file_hdr->c_chksum)
a8e481
-	    error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
a8e481
+	    error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
a8e481
 		   file_hdr->c_name, crc, file_hdr->c_chksum);
a8e481
 	}
a8e481
       tape_skip_padding (in_file_des, file_hdr->c_filesize);
a8e481
@@ -565,7 +565,7 @@ copyin_regular_file (struct cpio_file_stat* file_hdr, int in_file_des)
a8e481
   if (archive_format == arf_crcascii)
a8e481
     {
a8e481
       if (crc != file_hdr->c_chksum)
a8e481
-	error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
a8e481
+	error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
a8e481
 	       file_hdr->c_name, crc, file_hdr->c_chksum);
a8e481
     }
a8e481
 
a8e481
@@ -1454,7 +1454,7 @@ process_copy_in ()
a8e481
 	    tape_skip_padding (in_file_des, file_hdr.c_filesize);
a8e481
 	    if (crc != file_hdr.c_chksum)
a8e481
 	      {
a8e481
-		error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
a8e481
+		error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
a8e481
 		       file_hdr.c_name, crc, file_hdr.c_chksum);
a8e481
 	      }
a8e481
          /* Debian hack: -v and -V now work with --only-verify-crc.
a8e481
diff --git a/src/copyout.c b/src/copyout.c
a8e481
index 72f1989..03eaf88 100644
a8e481
--- a/src/copyout.c
a8e481
+++ b/src/copyout.c
a8e481
@@ -33,10 +33,10 @@
a8e481
 /* Read FILE_SIZE bytes of FILE_NAME from IN_FILE_DES and
a8e481
    compute and return a checksum for them.  */
a8e481
 
a8e481
-static unsigned long
a8e481
+static uint32_t
a8e481
 read_for_checksum (int in_file_des, int file_size, char *file_name)
a8e481
 {
a8e481
-  unsigned long crc;
a8e481
+  uint32_t crc;
a8e481
   char buf[BUFSIZ];
a8e481
   int bytes_left;
a8e481
   int bytes_read;
a8e481
diff --git a/src/cpiohdr.h b/src/cpiohdr.h
a8e481
index bb1ad6b..1c11998 100644
a8e481
--- a/src/cpiohdr.h
a8e481
+++ b/src/cpiohdr.h
a8e481
@@ -123,7 +123,7 @@ struct cpio_file_stat /* Internal representation of a CPIO header */
a8e481
   long c_rdev_maj;
a8e481
   long c_rdev_min;
a8e481
   size_t c_namesize;
a8e481
-  unsigned long c_chksum;
a8e481
+  uint32_t c_chksum;
a8e481
   char *c_name;
a8e481
   char *c_tar_linkname;
a8e481
 };
a8e481
diff --git a/src/extern.h b/src/extern.h
a8e481
index 4f94d40..3530bf6 100644
a8e481
--- a/src/extern.h
a8e481
+++ b/src/extern.h
a8e481
@@ -75,7 +75,7 @@ extern char *new_media_message_after_number;
a8e481
 extern int archive_des;
a8e481
 extern char *archive_name;
a8e481
 extern char *rsh_command_option;
a8e481
-extern unsigned long crc;
a8e481
+extern uint32_t crc;
a8e481
 extern int delayed_seek_count;
a8e481
 #ifdef DEBUG_CPIO
a8e481
 extern int debug_flag;
a8e481
diff --git a/src/global.c b/src/global.c
a8e481
index cff9720..336941e 100644
a8e481
--- a/src/global.c
a8e481
+++ b/src/global.c
a8e481
@@ -144,7 +144,7 @@ char *archive_name = NULL;
a8e481
 char *rsh_command_option = NULL;
a8e481
 
a8e481
 /* CRC checksum.  */
a8e481
-unsigned long crc;
a8e481
+uint32_t crc;
a8e481
 
a8e481
 /* Input and output buffers.  */
a8e481
 char *input_buffer, *output_buffer;
a8e481
-- 
a8e481
2.9.3
a8e481