Răsfoiți Sursa

Include bounds in forward declaration for xhdr_tab.

Paul Eggert 21 ani în urmă
părinte
comite
761802e87a
2 a modificat fișierele cu 13 adăugiri și 2 ștergeri
  1. 6 1
      ChangeLog
  2. 7 1
      src/xheader.c

+ 6 - 1
ChangeLog

@@ -1,6 +1,11 @@
+2003-11-03  Paul Eggert  <eggert@twinsun.com>
+
+	* src/xheader.c (xhdr_tab): Include bounds in forward declaration,
+	as C89 and C99 require this.
+
 2003-10-26  Paul Eggert  <eggert@twinsun.com>
 
-	* system.c (sys_spawn_shell): Cast trailing null to (char *).
+	* src/system.c (sys_spawn_shell): Cast trailing null to (char *).
 	Bug reported by Christian Weisgerber.
 
 2003-10-19  Sergey Poznyakoff  <gray@Mirddin.farlep.net>

+ 7 - 1
src/xheader.c

@@ -36,7 +36,10 @@ struct xhdr_tab
   void (*decoder) (struct tar_stat_info *, char const *);
 };
 
-static struct xhdr_tab const xhdr_tab[];
+/* This declaration must specify the number of elements in xhdr_tab,
+   because ISO C99 section 6.9.2 prohibits a tentative definition that
+   has both internal linkage and incomplete type.  */
+static struct xhdr_tab const xhdr_tab[13];
 
 static struct xhdr_tab const *
 locate_handler (char const *keyword)
@@ -420,6 +423,9 @@ static struct xhdr_tab const xhdr_tab[] = {
   { "uid",	uid_coder,	uid_decoder	},
   { "uname",	uname_coder,	uname_decoder	},
 
+  /* The number of entries in xhdr_tab must agree with the array
+     bounds in xhdr_tab's forward declaration.  */
+
 #if 0 /* GNU private keywords (not yet implemented) */
   /* Sparse file handling */
   { "GNU.sparse.offset",     sparse_offset_coder, sparse_offset_decoder },