[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Unhealthy commit e3340714c8 Style: clarify "do nothing" macro with {};
From: |
David Kastrup |
Subject: |
Unhealthy commit e3340714c8 Style: clarify "do nothing" macro with {}; |
Date: |
Thu, 07 Oct 2010 21:36:00 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Here we have
-#define ASSERT_LIVE_IS_ALLOWED()
+#define ASSERT_LIVE_IS_ALLOWED() {};
The problem is that the replaced statement defines
ASSERT_LIVE_IS_ALLOWED() as being 1, while the second defines it as {};.
Now
ASSERT_LIVE_IS_ALLOWED();
was one statement previously, while it now is three(!) statements.
That is a particular bad idea for things like
if (condition) ASSERT_LIVE_IS_ALLOWED(); else ...
While a code review can check that this is not yet problematic, it will
still remain an accident waiting to happen.
So either ASSERT_LIVE_IS_ALLOWED() should be explicitly defined as 1.
Or, if one really wants to stress the statement character, one can use
#define ASSERT_LIVE_IS_ALLOWED() do { } while (0)
which is a common trick to generate a statement that is lacking its
terminating semicolon.
--
David Kastrup
- Unhealthy commit e3340714c8 Style: clarify "do nothing" macro with {};,
David Kastrup <=