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

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