[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r13039: Another test for the increasingly bad check-spaces style che (in tor/trunk: . contrib src/common)
Author: nickm
Date: 2008-01-05 22:16:08 -0500 (Sat, 05 Jan 2008)
New Revision: 13039
Modified:
tor/trunk/
tor/trunk/contrib/checkSpace.pl
tor/trunk/src/common/compat.h
tor/trunk/src/common/util.c
tor/trunk/src/common/util.h
Log:
r17472@catbus: nickm | 2008-01-05 22:10:19 -0500
Another test for the increasingly bad check-spaces style checker to check: #else\n#if is almost a sure sign of a failure to use #elif. Fortunately, we only did that 3 times.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r17472] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/contrib/checkSpace.pl
===================================================================
--- tor/trunk/contrib/checkSpace.pl 2008-01-06 03:16:06 UTC (rev 13038)
+++ tor/trunk/contrib/checkSpace.pl 2008-01-06 03:16:08 UTC (rev 13039)
@@ -9,6 +9,7 @@
for $fn (@ARGV) {
open(F, "$fn");
$lastnil = 0;
+ $lastline = "";
$incomment = 0;
while (<F>) {
## Warn about windows-style newlines.
@@ -27,6 +28,11 @@
if ($C && /\s(?:if|while|for|switch)\(/) {
print " KW(:$fn:$.\n";
}
+ ## Warn about #else #if instead of #elif.
+ if (($lastline =~ /^\# *else/) and ($_ =~ /^\# *if/)) {
+ print " #else#if:$fn:$.\n";
+ }
+ $lastline = $_;
## Warn about multiple empty lines.
if ($lastnil && /^$/) {
print " DoubleNL:$fn:$.\n";
Modified: tor/trunk/src/common/compat.h
===================================================================
--- tor/trunk/src/common/compat.h 2008-01-06 03:16:06 UTC (rev 13038)
+++ tor/trunk/src/common/compat.h 2008-01-06 03:16:08 UTC (rev 13039)
@@ -139,15 +139,13 @@
#ifdef __GNUC__
#define STMT_BEGIN (void) ({
#define STMT_END })
-#else
-#if defined(sun) || defined(__sun__)
+#elif defined(sun) || defined(__sun__)
#define STMT_BEGIN if (1) {
#define STMT_END } else STMT_NIL
#else
#define STMT_BEGIN do {
#define STMT_END } while (0)
#endif
-#endif
/* ===== String compatibility */
#ifdef MS_WINDOWS
Modified: tor/trunk/src/common/util.c
===================================================================
--- tor/trunk/src/common/util.c 2008-01-06 03:16:06 UTC (rev 13038)
+++ tor/trunk/src/common/util.c 2008-01-06 03:16:08 UTC (rev 13039)
@@ -233,15 +233,13 @@
#ifdef HAVE_MALLOC_GOOD_SIZE
*sizep = malloc_good_size(*sizep);
return _tor_malloc(*sizep DMALLOC_FN_ARGS);
-#else
-#if defined(HAVE_MALLOC_USABLE_SIZE) && !defined(USE_DMALLOC)
+#elif defined(HAVE_MALLOC_USABLE_SIZE) && !defined(USE_DMALLOC)
void *result = _tor_malloc(*sizep DMALLOC_FN_ARGS);
*sizep = malloc_usable_size(result);
return result;
#else
return _tor_malloc(*sizep DMALLOC_FN_ARGS);
#endif
-#endif
}
/** Call the platform malloc info function, and dump the results to the log at
Modified: tor/trunk/src/common/util.h
===================================================================
--- tor/trunk/src/common/util.h 2008-01-06 03:16:06 UTC (rev 13038)
+++ tor/trunk/src/common/util.h 2008-01-06 03:16:08 UTC (rev 13039)
@@ -39,8 +39,7 @@
* security-critical properties.
*/
#error "Sorry; we don't support building with NDEBUG."
-#else
-#ifdef __GNUC__
+#elif defined(__GNUC__)
/* Give an int-valued version of !x that won't confuse PREDICT_UNLIKELY. */
#define IS_FALSE_AS_INT(x) ((x) == ((typeof(x)) 0))
#else
@@ -57,7 +56,6 @@
_SHORT_FILE_, __LINE__, __func__, #expr); \
abort(); \
} STMT_END
-#endif
#ifdef USE_DMALLOC
#define DMALLOC_PARAMS , const char *file, const int line