|
|
ad0d7c |
From 99ad17d4906f478c51b58ab8f288edbca0bab906 Mon Sep 17 00:00:00 2001
|
|
|
ad0d7c |
From: YAMAMOTO Masaya <pandax381@gmail.com>
|
|
|
ad0d7c |
Date: Fri, 14 Jul 2017 14:34:28 +0900
|
|
|
ad0d7c |
Subject: [PATCH 6/8] Fix to match coding style
|
|
|
ad0d7c |
|
|
|
ad0d7c |
---
|
|
|
ad0d7c |
keepalived/check/check_api.c | 22 ++++++++++------------
|
|
|
ad0d7c |
keepalived/check/check_dns.c | 20 +++++++++-----------
|
|
|
ad0d7c |
keepalived/check/check_http.c | 26 ++++++++++++--------------
|
|
|
ad0d7c |
keepalived/check/check_misc.c | 18 ++++++++----------
|
|
|
ad0d7c |
keepalived/check/check_smtp.c | 26 ++++++++++++--------------
|
|
|
ad0d7c |
keepalived/check/check_tcp.c | 18 ++++++++----------
|
|
|
ad0d7c |
keepalived/include/check_api.h | 6 +++---
|
|
|
ad0d7c |
7 files changed, 62 insertions(+), 74 deletions(-)
|
|
|
ad0d7c |
|
|
|
ad0d7c |
diff --git a/keepalived/check/check_api.c b/keepalived/check/check_api.c
|
|
|
ad0d7c |
index a722fc84..1d915414 100644
|
|
|
ad0d7c |
--- a/keepalived/check/check_api.c
|
|
|
ad0d7c |
+++ b/keepalived/check/check_api.c
|
|
|
ad0d7c |
@@ -81,7 +81,7 @@ dump_conn_opts(void *data)
|
|
|
ad0d7c |
void
|
|
|
ad0d7c |
queue_checker(void (*free_func) (void *), void (*dump_func) (void *)
|
|
|
ad0d7c |
, int (*launch) (thread_t *)
|
|
|
ad0d7c |
- , int (*compare) (void *, void *)
|
|
|
ad0d7c |
+ , bool (*compare) (void *, void *)
|
|
|
ad0d7c |
, void *data
|
|
|
ad0d7c |
, conn_opts_t *co)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
@@ -120,28 +120,26 @@ queue_checker(void (*free_func) (void *), void (*dump_func) (void *)
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
-int
|
|
|
ad0d7c |
+bool
|
|
|
ad0d7c |
compare_conn_opts(conn_opts_t *a, conn_opts_t *b)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
if (a == b)
|
|
|
ad0d7c |
- return 0;
|
|
|
ad0d7c |
+ return true;
|
|
|
ad0d7c |
|
|
|
ad0d7c |
if (!a || !b)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (!sockstorage_equal(&a->dst, &b->dst))
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (!sockstorage_equal(&a->bindto, &b->bindto))
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
- //if (a->connection_to != b->connection_to)
|
|
|
ad0d7c |
- // goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
+ if (a->connection_to != b->connection_to)
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
#ifdef _WITH_SO_MARK_
|
|
|
ad0d7c |
if (a->fwmark != b->fwmark)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
#endif
|
|
|
ad0d7c |
|
|
|
ad0d7c |
- return 0;
|
|
|
ad0d7c |
-err:
|
|
|
ad0d7c |
- return -1;
|
|
|
ad0d7c |
+ return true;
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
diff --git a/keepalived/check/check_dns.c b/keepalived/check/check_dns.c
|
|
|
ad0d7c |
index 84a5f56d..603742a4 100644
|
|
|
ad0d7c |
--- a/keepalived/check/check_dns.c
|
|
|
ad0d7c |
+++ b/keepalived/check/check_dns.c
|
|
|
ad0d7c |
@@ -388,24 +388,22 @@ dns_dump(void *data)
|
|
|
ad0d7c |
log_message(LOG_INFO, " Name = %s", dns_check->name);
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
-static int
|
|
|
ad0d7c |
-dns_compare(void *a, void *b)
|
|
|
ad0d7c |
+static bool
|
|
|
ad0d7c |
+dns_check_compare(void *a, void *b)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
dns_check_t *old = CHECKER_DATA(a);
|
|
|
ad0d7c |
dns_check_t *new = CHECKER_DATA(b);
|
|
|
ad0d7c |
|
|
|
ad0d7c |
- if (compare_conn_opts(CHECKER_CO(a), CHECKER_CO(b)) != 0)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ if (!compare_conn_opts(CHECKER_CO(a), CHECKER_CO(b)))
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (old->retry != new->retry)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (strcmp(old->type, new->type) != 0)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (strcmp(old->name, new->name) != 0)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
|
|
|
ad0d7c |
- return 0;
|
|
|
ad0d7c |
-err:
|
|
|
ad0d7c |
- return -1;
|
|
|
ad0d7c |
+ return true;
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
@@ -417,7 +415,7 @@ dns_check_handler(__attribute__((unused)) vector_t * strvec)
|
|
|
ad0d7c |
dns_check->type = DNS_DEFAULT_TYPE;
|
|
|
ad0d7c |
dns_check->name = DNS_DEFAULT_NAME;
|
|
|
ad0d7c |
queue_checker(dns_free, dns_dump, dns_connect_thread,
|
|
|
ad0d7c |
- dns_compare, dns_check, CHECKER_NEW_CO());
|
|
|
ad0d7c |
+ dns_check_compare, dns_check, CHECKER_NEW_CO());
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
diff --git a/keepalived/check/check_http.c b/keepalived/check/check_http.c
|
|
|
ad0d7c |
index c2089a3b..1ad395cf 100644
|
|
|
ad0d7c |
--- a/keepalived/check/check_http.c
|
|
|
ad0d7c |
+++ b/keepalived/check/check_http.c
|
|
|
ad0d7c |
@@ -123,36 +123,34 @@ alloc_http_get(char *proto)
|
|
|
ad0d7c |
return http_get_chk;
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
-static int
|
|
|
ad0d7c |
-compare_http_get_check(void *a, void *b)
|
|
|
ad0d7c |
+static bool
|
|
|
ad0d7c |
+http_get_check_compare(void *a, void *b)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
http_checker_t *old = CHECKER_DATA(a);
|
|
|
ad0d7c |
http_checker_t *new = CHECKER_DATA(b);
|
|
|
ad0d7c |
size_t n;
|
|
|
ad0d7c |
url_t *u1, *u2;
|
|
|
ad0d7c |
|
|
|
ad0d7c |
- if (compare_conn_opts(CHECKER_CO(a), CHECKER_CO(b)) != 0)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ if (!compare_conn_opts(CHECKER_CO(a), CHECKER_CO(b)))
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (old->nb_get_retry != new->nb_get_retry)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (old->delay_before_retry != new->delay_before_retry)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (LIST_SIZE(old->url) != LIST_SIZE(new->url))
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
for (n = 0; n < LIST_SIZE(new->url); n++) {
|
|
|
ad0d7c |
u1 = (url_t *)list_element(old->url, n);
|
|
|
ad0d7c |
u2 = (url_t *)list_element(new->url, n);
|
|
|
ad0d7c |
if (strcmp(u1->path, u2->path) != 0)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (strcmp(u1->digest, u2->digest) != 0)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (u1->status_code != u2->status_code)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
- return 0;
|
|
|
ad0d7c |
-err:
|
|
|
ad0d7c |
- return -1;
|
|
|
ad0d7c |
+ return true;
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
@@ -164,7 +162,7 @@ http_get_handler(vector_t *strvec)
|
|
|
ad0d7c |
/* queue new checker */
|
|
|
ad0d7c |
http_get_chk = alloc_http_get(str);
|
|
|
ad0d7c |
queue_checker(free_http_get_check, dump_http_get_check,
|
|
|
ad0d7c |
- http_connect_thread, compare_http_get_check,
|
|
|
ad0d7c |
+ http_connect_thread, http_get_check_compare,
|
|
|
ad0d7c |
http_get_chk, CHECKER_NEW_CO());
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
diff --git a/keepalived/check/check_misc.c b/keepalived/check/check_misc.c
|
|
|
ad0d7c |
index 311a1127..f1f66955 100644
|
|
|
ad0d7c |
--- a/keepalived/check/check_misc.c
|
|
|
ad0d7c |
+++ b/keepalived/check/check_misc.c
|
|
|
ad0d7c |
@@ -72,24 +72,22 @@ dump_misc_check(void *data)
|
|
|
ad0d7c |
log_message(LOG_INFO, " insecure = %s", misck_checker->insecure ? "Yes" : "No");
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
-static int
|
|
|
ad0d7c |
-compare_misc_check(void *a, void *b)
|
|
|
ad0d7c |
+static bool
|
|
|
ad0d7c |
+misc_check_compare(void *a, void *b)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
misc_checker_t *old = CHECKER_DATA(a);
|
|
|
ad0d7c |
misc_checker_t *new = CHECKER_DATA(b);
|
|
|
ad0d7c |
|
|
|
ad0d7c |
if (strcmp(old->path, new->path) != 0)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (old->timeout != new->timeout)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (old->dynamic != new->dynamic)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (old->uid != new->uid || new->gid != new->gid)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
|
|
|
ad0d7c |
- return 0;
|
|
|
ad0d7c |
-err:
|
|
|
ad0d7c |
- return -1;
|
|
|
ad0d7c |
+ return true;
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
@@ -169,7 +167,7 @@ log_message(LOG_INFO, "Setting uid.gid");
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
/* queue new checker */
|
|
|
ad0d7c |
- queue_checker(free_misc_check, dump_misc_check, misc_check_thread, compare_misc_check, misck_checker, NULL);
|
|
|
ad0d7c |
+ queue_checker(free_misc_check, dump_misc_check, misc_check_thread, misc_check_compare, misck_checker, NULL);
|
|
|
ad0d7c |
misck_checker = NULL;
|
|
|
ad0d7c |
log_message(LOG_INFO, "Leaving misc_end_handler");
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
diff --git a/keepalived/check/check_smtp.c b/keepalived/check/check_smtp.c
|
|
|
ad0d7c |
index e19511cc..44d15e01 100644
|
|
|
ad0d7c |
--- a/keepalived/check/check_smtp.c
|
|
|
ad0d7c |
+++ b/keepalived/check/check_smtp.c
|
|
|
ad0d7c |
@@ -82,8 +82,8 @@ dump_smtp_check(void *data)
|
|
|
ad0d7c |
dump_list(smtp_checker->host);
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
-static int
|
|
|
ad0d7c |
-compare_smtp_check(void *a, void *b)
|
|
|
ad0d7c |
+static bool
|
|
|
ad0d7c |
+smtp_check_compare(void *a, void *b)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
smtp_checker_t *old = CHECKER_DATA(a);
|
|
|
ad0d7c |
smtp_checker_t *new = CHECKER_DATA(b);
|
|
|
ad0d7c |
@@ -91,26 +91,24 @@ compare_smtp_check(void *a, void *b)
|
|
|
ad0d7c |
smtp_host_t *h1, *h2;
|
|
|
ad0d7c |
|
|
|
ad0d7c |
if (strcmp(old->helo_name, new->helo_name) != 0)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (old->retry != new->retry)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (old->db_retry != new->db_retry)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
- if (compare_conn_opts(CHECKER_CO(a), CHECKER_CO(b)) != 0)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
+ if (!compare_conn_opts(CHECKER_CO(a), CHECKER_CO(b)))
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (LIST_SIZE(old->host) != LIST_SIZE(new->host))
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
for (n = 0; n < LIST_SIZE(new->host); n++) {
|
|
|
ad0d7c |
h1 = (smtp_host_t *)list_element(old->host, n);
|
|
|
ad0d7c |
h2 = (smtp_host_t *)list_element(new->host, n);
|
|
|
ad0d7c |
- if (compare_conn_opts(h1, h2) != 0) {
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ if (!compare_conn_opts(h1, h2)) {
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
- return 0;
|
|
|
ad0d7c |
-err:
|
|
|
ad0d7c |
- return -1;
|
|
|
ad0d7c |
+ return true;
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
/* Allocates a default host structure */
|
|
|
ad0d7c |
@@ -167,7 +165,7 @@ smtp_check_handler(__attribute__((unused)) vector_t *strvec)
|
|
|
ad0d7c |
* void *data, conn_opts_t *)
|
|
|
ad0d7c |
*/
|
|
|
ad0d7c |
queue_checker(free_smtp_check, dump_smtp_check, smtp_connect_thread,
|
|
|
ad0d7c |
- compare_smtp_check, smtp_checker, smtp_checker->default_co);
|
|
|
ad0d7c |
+ smtp_check_compare, smtp_checker, smtp_checker->default_co);
|
|
|
ad0d7c |
|
|
|
ad0d7c |
/*
|
|
|
ad0d7c |
* Last, allocate the list that will hold all the per host
|
|
|
ad0d7c |
diff --git a/keepalived/check/check_tcp.c b/keepalived/check/check_tcp.c
|
|
|
ad0d7c |
index 026a0e3c..1858f5fc 100644
|
|
|
ad0d7c |
--- a/keepalived/check/check_tcp.c
|
|
|
ad0d7c |
+++ b/keepalived/check/check_tcp.c
|
|
|
ad0d7c |
@@ -62,22 +62,20 @@ dump_tcp_check(void *data)
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
-static int
|
|
|
ad0d7c |
-compare_tcp_check(void *a, void *b)
|
|
|
ad0d7c |
+static bool
|
|
|
ad0d7c |
+tcp_check_compare(void *a, void *b)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
tcp_check_t *old = CHECKER_DATA(a);
|
|
|
ad0d7c |
tcp_check_t *new = CHECKER_DATA(b);
|
|
|
ad0d7c |
|
|
|
ad0d7c |
- if (compare_conn_opts(CHECKER_CO(a), CHECKER_CO(b)) != 0)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ if (!compare_conn_opts(CHECKER_CO(a), CHECKER_CO(b)))
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (old->n_retry != new->n_retry)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
if (old->delay_before_retry != new->delay_before_retry)
|
|
|
ad0d7c |
- goto err;
|
|
|
ad0d7c |
+ return false;
|
|
|
ad0d7c |
|
|
|
ad0d7c |
- return 0;
|
|
|
ad0d7c |
-err:
|
|
|
ad0d7c |
- return -1;
|
|
|
ad0d7c |
+ return true;
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
@@ -91,7 +89,7 @@ tcp_check_handler(__attribute__((unused)) vector_t *strvec)
|
|
|
ad0d7c |
|
|
|
ad0d7c |
/* queue new checker */
|
|
|
ad0d7c |
queue_checker(free_tcp_check, dump_tcp_check, tcp_connect_thread,
|
|
|
ad0d7c |
- compare_tcp_check, tcp_check, CHECKER_NEW_CO());
|
|
|
ad0d7c |
+ tcp_check_compare, tcp_check, CHECKER_NEW_CO());
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
diff --git a/keepalived/include/check_api.h b/keepalived/include/check_api.h
|
|
|
ad0d7c |
index 4a10a36b..c7bc297d 100644
|
|
|
ad0d7c |
--- a/keepalived/include/check_api.h
|
|
|
ad0d7c |
+++ b/keepalived/include/check_api.h
|
|
|
ad0d7c |
@@ -36,7 +36,7 @@ typedef struct _checker {
|
|
|
ad0d7c |
void (*free_func) (void *);
|
|
|
ad0d7c |
void (*dump_func) (void *);
|
|
|
ad0d7c |
int (*launch) (struct _thread *);
|
|
|
ad0d7c |
- int (*compare) (void *, void *);
|
|
|
ad0d7c |
+ bool (*compare) (void *, void *);
|
|
|
ad0d7c |
virtual_server_t *vs; /* pointer to the checker thread virtualserver */
|
|
|
ad0d7c |
real_server_t *rs; /* pointer to the checker thread realserver */
|
|
|
ad0d7c |
void *data;
|
|
|
ad0d7c |
@@ -71,10 +71,10 @@ extern void init_checkers_queue(void);
|
|
|
ad0d7c |
extern void dump_conn_opts(void *);
|
|
|
ad0d7c |
extern void queue_checker(void (*free_func) (void *), void (*dump_func) (void *)
|
|
|
ad0d7c |
, int (*launch) (thread_t *)
|
|
|
ad0d7c |
- , int (*compare) (void *, void *)
|
|
|
ad0d7c |
+ , bool (*compare) (void *, void *)
|
|
|
ad0d7c |
, void *
|
|
|
ad0d7c |
, conn_opts_t *);
|
|
|
ad0d7c |
-extern int compare_conn_opts(conn_opts_t *, conn_opts_t *);
|
|
|
ad0d7c |
+extern bool compare_conn_opts(conn_opts_t *, conn_opts_t *);
|
|
|
ad0d7c |
extern void dump_checkers_queue(void);
|
|
|
ad0d7c |
extern void free_checkers_queue(void);
|
|
|
ad0d7c |
extern void register_checkers_thread(void);
|
|
|
ad0d7c |
--
|
|
|
ad0d7c |
2.20.1
|
|
|
ad0d7c |
|