From: Paul Eggert Date: Thu, 13 Nov 2003 06:23:23 +0000 (+0000) Subject: Fix some C compatibility bugs reported by Joerg Schilling. X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=572225dfdcc2f36c50128ae40f90f5efaf1b7a2c;p=chaz%2Ftar Fix some C compatibility bugs reported by Joerg Schilling. --- diff --git a/ChangeLog b/ChangeLog index bb22a7b..c7b0ef5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2003-11-12 Paul Eggert + + Fix some C compatibility bugs reported by Joerg Schilling. + + * src/common.h (stripped_prefix_len): Fix misspelling + "stripped_path_len" in declaration. + * src/rmt.c (main): Use "return FOO;" rather than + "exit (FOO);"; we no longer have to worry about + pre-ANSI hosts that mishandled returned values from "main". + * src/tar.c (main): Likewise. This avoids warnings on some + compilers. + * src/system.c: Include signal.h, for 'kill'. + * src/system.h (DEV_BSIZE): Remove. + (DEFAULT_ST_BLKSIZE): New macro. + (ST_BLKSIZE): Use it, instead of DEV_BSIZE. + * src/tar.c (enum): Remove comma just before }. + 2003-11-12 Sergey Poznyakoff * src/list.c (decode_header): Initialize st_atime and diff --git a/src/common.h b/src/common.h index d9ea6bc..2112f7b 100644 --- a/src/common.h +++ b/src/common.h @@ -581,7 +581,7 @@ char *name_from_list (void); void blank_name_list (void); char *new_name (const char *, const char *); char *safer_name_suffix (char const *, bool); -size_t stripped_path_len (char const *file_name, size_t num); +size_t stripped_prefix_len (char const *file_name, size_t num); bool all_names_found (struct tar_stat_info *); bool excluded_name (char const *); diff --git a/src/rmt.c b/src/rmt.c index 79a933d..1088fa1 100644 --- a/src/rmt.c +++ b/src/rmt.c @@ -314,7 +314,7 @@ see the file named COPYING for details.")); if (debug_file == 0) { report_numbered_error (errno); - exit (EXIT_FAILURE); + return EXIT_FAILURE; } setbuf (debug_file, 0); } @@ -395,7 +395,7 @@ top: if (c10 / 10 != count || (negative ? c10 < nc : nc < c10)) { report_error_message (N_("Seek offset out of range")); - exit (EXIT_FAILURE); + return EXIT_FAILURE; } count = nc; } @@ -408,7 +408,7 @@ top: case 2: whence = SEEK_END; break; default: report_error_message (N_("Seek direction out of range")); - exit (EXIT_FAILURE); + return EXIT_FAILURE; } count = lseek (tape, count, whence); if (count < 0) @@ -449,7 +449,7 @@ top: DEBUG (_("rmtd: Premature eof\n")); report_error_message (N_("Premature end of file")); - exit (EXIT_FAILURE); /* exit status used to be 2 */ + return EXIT_FAILURE; /* exit status used to be 2 */ } } status = full_write (tape, record_buffer, size); @@ -515,7 +515,7 @@ top: if (c10 / 10 != count || (negative ? c10 < nc : nc < c10)) { report_error_message (N_("Seek offset out of range")); - exit (EXIT_FAILURE); + return EXIT_FAILURE; } count = nc; } @@ -525,7 +525,7 @@ top: if (mtop.mt_count != count) { report_error_message (N_("Seek offset out of range")); - exit (EXIT_FAILURE); + return EXIT_FAILURE; } mtop.mt_op = atoi (operation_string); @@ -559,7 +559,7 @@ top: DEBUG1 (_("rmtd: Garbage command %c\n"), command); report_error_message (N_("Garbage command")); - exit (EXIT_FAILURE); /* exit status used to be 3 */ + return EXIT_FAILURE; /* exit status used to be 3 */ } respond: diff --git a/src/system.c b/src/system.c index 3b82480..37d0496 100644 --- a/src/system.c +++ b/src/system.c @@ -20,6 +20,7 @@ #include "common.h" #include "rmt.h" +#include #if MSDOS diff --git a/src/system.h b/src/system.h index 5420150..561c423 100644 --- a/src/system.h +++ b/src/system.h @@ -339,28 +339,17 @@ extern int errno; size is greater than 512 bytes; so ST_BLKSIZE code below, in preparation for some cleanup in this area, later. */ -/* Get or fake the disk device blocksize. Usually defined by sys/param.h - (if at all). */ - -#if !defined(DEV_BSIZE) && defined(BSIZE) -# define DEV_BSIZE BSIZE -#endif -#if !defined(DEV_BSIZE) && defined(BBSIZE) /* SGI */ -# define DEV_BSIZE BBSIZE -#endif -#ifndef DEV_BSIZE -# define DEV_BSIZE 4096 -#endif - /* Extract or fake data from a `struct stat'. ST_BLKSIZE gives the optimal I/O blocksize for the file, in bytes. Some systems, like Sequents, return st_blksize of 0 on pipes. */ +#define DEFAULT_ST_BLKSIZE 512 + #if !HAVE_ST_BLKSIZE -# define ST_BLKSIZE(Statbuf) DEV_BSIZE +# define ST_BLKSIZE(Statbuf) DEFAULT_ST_BLKSIZE #else # define ST_BLKSIZE(Statbuf) \ - ((Statbuf).st_blksize > 0 ? (Statbuf).st_blksize : DEV_BSIZE) + ((Statbuf).st_blksize > 0 ? (Statbuf).st_blksize : DEFAULT_ST_BLKSIZE) #endif /* Extract or fake data from a `struct stat'. ST_NBLOCKS gives the @@ -522,5 +511,3 @@ time_t time (); #if XENIX # include #endif - - diff --git a/src/tar.c b/src/tar.c index b648c8f..f9a3038 100644 --- a/src/tar.c +++ b/src/tar.c @@ -218,7 +218,7 @@ enum USE_COMPRESS_PROGRAM_OPTION, VOLNO_FILE_OPTION, WILDCARDS_OPTION, - WILDCARDS_MATCH_SLASH_OPTION, + WILDCARDS_MATCH_SLASH_OPTION }; /* If nonzero, display usage information and exit. */ @@ -1504,7 +1504,7 @@ main (int argc, char **argv) error (0, 0, _("Error exit delayed from previous errors")); if (ferror (stderr) || fclose (stderr) != 0) exit_status = TAREXIT_FAILURE; - exit (exit_status); + return exit_status; } void