Fix some C compatibility bugs reported by Joerg Schilling.

This commit is contained in:
Paul Eggert
2003-11-13 06:23:23 +00:00
parent 182091e79f
commit 572225dfdc
6 changed files with 32 additions and 27 deletions

View File

@@ -1,3 +1,20 @@
2003-11-12 Paul Eggert <eggert@twinsun.com>
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 <gray@Mirddin.farlep.net>
* src/list.c (decode_header): Initialize st_atime and

View File

@@ -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 *);

View File

@@ -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:

View File

@@ -20,6 +20,7 @@
#include "common.h"
#include "rmt.h"
#include <signal.h>
#if MSDOS

View File

@@ -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 <sys/inode.h>
#endif

View File

@@ -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