From 27027456b53d4bae60b00fab2f75b3ef602c8f08 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Thu, 24 Oct 2019 10:46:02 +0200 Subject: [PATCH] Simplify, remove gratuitous 'return;' at end of functions + cleanup - Add empty lines for readability, after return before new statement and after variable declarations - Remove explicit typecasting, NULL is NULL regardless of type - Remove unnecessary braces and else Signed-off-by: Joachim Nilsson --- src/klogd.c | 1 + src/ksym.c | 3 --- src/ksym_mod.c | 3 --- src/syslogd.c | 22 +++++++++++----------- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/klogd.c b/src/klogd.c index 8c669a9..1879fbe 100644 --- a/src/klogd.c +++ b/src/klogd.c @@ -830,6 +830,7 @@ static void LogKernelLine(void) if ((rdcnt = ksyslog(2, log_buffer, sizeof(log_buffer) - 1)) < 0) { if (errno == EINTR) return; + fprintf(stderr, "klogd: Error return from sys_sycall: %d - %s\n", errno, strerror(errno)); diff --git a/src/ksym.c b/src/ksym.c index bd12372..4d57d6a 100644 --- a/src/ksym.c +++ b/src/ksym.c @@ -776,7 +776,6 @@ char *ExpandKadds(char *line, char *el) void SetParanoiaLevel(int level) { i_am_paranoid = level; - return; } /* @@ -821,8 +820,6 @@ void Syslog(int priority, char *fmt, ...) vfprintf(stdout, fmt, ap); va_end(ap); fputc('\n', stdout); - - return; } #endif diff --git a/src/ksym_mod.c b/src/ksym_mod.c index 15f094a..edf40cd 100644 --- a/src/ksym_mod.c +++ b/src/ksym_mod.c @@ -285,7 +285,6 @@ static void FreeModules(void) free(sym_array_modules); sym_array_modules = NULL; num_modules = 0; - return; } /************************************************************************** @@ -538,8 +537,6 @@ void Syslog(int priority, char *fmt, ...) vfprintf(stdout, fmt, ap); va_end(ap); fputc('\n', stdout); - - return; } #endif /* TEST */ diff --git a/src/syslogd.c b/src/syslogd.c index 9054af5..b602e81 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -1107,6 +1107,7 @@ int main(int argc, char *argv[]) /* Main loop begins here. */ for (;;) { int nfds; + errno = 0; FD_ZERO(&readfds); maxfds = 0; @@ -1156,8 +1157,8 @@ int main(int argc, char *argv[]) logit("%d ", nfds); logit("\n"); } - nfds = select(maxfds + 1, (fd_set *)&readfds, (fd_set *)NULL, - (fd_set *)NULL, (struct timeval *)NULL); + + nfds = select(maxfds + 1, &readfds, NULL, NULL, NULL); if (restart) { restart = 0; logit("\nReceived SIGHUP, reloading syslogd.\n"); @@ -1173,6 +1174,7 @@ int main(int argc, char *argv[]) #endif continue; } + if (nfds == 0) { logit("No select activity.\n"); continue; @@ -1484,9 +1486,8 @@ char **crunch_list(list) char *list; void untty(void) { - if (!Debug) { + if (!Debug) setsid(); - } } /* @@ -1518,8 +1519,8 @@ void printchopped(const char *hname, char *msg, size_t len, int fd) printline(hname, tmpline); if ((strlen(msg) + 1) == len) return; - else - start = strchr(msg, '\0') + 1; + + start = strchr(msg, '\0') + 1; } } @@ -1544,8 +1545,6 @@ void printchopped(const char *hname, char *msg, size_t len, int fd) printline(hname, start); start = end + 1; } while (*start != '\0'); - - return; } /* @@ -1600,7 +1599,6 @@ void printline(const char *hname, char *msg) *q = '\0'; logmsg(pri, line, hname, SYNC_FILE); - return; } /* @@ -1617,6 +1615,7 @@ void printsys(char *msg) for (p = msg; *p != '\0';) { flags = ADDDATE; pri = DEFSPRI; + if (*p == '<') { pri = 0; while (isdigit(*++p)) @@ -1627,8 +1626,10 @@ void printsys(char *msg) /* kernel printf's come out on console */ flags |= IGN_CONS; } + if (pri & ~(LOG_FACMASK | LOG_PRIMASK)) pri = DEFSPRI; + q = lp; while (*p != '\0' && (c = *p++) != '\n' && q < &line[MAXLINE]) @@ -1636,7 +1637,6 @@ void printsys(char *msg) *q = '\0'; logmsg(pri, line, LocalHostName, flags); } - return; } /* @@ -2180,9 +2180,9 @@ void fprintlog(struct filed *f, char *from, int flags, char *msg) wallmsg(f, iov); break; } /* switch */ + if (f->f_type != F_FORW_UNKN) f->f_prevcount = 0; - return; } jmp_buf ttybuf;