[tor-commits] [tor/master] Wrap columnar tables in "clang-format off/on"

nickm at torproject.org nickm at torproject.org
Thu Mar 5 13:25:48 UTC 2020


commit 99a5aecbc779985629abce22dfc00a4e9d6ccb9e
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Jan 10 15:13:30 2020 -0500

    Wrap columnar tables in "clang-format off/on"
    
    These tables have aligned comments, so we don't want clang-format to
    mess with them.
---
 src/app/config/statefile.c                | 2 ++
 src/feature/client/entrynodes.c           | 2 ++
 src/feature/dirauth/shared_random_state.c | 2 ++
 src/feature/dirparse/authcert_members.h   | 2 ++
 src/feature/dirparse/authcert_parse.c     | 2 ++
 src/feature/dirparse/microdesc_parse.c    | 2 ++
 src/feature/dirparse/ns_parse.c           | 8 ++++++++
 src/feature/dirparse/routerparse.c        | 4 ++++
 src/lib/confmgt/unitparse.c               | 6 ++++++
 src/lib/osinfo/uname.c                    | 2 ++
 10 files changed, 32 insertions(+)

diff --git a/src/app/config/statefile.c b/src/app/config/statefile.c
index d9667733c..dcc55f189 100644
--- a/src/app/config/statefile.c
+++ b/src/app/config/statefile.c
@@ -78,6 +78,7 @@ DUMMY_TYPECHECK_INSTANCE(or_state_t);
   VAR(#member, conftype, member, initvalue)
 
 /** Array of "state" variables saved to the ~/.tor/state file. */
+// clang-format off
 static const config_var_t state_vars_[] = {
   /* Remember to document these in state-contents.txt ! */
 
@@ -134,6 +135,7 @@ static const config_var_t state_vars_[] = {
 
   END_OF_CONFIG_VARS
 };
+// clang-format on
 
 #undef VAR
 #undef V
diff --git a/src/feature/client/entrynodes.c b/src/feature/client/entrynodes.c
index 8962f6500..2843558e9 100644
--- a/src/feature/client/entrynodes.c
+++ b/src/feature/client/entrynodes.c
@@ -1974,10 +1974,12 @@ get_retry_schedule(time_t failing_since, time_t now,
   const struct {
     time_t maximum; int primary_delay; int nonprimary_delay;
   } delays[] = {
+    // clang-format off
     { SIX_HOURS,    10*60,  1*60*60 },
     { FOUR_DAYS,    90*60,  4*60*60 },
     { SEVEN_DAYS, 4*60*60, 18*60*60 },
     { TIME_MAX,   9*60*60, 36*60*60 }
+    // clang-format on
   };
 
   unsigned i;
diff --git a/src/feature/dirauth/shared_random_state.c b/src/feature/dirauth/shared_random_state.c
index 1792d540c..52d9dc344 100644
--- a/src/feature/dirauth/shared_random_state.c
+++ b/src/feature/dirauth/shared_random_state.c
@@ -60,6 +60,7 @@ DUMMY_TYPECHECK_INSTANCE(sr_disk_state_t);
 #define SR_DISK_STATE_MAGIC 0x98AB1254
 
 /** Array of variables that are saved to disk as a persistent state. */
+// clang-format off
 static const config_var_t state_vars[] = {
   V(Version,                    POSINT, "0"),
   V(TorVersion,                 STRING, NULL),
@@ -73,6 +74,7 @@ static const config_var_t state_vars[] = {
   VAR("SharedRandCurrentValue", LINELIST_S, SharedRandValues, NULL),
   END_OF_CONFIG_VARS
 };
+// clang-format on
 
 /** "Extra" variable in the state that receives lines we can't parse. This
  * lets us preserve options from versions of Tor newer than us. */
diff --git a/src/feature/dirparse/authcert_members.h b/src/feature/dirparse/authcert_members.h
index c6755bb62..53eab175d 100644
--- a/src/feature/dirparse/authcert_members.h
+++ b/src/feature/dirparse/authcert_members.h
@@ -14,6 +14,7 @@
 #ifndef TOR_AUTHCERT_MEMBERS_H
 #define TOR_AUTHCERT_MEMBERS_H
 
+// clang-format off
 #define AUTHCERT_MEMBERS                                           \
   T1("dir-key-certificate-version", K_DIR_KEY_CERTIFICATE_VERSION,      \
                                                      GE(1),       NO_OBJ ), \
@@ -25,5 +26,6 @@
   T1("dir-key-certification", K_DIR_KEY_CERTIFICATION,\
                                                      NO_ARGS,     NEED_OBJ),\
   T01("dir-address",     K_DIR_ADDRESS,              GE(1),       NO_OBJ)
+// clang-format on
 
 #endif /* !defined(TOR_AUTHCERT_MEMBERS_H) */
diff --git a/src/feature/dirparse/authcert_parse.c b/src/feature/dirparse/authcert_parse.c
index 3d42119b9..deb45c12d 100644
--- a/src/feature/dirparse/authcert_parse.c
+++ b/src/feature/dirparse/authcert_parse.c
@@ -21,11 +21,13 @@
 #include "feature/dirparse/authcert_members.h"
 
 /** List of tokens recognized in V3 authority certificates. */
+// clang-format off
 static token_rule_t dir_key_certificate_table[] = {
   AUTHCERT_MEMBERS,
   T1("fingerprint",      K_FINGERPRINT,              CONCAT_ARGS, NO_OBJ ),
   END_OF_TABLE
 };
+// clang-format on
 
 /** Parse a key certificate from <b>s</b>; point <b>end-of-string</b> to
  * the first character after the certificate. */
diff --git a/src/feature/dirparse/microdesc_parse.c b/src/feature/dirparse/microdesc_parse.c
index c2eabeb40..9231080aa 100644
--- a/src/feature/dirparse/microdesc_parse.c
+++ b/src/feature/dirparse/microdesc_parse.c
@@ -28,6 +28,7 @@
 #include "feature/nodelist/microdesc_st.h"
 
 /** List of tokens recognized in microdescriptors */
+// clang-format off
 static token_rule_t microdesc_token_table[] = {
   T1_START("onion-key",        K_ONION_KEY,        NO_ARGS,     NEED_KEY_1024),
   T01("ntor-onion-key",        K_ONION_KEY_NTOR,   GE(1),       NO_OBJ ),
@@ -39,6 +40,7 @@ static token_rule_t microdesc_token_table[] = {
   A01("@last-listed",          A_LAST_LISTED,      CONCAT_ARGS, NO_OBJ ),
   END_OF_TABLE
 };
+// clang-format on
 
 /** Assuming that s starts with a microdesc, return the start of the
  * *NEXT* one.  Return NULL on "not found." */
diff --git a/src/feature/dirparse/ns_parse.c b/src/feature/dirparse/ns_parse.c
index 4d9b6e6e7..ac9325a60 100644
--- a/src/feature/dirparse/ns_parse.c
+++ b/src/feature/dirparse/ns_parse.c
@@ -43,6 +43,7 @@
 
 /** List of tokens recognized in the body part of v3 networkstatus
  * documents. */
+// clang-format off
 static token_rule_t rtrstatus_token_table[] = {
   T01("p",                   K_P,               CONCAT_ARGS, NO_OBJ ),
   T1( "r",                   K_R,                   GE(7),   NO_OBJ ),
@@ -56,8 +57,10 @@ static token_rule_t rtrstatus_token_table[] = {
   T0N("opt",                 K_OPT,             CONCAT_ARGS, OBJ_OK ),
   END_OF_TABLE
 };
+// clang-format on
 
 /** List of tokens recognized in V3 networkstatus votes. */
+// clang-format off
 static token_rule_t networkstatus_token_table[] = {
   T1_START("network-status-version", K_NETWORK_STATUS_VERSION,
                                                    GE(1),       NO_OBJ ),
@@ -98,8 +101,10 @@ static token_rule_t networkstatus_token_table[] = {
 
   END_OF_TABLE
 };
+// clang-format on
 
 /** List of tokens recognized in V3 networkstatus consensuses. */
+// clang-format off
 static token_rule_t networkstatus_consensus_token_table[] = {
   T1_START("network-status-version", K_NETWORK_STATUS_VERSION,
                                                    GE(1),       NO_OBJ ),
@@ -136,14 +141,17 @@ static token_rule_t networkstatus_consensus_token_table[] = {
 
   END_OF_TABLE
 };
+// clang-format on
 
 /** List of tokens recognized in the footer of v1 directory footers. */
+// clang-format off
 static token_rule_t networkstatus_vote_footer_token_table[] = {
   T01("directory-footer",    K_DIRECTORY_FOOTER,    NO_ARGS,   NO_OBJ ),
   T01("bandwidth-weights",   K_BW_WEIGHTS,          ARGS,      NO_OBJ ),
   T(  "directory-signature", K_DIRECTORY_SIGNATURE, GE(2),     NEED_OBJ ),
   END_OF_TABLE
 };
+// clang-format on
 
 /** Try to find the start and end of the signed portion of a networkstatus
  * document in <b>s</b>. On success, set <b>start_out</b> to the first
diff --git a/src/feature/dirparse/routerparse.c b/src/feature/dirparse/routerparse.c
index f476beec6..8828a0f97 100644
--- a/src/feature/dirparse/routerparse.c
+++ b/src/feature/dirparse/routerparse.c
@@ -81,6 +81,7 @@
 /****************************************************************************/
 
 /** List of tokens recognized in router descriptors */
+// clang-format off
 const token_rule_t routerdesc_token_table[] = {
   T0N("reject",              K_REJECT,              ARGS,    NO_OBJ ),
   T0N("accept",              K_ACCEPT,              ARGS,    NO_OBJ ),
@@ -123,8 +124,10 @@ const token_rule_t routerdesc_token_table[] = {
 
   END_OF_TABLE
 };
+// clang-format on
 
 /** List of tokens recognized in extra-info documents. */
+// clang-format off
 static token_rule_t extrainfo_token_table[] = {
   T1_END( "router-signature",    K_ROUTER_SIGNATURE,    NO_ARGS, NEED_OBJ ),
   T1( "published",           K_PUBLISHED,       CONCAT_ARGS, NO_OBJ ),
@@ -162,6 +165,7 @@ static token_rule_t extrainfo_token_table[] = {
 
   END_OF_TABLE
 };
+// clang-format on
 
 #undef T
 
diff --git a/src/lib/confmgt/unitparse.c b/src/lib/confmgt/unitparse.c
index 52c0eabb6..995cb9383 100644
--- a/src/lib/confmgt/unitparse.c
+++ b/src/lib/confmgt/unitparse.c
@@ -21,6 +21,7 @@
 
 /** Table to map the names of memory units to the number of bytes they
  * contain. */
+// clang-format off
 const struct unit_table_t memory_units[] = {
   { "",          1 },
   { "b",         1<< 0 },
@@ -65,9 +66,11 @@ const struct unit_table_t memory_units[] = {
   { "tbit",      UINT64_C(1)<<37 },
   { NULL, 0 },
 };
+// clang-format on
 
 /** Table to map the names of time units to the number of seconds they
  * contain. */
+// clang-format off
 const struct unit_table_t time_units[] = {
   { "",         1 },
   { "second",   1 },
@@ -84,9 +87,11 @@ const struct unit_table_t time_units[] = {
   { "months",   2629728, },
   { NULL, 0 },
 };
+// clang-format on
 
 /** Table to map the names of time units to the number of milliseconds
  * they contain. */
+// clang-format off
 const struct unit_table_t time_msec_units[] = {
   { "",         1 },
   { "msec",     1 },
@@ -104,6 +109,7 @@ const struct unit_table_t time_msec_units[] = {
   { "weeks",    7*24*60*60*1000 },
   { NULL, 0 },
 };
+// clang-format on
 
 /** Parse a string <b>val</b> containing a number, zero or more
  * spaces, and an optional unit string.  If the unit appears in the
diff --git a/src/lib/osinfo/uname.c b/src/lib/osinfo/uname.c
index ac99726f5..66439d133 100644
--- a/src/lib/osinfo/uname.c
+++ b/src/lib/osinfo/uname.c
@@ -61,6 +61,7 @@ get_uname,(void))
      */
     /* Windows Server 2019 is indistinguishable from Windows Server 2016
      * using GetVersionEx().
+// clang-format off
     { 10,  0, NULL,                        "Windows Server 2019" }, */
     { 10,  0, "Windows 10",                "Windows Server 2016" },
     {  6,  3, "Windows 8.1",               "Windows Server 2012 R2" },
@@ -73,6 +74,7 @@ get_uname,(void))
     {  5,  0, "Windows 2000 Professional", "Windows 2000 Server" },
     /* Earlier versions are not supported by GetVersionEx(). */
     {  0,  0, NULL,                        NULL }
+// clang-format on
         };
         memset(&info, 0, sizeof(info));
         info.dwOSVersionInfoSize = sizeof(info);





More information about the tor-commits mailing list