Refctor, simplify return statements, no parenthesis needed

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2018-08-05 18:59:33 +02:00
parent f1f1ee3563
commit 2e84a34758
7 changed files with 58 additions and 58 deletions

View File

@ -501,7 +501,7 @@ static enum LOGSRC GetKernelLogSrc(void)
Syslog(LOG_INFO, "klogd v%s, log source = ksyslog "
"started.",
PACKAGE_VERSION);
return (kernel);
return kernel;
}
#ifndef TESTING
@ -518,7 +518,7 @@ static enum LOGSRC GetKernelLogSrc(void)
Syslog(LOG_INFO, "klogd v%s, log source = %s started.",
VERSION, _PATH_KLOG);
return (proc);
return proc;
}
extern void Syslog(int priority, char *fmt, ...)
@ -613,7 +613,7 @@ static int copyin(char *line, int space,
for (i = 0; i < count && !strchr(delim, *ptr); i++)
*line++ = *ptr++;
return (i);
return i;
}
/*
@ -933,11 +933,11 @@ int main(int argc, char *argv[])
case 'i': /* Reload module symbols. */
SignalDaemon(SIGUSR1);
return (0);
return 0;
case 'I':
SignalDaemon(SIGUSR2);
return (0);
return 0;
case 'k': /* Kernel symbol file. */
symfile = optarg;
@ -984,7 +984,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "klogd: Invalid console logging "
"level <%s> specified.\n",
log_level);
return (1);
return 1;
}
console_log_level = *log_level - '0';
}
@ -1065,7 +1065,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "klogd: Cannot open output file "
"%s - %s\n",
output, strerror(errno));
return (1);
return 1;
}
} else
openlog("kernel", 0, LOG_KERN);

View File

@ -201,7 +201,7 @@ int InitKsyms(char *mapfile)
Syslog(LOG_WARNING, "Cannot find a map file.");
if (debugging)
fputs("Cannot find a map file.\n", stderr);
return (0);
return 0;
}
}
@ -209,7 +209,7 @@ int InitKsyms(char *mapfile)
Syslog(LOG_WARNING, "Cannot open map file: %s.", mapfile);
if (debugging)
fprintf(stderr, "Cannot open map file: %s.\n", mapfile);
return (0);
return 0;
}
/*
@ -224,7 +224,7 @@ int InitKsyms(char *mapfile)
if (fscanf(sym_file, "%lx %c %511s\n", &address, &type, sym) != 3) {
Syslog(LOG_ERR, "Error in symbol table input (#1).");
fclose(sym_file);
return (0);
return 0;
}
if (VERBOSE_DEBUGGING && debugging)
fprintf(stderr, "Address: %lx, Type: %c, Symbol: %s\n",
@ -233,7 +233,7 @@ int InitKsyms(char *mapfile)
if (AddSymbol(address, sym) == 0) {
Syslog(LOG_ERR, "Error adding symbol - %s.", sym);
fclose(sym_file);
return (0);
return 0;
}
if (version == 0)
@ -258,7 +258,7 @@ int InitKsyms(char *mapfile)
}
fclose(sym_file);
return (1);
return 1;
}
/**************************************************************************
@ -303,7 +303,7 @@ static char *FindSymbolFile(void)
if (uname(&utsname) < 0) {
Syslog(LOG_ERR, "Cannot get kernel version information.");
return (0);
return 0;
}
if (debugging)
@ -337,7 +337,7 @@ static char *FindSymbolFile(void)
*/
if (debugging)
fprintf(stderr, "End of search list encountered.\n");
return (file);
return file;
}
/**************************************************************************
@ -394,7 +394,7 @@ static int CheckVersion(char *version)
strncmp(++version, prefix, strlen(prefix)) == 0) /* a.out */)
;
else
return (0);
return 0;
/*
* Since the symbol looks like a kernel version we can start
@ -424,7 +424,7 @@ static int CheckVersion(char *version)
*/
if (uname(&utsname) < 0) {
Syslog(LOG_ERR, "Cannot get kernel version information.");
return (0);
return 0;
}
if (debugging)
fprintf(stderr, "Comparing kernel %s with symbol table %s.\n",
@ -433,7 +433,7 @@ static int CheckVersion(char *version)
if (sscanf(utsname.release, "%d.%d.%d", &major, &minor, &patch) < 3) {
Syslog(LOG_ERR, "Kernel send bogus release string `%s'.",
utsname.release);
return (0);
return 0;
}
/* Compute the version code from data sent by the kernel */
@ -441,11 +441,11 @@ static int CheckVersion(char *version)
/* Failure. */
if (vnum != kvnum)
return (-1);
return -1;
/* Success. */
#endif
return (1);
return 1;
}
/**************************************************************************
@ -494,7 +494,7 @@ static int CheckMapVersion(char *fname)
&type, sym) != 3) {
Syslog(LOG_ERR, "Error in symbol table input (#2).");
fclose(sym_file);
return (0);
return 0;
}
if (VERBOSE_DEBUGGING && debugging)
fprintf(stderr, "Address: %lx, Type: %c, "
@ -523,10 +523,10 @@ static int CheckMapVersion(char *fname)
break;
}
return (version);
return version;
}
return (0);
return 0;
}
/**************************************************************************
@ -547,17 +547,17 @@ static int AddSymbol(unsigned long address, char *symbol)
/* Allocate the the symbol table entry. */
sym_array = realloc(sym_array, (num_syms + 1) * sizeof(struct sym_table));
if (sym_array == NULL)
return (0);
return 0;
/* Then the space for the symbol. */
sym_array[num_syms].name = malloc(strlen(symbol) * sizeof(char) + 1);
if (sym_array[num_syms].name == NULL)
return (0);
return 0;
sym_array[num_syms].value = address;
strcpy(sym_array[num_syms].name, symbol);
++num_syms;
return (1);
return 1;
}
/**************************************************************************
@ -587,13 +587,13 @@ char *LookupSymbol(unsigned long value, struct symbol *sym)
int lp;
if (!sym_array)
return ((char *)0);
return NULL;
last = sym_array[0].name;
ksym.offset = 0;
ksym.size = 0;
if (value < sym_array[0].value)
return ((char *)0);
return NULL;
for (lp = 0; lp <= num_syms; ++lp) {
if (sym_array[lp].value > value) {
@ -615,11 +615,11 @@ char *LookupSymbol(unsigned long value, struct symbol *sym)
(ksym.offset > 0 && ksym.offset < msym.offset)) {
sym->offset = ksym.offset;
sym->size = ksym.size;
return (last);
return last;
} else {
sym->offset = msym.offset;
sym->size = msym.size;
return (name);
return name;
}
return NULL;
@ -712,7 +712,7 @@ char *ExpandKadds(char *line, char *el)
if ((num_syms == 0) ||
(kp = strstr(line, "[<")) == (char *)0) {
strcpy(el, line);
return (el);
return el;
}
/* Loop through and expand all kernel messages. */
@ -723,7 +723,7 @@ char *ExpandKadds(char *line, char *el)
/* Now poised at a kernel delimiter. */
if ((kp = strstr(sl, ">]")) == (char *)0) {
strcpy(el, sl);
return (el);
return el;
}
dlm = *kp;
strncpy(num, sl + 1, kp - sl - 1);
@ -755,7 +755,7 @@ char *ExpandKadds(char *line, char *el)
if (debugging)
fprintf(stderr, "Expanded line: %s\n", el);
return (el);
return el;
}
/**************************************************************************
@ -795,7 +795,7 @@ int main(int argc, char *argv[])
if (!InitKsyms((char *)0)) {
fputs("ksym: Error loading system map.\n", stderr);
return (1);
return 1;
}
while (!feof(stdin)) {
@ -807,7 +807,7 @@ int main(int argc, char *argv[])
fprintf(stdout, "%s\n", eline);
}
return (0);
return 0;
}
void Syslog(int priority, char *fmt, ...)

View File

@ -185,7 +185,7 @@ extern int InitMsyms(void)
Syslog(LOG_ERR, "Error loading kernel symbols "
"- %s\n",
strerror(errno));
return (0);
return 0;
}
if (debugging)
@ -230,7 +230,7 @@ extern int InitMsyms(void)
(rtn == 1) ? "symbol" : "symbols",
num_modules, (num_modules == 1) ? "." : "s.");
return (1);
return 1;
}
static int symsort(const void *p1, const void *p2)
@ -239,12 +239,12 @@ static int symsort(const void *p1, const void *p2)
*sym2 = p2;
if (sym1->value < sym2->value)
return (-1);
return -1;
if (sym1->value == sym2->value)
return (0);
return 0;
return (1);
return 1;
}
/**************************************************************************
@ -381,7 +381,7 @@ static int AddSymbol(const char *line)
p = index(line, ' ');
if (p == NULL)
return (0);
return 0;
*p = '\0';
address = strtoul(line, (char **)0, 16);
@ -395,7 +395,7 @@ static int AddSymbol(const char *line)
mp = AddModule(module);
if (mp == NULL)
return (0);
return 0;
} else
mp = &sym_array_modules[num_modules - 1];
@ -406,17 +406,17 @@ static int AddSymbol(const char *line)
(mp->num_syms + 1) * sizeof(struct sym_table));
if (mp->sym_array == (struct sym_table *)0)
return (0);
return 0;
mp->sym_array[mp->num_syms].name = strdup(p);
if (mp->sym_array[mp->num_syms].name == (char *)0)
return (0);
return 0;
/* Stuff interesting information into the module. */
mp->sym_array[mp->num_syms].value = address;
++mp->num_syms;
return (1);
return 1;
}
/**************************************************************************
@ -484,7 +484,7 @@ char *LookupModuleSymbol(unsigned long value, struct symbol *sym)
}
if (sym->size > 0)
return (ret);
return ret;
/* It has been a hopeless exercise. */
return NULL;
@ -505,7 +505,7 @@ int main(int argc, char *argv[])
if (!InitMsyms()) {
fprintf(stderr, "Cannot load module symbols.\n");
return (1);
return 1;
}
printf("Number of modules: %d\n\n", num_modules);
@ -527,7 +527,7 @@ int main(int argc, char *argv[])
}
FreeModules();
return (0);
return 0;
}
void Syslog(int priority, char *fmt, ...)

View File

@ -75,7 +75,7 @@ int check_pid(char *pidfile)
*/
/* But... errno is usually changed only on error.. */
if (kill(pid, 0) && errno == ESRCH)
return (0);
return 0;
return pid;
}

View File

@ -248,7 +248,7 @@ int setlogmask(int pmask)
omask = LogMask;
if (pmask != 0)
LogMask = pmask;
return (omask);
return omask;
}
/**

View File

@ -58,10 +58,10 @@ int main(int argc, char *argv[])
syslog(LOG_INFO, "Info log.");
syslog(LOG_DEBUG, "Debug log.");
closelog();
return (0);
return 0;
}
return (0);
return 0;
}
/**

View File

@ -2305,14 +2305,14 @@ const char *cvthname(struct sockaddr_storage *f, int len)
if ((p = strchr(hname, '.'))) {
if (strcmp(p + 1, LocalDomain) == 0) {
*p = '\0';
return (hname);
return hname;
} else {
if (StripDomains) {
count = 0;
while (StripDomains[count]) {
if (strcmp(p + 1, StripDomains[count]) == 0) {
*p = '\0';
return (hname);
return hname;
}
count++;
}
@ -2322,7 +2322,7 @@ const char *cvthname(struct sockaddr_storage *f, int len)
while (LocalHosts[count]) {
if (!strcmp(hname, LocalHosts[count])) {
*p = '\0';
return (hname);
return hname;
}
count++;
}
@ -2330,7 +2330,7 @@ const char *cvthname(struct sockaddr_storage *f, int len)
}
}
return (hname);
return hname;
}
void domark(int signo)
@ -2971,7 +2971,7 @@ int decode(char *name, struct code *codetab)
logit("symbolic name: %s", name);
if (isdigit(*name)) {
logit("\n");
return (atoi(name));
return atoi(name);
}
(void)strncpy(buf, name, 79);
for (p = buf; *p; p++)
@ -2980,9 +2980,9 @@ int decode(char *name, struct code *codetab)
for (c = codetab; c->c_name; c++)
if (!strcmp(buf, c->c_name)) {
logit(" ==> %d\n", c->c_val);
return (c->c_val);
return c->c_val;
}
return (-1);
return -1;
}
static void logit(char *fmt, ...)