summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2016-02-22 15:20:25 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2016-02-22 15:20:25 +0100
commit96c9ba0f09db026ec361b4d4d3a1fbf1f57bdc06 (patch)
tree8c32464bd3a2fc0f1178c2e357617a9c4e256114
parent8255dd8965cde43311d6e89ca9e9644fe29d4bca (diff)
downloadfastd-96c9ba0f09db026ec361b4d4d3a1fbf1f57bdc06.tar
fastd-96c9ba0f09db026ec361b4d4d3a1fbf1f57bdc06.zip
types: replace static consts with defines
-rw-r--r--src/config.y4
-rw-r--r--src/methods/common.c6
-rw-r--r--src/peer.c8
-rw-r--r--src/peer.h4
-rw-r--r--src/poll.c2
-rw-r--r--src/task.c2
-rw-r--r--src/task.h2
-rw-r--r--src/types.h8
-rw-r--r--src/verify.c8
9 files changed, 22 insertions, 22 deletions
diff --git a/src/config.y b/src/config.y
index 8495e25..0d0a343 100644
--- a/src/config.y
+++ b/src/config.y
@@ -653,8 +653,8 @@ boolean: TOK_YES { $$ = true; }
| TOK_NO { $$ = false; }
;
-autobool: TOK_AUTO { $$ = fastd_tristate_undef; }
- | boolean { $$ = $1 ? fastd_tristate_true : fastd_tristate_false; }
+autobool: TOK_AUTO { $$ = FASTD_TRISTATE_UNDEF; }
+ | boolean { $$ = $1 ? FASTD_TRISTATE_TRUE : FASTD_TRISTATE_FALSE; }
;
colon_or_port: ':'
diff --git a/src/methods/common.c b/src/methods/common.c
index 4d1a795..fddfc20 100644
--- a/src/methods/common.c
+++ b/src/methods/common.c
@@ -96,15 +96,15 @@ fastd_tristate_t fastd_method_reorder_check(fastd_peer_t *peer, fastd_method_com
memcpy(session->receive_nonce, nonce, COMMON_NONCEBYTES);
session->reorder_timeout = ctx.now + REORDER_TIME;
- return fastd_tristate_false;
+ return FASTD_TRISTATE_FALSE;
}
else if (age == 0 || session->receive_reorder_seen & ((uint64_t)1 << (age-1))) {
pr_debug("dropping duplicate packet from %P (age %u)", peer, (unsigned)age);
- return fastd_tristate_undef;
+ return FASTD_TRISTATE_UNDEF;
}
else {
pr_debug2("accepting reordered packet from %P (age %u)", peer, (unsigned)age);
session->receive_reorder_seen |= ((uint64_t)1 << (age-1));
- return fastd_tristate_true;
+ return FASTD_TRISTATE_TRUE;
}
}
diff --git a/src/peer.c b/src/peer.c
index 8b2dfdb..0fbda1a 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -262,7 +262,7 @@ static void schedule_peer_task(fastd_peer_t *peer) {
fastd_timeout_min(peer->keepalive_timeout,
peer->next_handshake));
- if (timeout == fastd_timeout_inv) {
+ if (timeout == FASTD_TIMEOUT_INV) {
pr_debug2("Removing scheduled task for %P", peer);
fastd_task_unschedule(&peer->task);
}
@@ -427,9 +427,9 @@ static void setup_peer(fastd_peer_t *peer) {
peer->verify_valid_timeout = ctx.now;
#endif
- peer->next_handshake = fastd_timeout_inv;
- peer->reset_timeout = fastd_timeout_inv;
- peer->keepalive_timeout = fastd_timeout_inv;
+ peer->next_handshake = FASTD_TIMEOUT_INV;
+ peer->reset_timeout = FASTD_TIMEOUT_INV;
+ peer->keepalive_timeout = FASTD_TIMEOUT_INV;
if (fastd_peer_is_dynamic(peer))
peer->reset_timeout = ctx.now;
diff --git a/src/peer.h b/src/peer.h
index 88e192b..589ac90 100644
--- a/src/peer.h
+++ b/src/peer.h
@@ -186,7 +186,7 @@ static inline void fastd_peer_schedule_handshake_default(fastd_peer_t *peer) {
/** Cancels a scheduled handshake */
static inline void fastd_peer_unschedule_handshake(fastd_peer_t *peer) {
- peer->next_handshake = fastd_timeout_inv;
+ peer->next_handshake = FASTD_TIMEOUT_INV;
}
#ifdef WITH_DYNAMIC_PEERS
@@ -207,7 +207,7 @@ static inline void fastd_peer_set_verified(fastd_peer_t *peer, bool ok) {
/** Checks if there's a handshake queued for the peer */
static inline bool fastd_peer_handshake_scheduled(fastd_peer_t *peer) {
- return (peer->next_handshake != fastd_timeout_inv);
+ return (peer->next_handshake != FASTD_TIMEOUT_INV);
}
/** Checks if a peer is floating (is has at least one floating remote or no remotes at all) */
diff --git a/src/poll.c b/src/poll.c
index 123db6f..6507aad 100644
--- a/src/poll.c
+++ b/src/poll.c
@@ -54,7 +54,7 @@
/** Returns the time to the next task or -1 */
static inline int task_timeout(void) {
fastd_timeout_t timeout = fastd_task_queue_timeout();
- if (timeout == fastd_timeout_inv)
+ if (timeout == FASTD_TIMEOUT_INV)
return -1;
int diff_msec = timeout - ctx.now;
diff --git a/src/task.c b/src/task.c
index 8a95b06..c6cc898 100644
--- a/src/task.c
+++ b/src/task.c
@@ -75,7 +75,7 @@ void fastd_task_reschedule(fastd_task_t *task, fastd_timeout_t timeout) {
/** Gets the timeout of the next task in the task queue */
fastd_timeout_t fastd_task_queue_timeout(void) {
if (!ctx.task_queue)
- return fastd_timeout_inv;
+ return FASTD_TIMEOUT_INV;
return ctx.task_queue->value;
}
diff --git a/src/task.h b/src/task.h
index 667386a..21b15fe 100644
--- a/src/task.h
+++ b/src/task.h
@@ -55,7 +55,7 @@ static inline bool fastd_task_scheduled(fastd_task_t *task) {
/** Gets the timeout of a task */
static inline fastd_timeout_t fastd_task_timeout(fastd_task_t *task) {
if (!fastd_task_scheduled(task))
- return fastd_timeout_inv;
+ return FASTD_TIMEOUT_INV;
return task->entry.value;
}
diff --git a/src/types.h b/src/types.h
index e29943c..1d28781 100644
--- a/src/types.h
+++ b/src/types.h
@@ -49,11 +49,11 @@ typedef struct fastd_tristate {
} fastd_tristate_t;
/** A fastd_tristate_t instance representing the value \em true */
-static const fastd_tristate_t fastd_tristate_true = {true, true};
+#define FASTD_TRISTATE_TRUE ((fastd_tristate_t){true, true})
/** A fastd_tristate_t instance representing the value \em false */
-static const fastd_tristate_t fastd_tristate_false = {true, false};
+#define FASTD_TRISTATE_FALSE ((fastd_tristate_t){true, false})
/** A fastd_tristate_t instance representing the value \em undefined */
-static const fastd_tristate_t fastd_tristate_undef = {false, false};
+#define FASTD_TRISTATE_UNDEF ((fastd_tristate_t){false, false})
/** The defined packet types */
@@ -97,7 +97,7 @@ typedef enum fastd_task_type {
typedef int64_t fastd_timeout_t;
/** Invalid timestamp */
-static const fastd_timeout_t fastd_timeout_inv = INT64_MAX;
+#define FASTD_TIMEOUT_INV INT64_MAX
typedef struct fastd_buffer fastd_buffer_t;
diff --git a/src/verify.c b/src/verify.c
index d0edbe9..be2fe9d 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -106,12 +106,12 @@ fastd_tristate_t fastd_verify_peer(fastd_peer_t *peer, fastd_socket_t *sock, con
bool ret = do_verify(env);
fastd_shell_env_free(env);
fastd_peer_set_verified(peer, ret);
- return ret ? fastd_tristate_true : fastd_tristate_false;
+ return ret ? FASTD_TRISTATE_TRUE : FASTD_TRISTATE_FALSE;
}
else {
if (!fastd_sem_trywait(&ctx.verify_limit)) {
pr_debug("maximum number of verification processes reached");
- return fastd_tristate_false;
+ return FASTD_TRISTATE_FALSE;
}
verify_arg_t *arg = fastd_alloc0(sizeof(verify_arg_t) + data_len);
@@ -135,10 +135,10 @@ fastd_tristate_t fastd_verify_peer(fastd_peer_t *peer, fastd_socket_t *sock, con
fastd_shell_env_free(env);
free(arg);
- return fastd_tristate_false;
+ return FASTD_TRISTATE_FALSE;
}
- return fastd_tristate_undef;
+ return FASTD_TRISTATE_UNDEF;
}
}