Blame SOURCES/bz1678480-fix-checker-coding-style.patch

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