From c0086a8509425f74c25b6c1cdf06148468438cbd Mon Sep 17 00:00:00 2001 From: Bogomil Vasilev Date: Wed, 9 Jan 2019 23:58:59 +0200 Subject: [PATCH] checkpatch fixes --- src/confparser.h | 2 +- src/log.c | 6 ++++-- src/main.c | 12 ++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/confparser.h b/src/confparser.h index e169bdd..a4edd42 100644 --- a/src/confparser.h +++ b/src/confparser.h @@ -66,7 +66,7 @@ struct conf_table { }; extern struct conf_table conf; -extern int confparse(char *); +extern int confparse(char *config); extern void confexport(void); extern const char *conf_db_pass(void); extern const char *conf_db_hostname(void); diff --git a/src/log.c b/src/log.c index b1c5dd7..2a4102a 100644 --- a/src/log.c +++ b/src/log.c @@ -34,11 +34,13 @@ static pthread_once_t init_once = PTHREAD_ONCE_INIT; static void open_logs(void) { - if ((fderr = fopen(conf.rmps.errlog, "a")) == NULL) + fderr = fopen(conf.rmps.errlog, "a"); + if (fderr == NULL) fderr = stderr; else setvbuf(fderr, NULL, _IOLBF, 0); - if ((fdout = fopen(conf.rmps.logfile, "a")) == NULL) + fdout = fopen(conf.rmps.logfile, "a"); + if (fdout == NULL) fdout = stdout; else setvbuf(fdout, NULL, _IOLBF, 0); diff --git a/src/main.c b/src/main.c index 3409cc6..8e22057 100644 --- a/src/main.c +++ b/src/main.c @@ -34,7 +34,7 @@ static void usage(char *argv) { fprintf(stderr, "Usage:\n%s TASK [-c CONFIG] [-d]\n\n" "Tasks:\n" - "\t--start\t\tStart the RMPS server. This is by default. \n" + "\t--start\t\tStart the RMPS server. This is by default.\n" "\t--stop\t\tStop the RMPS server.\n" "\t--restart\tRestart the RMPS server.\n" "\t-t, --test\tTest the configuration file and exit,\n" @@ -60,9 +60,8 @@ int main(int argc, char *argv[]) TEST_AND_EXPORT }; static int task = START; - const char opts_short[] = "dc:htT"; - static struct option opts_long[] = - { + static const char opts_short[] = "dc:htT"; + static struct option opts_long[] = { {"start", no_argument, &task, START}, {"stop", no_argument, &task, STOP}, {"restart", no_argument, &task, RESTART}, @@ -74,13 +73,13 @@ int main(int argc, char *argv[]) }; int opt = 0, opt_index = 0, fork_flag = 0; char *config = NULL; + while ((opt = getopt_long(argc, argv, opts_short, opts_long, &opt_index)) != -1) { switch (opt) { case 0: - if (opts_long[opt_index].flag != 0) { + if (opts_long[opt_index].flag != 0) break; - } log(INFO, "option %s", opts_long[opt_index].name); if (optarg) log(INFO, "with arg %s\n", optarg); @@ -109,6 +108,7 @@ int main(int argc, char *argv[]) if (!config) { char path[] = "/etc/rmps/rmps.conf"; int path_size = strlen(path) + 1; + config = calloc(sizeof(char), path_size); if (config == NULL) { log(ERROR, "malloc() failed for config");