Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/newsyslog/newsyslog.c
Show First 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | |||||
#define CE_GLOB 0x0040 /* name of the log is file name pattern. */ | #define CE_GLOB 0x0040 /* name of the log is file name pattern. */ | ||||
#define CE_SIGNALGROUP 0x0080 /* Signal a process-group instead of a single */ | #define CE_SIGNALGROUP 0x0080 /* Signal a process-group instead of a single */ | ||||
/* process when trimming this file. */ | /* process when trimming this file. */ | ||||
#define CE_CREATE 0x0100 /* Create the log file if it does not exist. */ | #define CE_CREATE 0x0100 /* Create the log file if it does not exist. */ | ||||
#define CE_NODUMP 0x0200 /* Set 'nodump' on newly created log file. */ | #define CE_NODUMP 0x0200 /* Set 'nodump' on newly created log file. */ | ||||
#define CE_PID2CMD 0x0400 /* Replace PID file with a shell command.*/ | #define CE_PID2CMD 0x0400 /* Replace PID file with a shell command.*/ | ||||
#define CE_PLAIN0 0x0800 /* Do not compress zero'th history file */ | #define CE_PLAIN0 0x0800 /* Do not compress zero'th history file */ | ||||
#define CE_RFC5424 0x1000 /* Use RFC5424 format rotation message */ | #define CE_RFC5424 0x1000 /* Use RFC5424 format rotation message */ | ||||
#define CE_NOEMPTY 0x2000 /* Do not rotate the file when its size */ | |||||
/* is zero */ | |||||
#define MIN_PID 5 /* Don't touch pids lower than this */ | #define MIN_PID 5 /* Don't touch pids lower than this */ | ||||
#define MAX_PID 99999 /* was lower, see /usr/include/sys/proc.h */ | #define MAX_PID 99999 /* was lower, see /usr/include/sys/proc.h */ | ||||
#define kbytes(size) (((size) + 1023) >> 10) | #define kbytes(size) (((size) + 1023) >> 10) | ||||
#define DEFAULT_MARKER "<default>" | #define DEFAULT_MARKER "<default>" | ||||
#define DEBUG_MARKER "<debug>" | #define DEBUG_MARKER "<debug>" | ||||
#define INCLUDE_MARKER "<include>" | #define INCLUDE_MARKER "<include>" | ||||
▲ Show 20 Lines • Show All 400 Lines • ▼ Show 20 Lines | if (ent->fsize < 0) { | ||||
if (ent->firstcreate) { | if (ent->firstcreate) { | ||||
if (verbose) | if (verbose) | ||||
printf("does not exist -> will create.\n"); | printf("does not exist -> will create.\n"); | ||||
createlog(ent); | createlog(ent); | ||||
} else if (verbose) { | } else if (verbose) { | ||||
printf("does not exist, skipped%s.\n", temp_reason); | printf("does not exist, skipped%s.\n", temp_reason); | ||||
} | } | ||||
} else { | } else { | ||||
if (ent->flags & CE_NOEMPTY && ent->fsize == 0) { | |||||
markj: The parentheses around `(ent->fsize == 0)` are redundant. | |||||
if (verbose) | |||||
printf("--> Not rotating empty file\n"); | |||||
return (free_or_keep); | |||||
} | |||||
if (ent->flags & CE_TRIMAT && !force && !rotatereq && | if (ent->flags & CE_TRIMAT && !force && !rotatereq && | ||||
!oversized) { | !oversized) { | ||||
diffsecs = ptimeget_diff(timenow, ent->trim_at); | diffsecs = ptimeget_diff(timenow, ent->trim_at); | ||||
if (diffsecs < 0.0) { | if (diffsecs < 0.0) { | ||||
/* trim_at is some time in the future. */ | /* trim_at is some time in the future. */ | ||||
if (verbose) { | if (verbose) { | ||||
ptime_adjust4dst(ent->trim_at, | ptime_adjust4dst(ent->trim_at, | ||||
timenow); | timenow); | ||||
▲ Show 20 Lines • Show All 743 Lines • ▼ Show 20 Lines | for (; q && *q && !isspacech(*q); q++) { | ||||
case 'b': | case 'b': | ||||
working->flags |= CE_BINARY; | working->flags |= CE_BINARY; | ||||
break; | break; | ||||
case 'c': | case 'c': | ||||
working->flags |= CE_CREATE; | working->flags |= CE_CREATE; | ||||
break; | break; | ||||
case 'd': | case 'd': | ||||
working->flags |= CE_NODUMP; | working->flags |= CE_NODUMP; | ||||
break; | |||||
case 'e': | |||||
Done Inline ActionsThe description and manpage say E, but you're checking for e. rpokala: The description and manpage say `E`, but you're checking for `e`. | |||||
Done Inline Actions
There is switch (tolowerch(*q)) so yes, e is apropriate. otis: > The description and manpage say `E`, but you're checking for `e`.
There is `switch… | |||||
Not Done Inline ActionsUgh, it is! That's
Bearing that in mind, LGTM. rpokala: Ugh, it //is//! That's
# Gross 🤮
# Not your fault 😜
Bearing that in mind, LGTM. | |||||
working->flags |= CE_NOEMPTY; | |||||
break; | break; | ||||
case 'g': | case 'g': | ||||
working->flags |= CE_GLOB; | working->flags |= CE_GLOB; | ||||
break; | break; | ||||
case 'j': | case 'j': | ||||
working->compress = COMPRESS_BZIP2; | working->compress = COMPRESS_BZIP2; | ||||
break; | break; | ||||
case 'n': | case 'n': | ||||
▲ Show 20 Lines • Show All 1,492 Lines • Show Last 20 Lines |
The parentheses around (ent->fsize == 0) are redundant.