static void setup_output()
{
- if (g_output_filename == NULL) {
- g_outfd = STDOUT_FILENO;
-
- } else {
- struct stat statbuf;
-
- g_outfd = open_logfile (g_output_filename);
+ if (g_output_filename == NULL) {
+ g_outfd = STDOUT_FILENO;
- if (g_outfd < 0) {
- perror ("couldn't open output file");
- exit(-1);
- }
+ } else {
+ struct stat statbuf;
- fstat(g_outfd, &statbuf);
+ g_outfd = open_logfile (g_output_filename);
- g_out_byte_count = statbuf.st_size;
- }
+ if (g_outfd < 0) {
+ perror ("couldn't open output file");
+ exit(-1);
+ }
+ if (fstat(g_outfd, &statbuf) == -1)
+ g_out_byte_count = 0;
+ else
+ g_out_byte_count = statbuf.st_size;
+ }
}
static int set_log_format(const char * formatString)
case 'b': {
char *buf;
- if (asprintf(&buf, LOG_FILE_DIR "/%s", optarg) == -1) {
+ if (asprintf(&buf, LOG_FILE_DIR "%s", optarg) == -1) {
asprintf(stderr,"Can't malloc LOG_FILE_DIR\n");
exit(-1);
}