From a0915fc803766d83d7f89e9c4097c416a6366904 Mon Sep 17 00:00:00 2001 From: Bogomil Vasilev Date: Wed, 21 Jun 2017 11:52:34 +0300 Subject: [PATCH] More checkpatch.pl happiness --- agent_pool.c | 8 +++++--- confparser.c | 24 ++++++++++++++++-------- rmps.c | 6 +++--- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/agent_pool.c b/agent_pool.c index b3e8533..b0a4a5b 100644 --- a/agent_pool.c +++ b/agent_pool.c @@ -73,7 +73,8 @@ static void *servlet(void *args) /* Serve the connection -- threadable */ /* TODO: Insert msg handler here */ continue; } - if (SSL_get_shutdown(agent->ssl) == SSL_RECEIVED_SHUTDOWN) + if (SSL_get_shutdown(agent->ssl) + == SSL_RECEIVED_SHUTDOWN) log(VERBOSE, "SSL_RECEIVED_SHUTDOWN from agent [%s]", agent->ip); @@ -84,7 +85,8 @@ static void *servlet(void *args) /* Serve the connection -- threadable */ //log_ssl(); sprintf((char *)buf.chunk.data, "%s", "Where's the data, m8?"); - SSL_write(agent->ssl, &buf, sizeof(struct msg_t)); + SSL_write(agent->ssl, &buf, + sizeof(struct msg_t)); } log(INFO, "Agent [%s] disconnected.", agent->ip); } while (bytes); @@ -111,7 +113,7 @@ void *agent_pool(void *args) pthread_t *agent_thread = (pthread_t *)malloc(pool->size * sizeof(pthread_t)); struct agent_args *agent_struct = - (struct agent_args *)malloc(pool->size * sizeof(struct agent_args)); + malloc(pool->size * sizeof(struct agent_args)); int i; memset(agent_thread, 0, sizeof(pthread_t) * pool->size); diff --git a/confparser.c b/confparser.c index ecafdcd..b7353bf 100644 --- a/confparser.c +++ b/confparser.c @@ -214,13 +214,15 @@ static int test_conf_syntax(void) while (fgets(buf, CFGLINESIZE, fp) != NULL) { j++; /* kill comments and ignore BLANK lines */ - if ((tmp = strstr(buf, "#"))) + tmp = strstr(buf, "#"); + if (tmp) *tmp = '\0'; if (buf[strspn(buf, " \t\v\r\n")] == '\0') continue; /* If we have "=", it's a possible var */ - if ((tmp = strstr(buf, "="))) + tmp = strstr(buf, "="); + if (tmp) *tmp = '\0'; else { log(ERROR, @@ -258,8 +260,10 @@ static int test_conf_syntax(void) /* Just save it, launch_rmps will check it */ strcpy(conf.db.hostname, tmp + 1); else if (!strcmp(buf, "db.port")) { - if ((i = strlen(tmp + 1)) < 6) { - if ((signed int)strspn(tmp + 1, "1234567890") == i) { + i = strlen(tmp + 1); + if (i < 6) { /* max 5 digits for network port */ + if ((signed int)strspn(tmp + 1, + "1234567890") == i) { i = atoi(tmp + 1); if (i > 0 && i < 65536) { strcpy(conf.db.port, tmp + 1); @@ -274,8 +278,10 @@ static int test_conf_syntax(void) else if (!strcmp(buf, "rmps.agent_ip")) { /* TODO */ } else if (!strcmp(buf, "rmps.agent_port")) { - if ((i = strlen(tmp + 1)) < 6) { - if ((signed int)strspn(tmp + 1, "1234567890") == i) { + i = strlen(tmp + 1); + if (i < 6) { /* max 5 digits for network port */ + if ((signed int)strspn(tmp + 1, + "1234567890") == i) { i = atoi(tmp + 1); if (i > 0 && i < 65536) { strcpy(conf.rmps.agent_port, @@ -289,8 +295,10 @@ static int test_conf_syntax(void) } else if (!strcmp(buf, "rmps.client_ip")) { /* TODO */ } else if (!strcmp(buf, "rmps.client_port")) { - if ((i = strlen(tmp + 1)) < 6) { - if ((signed int)strspn(tmp + 1, "1234567890") == i) { + i = strlen(tmp + 1); + if (i < 6) { /* max 5 digits for network port */ + if ((signed int)strspn(tmp + 1, + "1234567890") == i) { i = atoi(tmp + 1); if (i > 0 && i < 65536) { strcpy(conf.rmps.client_port, diff --git a/rmps.c b/rmps.c index 3510037..7c7577d 100644 --- a/rmps.c +++ b/rmps.c @@ -187,8 +187,7 @@ static int open_listener(int port) goto exit; } if (listen(sd, 10) != 0) { - log(ERROR, - "Failed to start listener on port %d - Aborting...", + log(ERROR, "Failed to start listener on port %d - Aborting...", port); goto exit; } @@ -307,7 +306,8 @@ void launch_rmps(struct conf_table *conf, int fork_flag) log(VERBOSE, "Creating client thread pool (mutex)."); pthread_create(&pool[1], NULL, client_pool, &pool_args[1]); if (start_job_queue(conf->rmps.agent_poolsize) == FAIL) { - log(ERROR, "On start_job_queue(), RMPS failed to start, shutting down..."); + log(ERROR, + "On start_job_queue(), RMPS failed to start, shutting down..."); atexit(cleanup); return; }