代码拉取完成,页面将自动刷新
From de2b6a221793fcf69c43e71ba46f0576524d2537 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Tue, 28 Jan 2020 21:38:21 +0100
Subject: [PATCH 13/20] Refactor: rename foreach_{node,ticket} macros to
uppercased variants
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is to allow for better visual identification of the macro magic.
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
---
src/config.c | 6 +++---
src/handler.c | 2 +-
src/main.c | 2 +-
src/raft.c | 3 ++-
src/ticket.c | 22 +++++++++++-----------
src/ticket.h | 4 ++--
src/transport.c | 4 ++--
7 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/src/config.c b/src/config.c
index cc338f9..f1613eb 100644
--- a/src/config.c
+++ b/src/config.c
@@ -986,7 +986,7 @@ static int get_other_site(struct booth_site **node)
if (!booth_conf)
return 0;
- foreach_node(i, n) {
+ FOREACH_NODE(i, n) {
if (n != local && n->type == SITE) {
if (!*node) {
*node = n;
@@ -1011,7 +1011,7 @@ int find_site_by_name(char *site, struct booth_site **node, int any_type)
if (!strcmp(site, OTHER_SITE))
return get_other_site(node);
- foreach_node(i, n) {
+ FOREACH_NODE(i, n) {
if ((n->type == SITE || any_type) &&
strncmp(n->addr_string, site, sizeof(n->addr_string)) == 0) {
*node = n;
@@ -1035,7 +1035,7 @@ int find_site_by_id(uint32_t site_id, struct booth_site **node)
if (!booth_conf)
return 0;
- foreach_node(i, n) {
+ FOREACH_NODE(i, n) {
if (n->site_id == site_id) {
*node = n;
return 1;
diff --git a/src/handler.c b/src/handler.c
index c7d6995..9d74f0f 100644
--- a/src/handler.c
+++ b/src/handler.c
@@ -133,7 +133,7 @@ void wait_child(int sig)
/* use waitpid(2) and not wait(2) in order not to interfere
* with popen(2)/pclose(2) and system(2) used in pacemaker.c
*/
- foreach_ticket(i, tk) {
+ FOREACH_TICKET(i, tk) {
if (tk_test.path && tk_test.pid > 0 &&
(tk_test.progstate == EXTPROG_RUNNING ||
tk_test.progstate == EXTPROG_IGNORE) &&
diff --git a/src/main.c b/src/main.c
index 71932fa..2c96c68 100644
--- a/src/main.c
+++ b/src/main.c
@@ -233,7 +233,7 @@ static int format_peers(char **pdata, unsigned int *len)
return -ENOMEM;
cp = data;
- foreach_node(i, s) {
+ FOREACH_NODE(i, s) {
if (s == local)
continue;
strftime(time_str, sizeof(time_str), "%F %T",
diff --git a/src/raft.c b/src/raft.c
index 4b484a9..dbe773c 100644
--- a/src/raft.c
+++ b/src/raft.c
@@ -40,8 +40,9 @@ inline static void clear_election(struct ticket_config *tk)
tk_log_debug("clear election");
tk->votes_received = 0;
- foreach_node(i, site)
+ FOREACH_NODE(i, site) {
tk->votes_for[site->index] = NULL;
+ }
}
diff --git a/src/ticket.c b/src/ticket.c
index 5f8ec4e..6673a2e 100644
--- a/src/ticket.c
+++ b/src/ticket.c
@@ -65,7 +65,7 @@ int find_ticket_by_name(const char *ticket, struct ticket_config **found)
if (found)
*found = NULL;
- foreach_ticket(i, tk) {
+ FOREACH_TICKET(i, tk) {
if (!strncmp(tk->name, ticket, sizeof(tk->name))) {
if (found)
*found = tk;
@@ -406,7 +406,7 @@ int list_ticket(char **pdata, unsigned int *len)
alloc = booth_conf->ticket_count * (BOOTH_NAME_LEN * 2 + 128 + 16);
- foreach_ticket(i, tk) {
+ FOREACH_TICKET(i, tk) {
multiple_grant_warning_length = number_sites_marked_as_granted(tk);
if (multiple_grant_warning_length > 1) {
@@ -420,7 +420,7 @@ int list_ticket(char **pdata, unsigned int *len)
return -ENOMEM;
cp = data;
- foreach_ticket(i, tk) {
+ FOREACH_TICKET(i, tk) {
if ((!is_manual(tk)) && is_time_set(&tk->term_expires)) {
/* Manual tickets doesn't have term_expires defined */
ts = wall_ts(&tk->term_expires);
@@ -468,7 +468,7 @@ int list_ticket(char **pdata, unsigned int *len)
}
}
- foreach_ticket(i, tk) {
+ FOREACH_TICKET(i, tk) {
multiple_grant_warning_length = number_sites_marked_as_granted(tk);
if (multiple_grant_warning_length > 1) {
@@ -477,7 +477,7 @@ int list_ticket(char **pdata, unsigned int *len)
"\nWARNING: The ticket %s is granted to multiple sites: ", // ~55 characters
tk->name);
- foreach_node(site_index, site) {
+ FOREACH_NODE(site_index, site) {
if (tk->sites_where_granted[site_index] > 0) {
cp += snprintf(cp,
alloc - (cp - data),
@@ -633,7 +633,7 @@ int setup_ticket(void)
struct ticket_config *tk;
int i;
- foreach_ticket(i, tk) {
+ FOREACH_TICKET(i, tk) {
reset_ticket(tk);
if (local->type == SITE) {
@@ -860,7 +860,7 @@ static void log_lost_servers(struct ticket_config *tk)
*/
return;
- foreach_node(i, n) {
+ FOREACH_NODE(i, n) {
if (!(tk->acks_received & n->bitmask)) {
tk_log_warn("%s %s didn't acknowledge our %s, "
"will retry %d times",
@@ -880,7 +880,7 @@ static void resend_msg(struct ticket_config *tk)
if (!(tk->acks_received ^ local->bitmask)) {
ticket_broadcast(tk, tk->last_request, 0, RLT_SUCCESS, 0);
} else {
- foreach_node(i, n) {
+ FOREACH_NODE(i, n) {
if (!(tk->acks_received & n->bitmask)) {
n->resend_cnt++;
tk_log_debug("resending %s to %s",
@@ -1144,7 +1144,7 @@ void process_tickets(void)
int i;
timetype last_cron;
- foreach_ticket(i, tk) {
+ FOREACH_TICKET(i, tk) {
if (!has_extprog_exited(tk) &&
is_time_set(&tk->next_cron) && !is_past(&tk->next_cron))
continue;
@@ -1168,7 +1168,7 @@ void tickets_log_info(void)
int i;
time_t ts;
- foreach_ticket(i, tk) {
+ FOREACH_TICKET(i, tk) {
ts = wall_ts(&tk->term_expires);
tk_log_info("state '%s' "
"term %d "
@@ -1366,7 +1366,7 @@ int number_sites_marked_as_granted(struct ticket_config *tk)
int i, result = 0;
struct booth_site *ignored __attribute__((unused));
- foreach_node(i, ignored) {
+ FOREACH_NODE(i, ignored) {
result += tk->sites_where_granted[i];
}
diff --git a/src/ticket.h b/src/ticket.h
index 59e84c0..d95cf6e 100644
--- a/src/ticket.h
+++ b/src/ticket.h
@@ -35,12 +35,12 @@ extern int TIME_RES;
#define DEFAULT_RETRIES 10
-#define foreach_ticket(i_, t_) \
+#define FOREACH_TICKET(i_, t_) \
for (i_ = 0; \
(t_ = booth_conf->ticket + i_, i_ < booth_conf->ticket_count); \
i_++)
-#define foreach_node(i_, n_) \
+#define FOREACH_NODE(i_, n_) \
for (i_ = 0; \
(n_ = booth_conf->site + i_, i_ < booth_conf->site_count); \
i_++)
diff --git a/src/transport.c b/src/transport.c
index 8e2d422..cd40e99 100644
--- a/src/transport.c
+++ b/src/transport.c
@@ -98,7 +98,7 @@ static int find_address(unsigned char ipaddr[BOOTH_IPADDR_LEN],
/* One bit left to check means ignore 7 lowest bits. */
mask = ~( (1 << (8 - bits_left)) -1);
- foreach_node(i, node) {
+ FOREACH_NODE(i, node) {
if (family != node->family)
continue;
n_a = node_to_addr_pointer(node);
@@ -895,7 +895,7 @@ static int booth_udp_broadcast_auth(void *buf, int len)
return rv;
rvs = 0;
- foreach_node(i, site) {
+ FOREACH_NODE(i, site) {
if (site != local) {
rv = booth_udp_send(site, buf, len);
if (!rvs)
--
2.25.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。