]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Catch a few more K&R violations with make check-spaces
authorNick Mathewson <nickm@torproject.org>
Sat, 23 Jun 2012 19:51:48 +0000 (15:51 -0400)
committerNick Mathewson <nickm@torproject.org>
Sat, 23 Jun 2012 19:54:01 +0000 (15:54 -0400)
We now catch bare {s that should be on the previous line with a do,
while, if, or for, and elses that should share a line with their
preceding }.

That is,
    if (foo)
    {
and
    if (foo) {
      ...
    }
    else

are now detected.

We should think about maybe making Tor uncrustify-clean some day,
but configuring uncrustify is an exercise in bizarreness, and
reformatting huge gobs of Tor is always painful.

contrib/checkSpace.pl
src/or/circuitbuild.c
src/or/main.c
src/or/nodelist.c

index a18df99b1699c5273d8e963d6fd30b6d20aaaa43..682dbced00436c84795402afad7f54ba5cd6061d 100755 (executable)
@@ -32,10 +32,18 @@ for $fn (@ARGV) {
         if ($C && /\s(?:if|while|for|switch)\(/) {
             print "      KW(:$fn:$.\n";
         }
-        ## Warn about #else #if instead of #elif. 
+        ## Warn about #else #if instead of #elif.
         if (($lastline =~ /^\# *else/) and ($_ =~ /^\# *if/)) {
             print " #else#if:$fn:$.\n";
         }
+        ## Warn about some K&R violations
+        if (/^\s+\{/ and $lastline =~ /^\s*(if|while|for|else if)/ and
+           $lastline !~ /\{$/) {
+            print "non-K&R {:$fn:$.\n";
+       }
+        if (/^\s*else/ and $lastline =~ /\}$/) {
+           print "  }\\nelse:$fn:$.\n";
+       }
         $lastline = $_;
         ## Warn about unnecessary empty lines.
         if ($lastnil && /^\s*}\n/) {
index cfd1956e5f5b2e84916102469ab0f2ea46961317..074b78d96fdf367757c7ed9c447a3d6863fbfb6a 100644 (file)
@@ -5602,8 +5602,7 @@ rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node)
 
     /* XXXipv6 we lack support for falling back to another address for
        the same relay, warn the user */
-    if (!tor_addr_is_null(&ri->ipv6_addr))
-    {
+    if (!tor_addr_is_null(&ri->ipv6_addr)) {
       tor_addr_port_t ap;
       router_get_pref_orport(ri, &ap);
       log_notice(LD_CONFIG,
index 1f3117b230fb8783fef6b5f608ff1224e89232d7..95ac8d616ec615b26e579dc1440067b7a83c7982 100644 (file)
@@ -2597,8 +2597,7 @@ tor_main(int argc, char *argv[])
   // a file on a folder shared by the wm emulator.
   // if no flashcard (real or emulated) is present,
   // log files will be written in the root folder
-  if (find_flashcard_path(path,MAX_PATH) == -1)
-  {
+  if (find_flashcard_path(path,MAX_PATH) == -1) {
     redir = _wfreopen( L"\\stdout.log", L"w", stdout );
     redirdbg = _wfreopen( L"\\stderr.log", L"w", stderr );
   } else {
index f7f3024179cc1e98ced741f81342b8b6c1cbfc09..d17850888d5bab8ae7c5872338d3955d08789f90 100644 (file)
@@ -689,8 +689,7 @@ node_get_prim_orport(const node_t *node, tor_addr_port_t *ap_out)
 {
   if (node->ri) {
     router_get_prim_orport(node->ri, ap_out);
-  }
-  else if (node->rs) {
+  } else if (node->rs) {
     tor_addr_from_ipv4h(&ap_out->addr, node->rs->addr);
     ap_out->port = node->rs->or_port;
   }