aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-01-06 03:16:08 +0000
committerNick Mathewson <nickm@torproject.org>2008-01-06 03:16:08 +0000
commit6d58d80e78d9b6706bda502a9041351f4a619306 (patch)
treef5b0a15ed1e1f212de955e360b06661e47ac0c50
parent864d83059823bbd89c94dcff258f99977b17bcd6 (diff)
downloadtor-6d58d80e78d9b6706bda502a9041351f4a619306.tar
tor-6d58d80e78d9b6706bda502a9041351f4a619306.tar.gz
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. svn:r13039
-rwxr-xr-xcontrib/checkSpace.pl6
-rw-r--r--src/common/compat.h4
-rw-r--r--src/common/util.c4
-rw-r--r--src/common/util.h4
4 files changed, 9 insertions, 9 deletions
diff --git a/contrib/checkSpace.pl b/contrib/checkSpace.pl
index 686427f73..fb0c9861b 100755
--- a/contrib/checkSpace.pl
+++ b/contrib/checkSpace.pl
@@ -9,6 +9,7 @@ if ($ARGV[0] =~ /^-/) {
for $fn (@ARGV) {
open(F, "$fn");
$lastnil = 0;
+ $lastline = "";
$incomment = 0;
while (<F>) {
## Warn about windows-style newlines.
@@ -27,6 +28,11 @@ for $fn (@ARGV) {
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";
diff --git a/src/common/compat.h b/src/common/compat.h
index d92b06ac3..a94691d44 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -139,15 +139,13 @@ extern INLINE double U64_TO_DBL(uint64_t x) {
#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
diff --git a/src/common/util.c b/src/common/util.c
index aaf057cd1..357f997f1 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -233,15 +233,13 @@ _tor_malloc_roundup(size_t *sizep DMALLOC_PARAMS)
#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
diff --git a/src/common/util.h b/src/common/util.h
index 1eaad82ec..686350cae 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -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