[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Catch a few more K&R violations with make check-spaces
commit a6688c574e569a2a018038414198ab440344ba95
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Sat Jun 23 15:51:48 2012 -0400
Catch a few more K&R violations with make check-spaces
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 | 10 +++++++++-
src/or/circuitbuild.c | 3 +--
src/or/main.c | 3 +--
src/or/nodelist.c | 3 +--
4 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/contrib/checkSpace.pl b/contrib/checkSpace.pl
index a18df99..682dbce 100755
--- a/contrib/checkSpace.pl
+++ b/contrib/checkSpace.pl
@@ -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/) {
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index cfd1956..074b78d 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -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,
diff --git a/src/or/main.c b/src/or/main.c
index 1f3117b..95ac8d6 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -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 {
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index f7f3024..d178508 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -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;
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits