commit ccdd0d801ae952d4c8219eea9acdd3acfd438924
Author: Daniel Pinto <danielpinto52(a)gmail.com>
Date: Mon Aug 3 20:08:17 2020 +0100
Minor style improvements. #30045
---
scripts/maint/practracker/exceptions.txt | 4 ++--
src/app/config/config.c | 3 +--
src/app/config/or_options_st.h | 11 +++++++----
src/feature/relay/routerkeys.c | 7 +++----
4 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/scripts/maint/practracker/exceptions.txt b/scripts/maint/practracker/exceptions.txt
index 95c5665fb3..b7d6d609b8 100644
--- a/scripts/maint/practracker/exceptions.txt
+++ b/scripts/maint/practracker/exceptions.txt
@@ -37,7 +37,7 @@ problem file-size /src/app/config/config.c 7525
problem include-count /src/app/config/config.c 81
problem function-size /src/app/config/config.c:options_act() 381
problem function-size /src/app/config/config.c:options_validate_cb() 794
-problem function-size /src/app/config/config.c:options_init_from_torrc() 231
+problem function-size /src/app/config/config.c:options_init_from_torrc() 230
problem function-size /src/app/config/config.c:options_init_from_string() 103
problem function-size /src/app/config/config.c:options_init_logs() 125
problem function-size /src/app/config/config.c:parse_bridge_line() 104
@@ -47,7 +47,7 @@ problem function-size /src/app/config/config.c:parse_dir_fallback_line() 101
problem function-size /src/app/config/config.c:port_parse_config() 435
problem function-size /src/app/config/config.c:parse_ports() 132
problem function-size /src/app/config/resolve_addr.c:resolve_my_address_v4() 197
-problem file-size /src/app/config/or_options_st.h 1069
+problem file-size /src/app/config/or_options_st.h 1072
problem include-count /src/app/main/main.c 71
problem function-size /src/app/main/main.c:dumpstats() 102
problem function-size /src/app/main/main.c:tor_init() 109
diff --git a/src/app/config/config.c b/src/app/config/config.c
index 1c6d4acd3e..23f280891b 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -4434,9 +4434,8 @@ options_init_from_torrc(int argc, char **argv)
const char *v = format_line->value;
// keep the same order as enum key_expiration_format
const char *formats[] = { "iso8601", "timestamp" };
- const int formats_len = sizeof(formats) / sizeof(formats[0]);
int format = -1;
- for (int i = 0; i < formats_len; i++) {
+ for (unsigned i = 0; i < ARRAY_LENGTH(formats); i++) {
if (!strcmp(v, formats[i])) {
format = i;
break;
diff --git a/src/app/config/or_options_st.h b/src/app/config/or_options_st.h
index 774b476476..9d620c7b62 100644
--- a/src/app/config/or_options_st.h
+++ b/src/app/config/or_options_st.h
@@ -35,6 +35,12 @@ typedef enum {
TCP_PROXY_PROTOCOL_HAPROXY
} tcp_proxy_protocol_t;
+/** Enumeration of available time formats for output of --key-expiration */
+typedef enum {
+ KEY_EXPIRATION_FORMAT_ISO8601 = 0,
+ KEY_EXPIRATION_FORMAT_TIMESTAMP
+} key_expiration_format_t;
+
/** Configuration options for a Tor process. */
struct or_options_t {
uint32_t magic_;
@@ -944,10 +950,7 @@ struct or_options_t {
* ed25519 identity key except from tor --keygen */
int OfflineMasterKey;
- enum {
- KEY_EXPIRATION_FORMAT_ISO8601 = 0,
- KEY_EXPIRATION_FORMAT_TIMESTAMP
- } key_expiration_format;
+ key_expiration_format_t key_expiration_format;
enum {
FORCE_PASSPHRASE_AUTO=0,
diff --git a/src/feature/relay/routerkeys.c b/src/feature/relay/routerkeys.c
index f0fd101efd..744a73d936 100644
--- a/src/feature/relay/routerkeys.c
+++ b/src/feature/relay/routerkeys.c
@@ -520,14 +520,13 @@ print_cert_expiration(const char *expiration,
/**
* Log when a certificate, <b>cert</b>, with some <b>description</b> and
* stored in a file named <b>fname</b>, is going to expire. Formats the expire
- * time according to <b>time_format</b>. Valid time formats are in the
- * key_expiration_format enum, in or_options_t.
+ * time according to <b>time_format</b>.
*/
static void
log_ed_cert_expiration(const tor_cert_t *cert,
const char *description,
const char *fname,
- int time_format) {
+ key_expiration_format_t time_format) {
if (BUG(!cert)) { /* If the specified key hasn't been loaded */
log_warn(LD_OR, "No %s key loaded; can't get certificate expiration.",
description);
@@ -582,7 +581,7 @@ log_master_signing_key_cert_expiration(const or_options_t *options)
/* If we do have a signing key, log the expiration time. */
if (signing_key) {
- int time_format = options->key_expiration_format;
+ key_expiration_format_t time_format = options->key_expiration_format;
log_ed_cert_expiration(signing_key, "signing", fn, time_format);
} else {
log_warn(LD_OR, "Could not load signing key certificate from %s, so " \