OSDN Git Service

maint: make PED_ASSERT and PED_DEBUG if-safe
authorColin Watson <cjwatson@ubuntu.com>
Tue, 20 Apr 2010 12:01:33 +0000 (13:01 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 21 Apr 2010 12:02:35 +0000 (14:02 +0200)
Constructions such as:

  if (foo)
    PED_DEBUG (0, "foo");
  else
    PED_DEBUG (0, "not foo");

did not compile reliably, depending on the configuration.  Make this
work.

* include/parted/debug.h [DEBUG && __GNUC__ && !__JSFTRACE__]
(PED_DEBUG): Remove trailing semicolon.
[!DEBUG] (PED_ASSERT): Use do-while rather than while.
[!DEBUG] (PED_DEBUG): Likewise.

include/parted/debug.h

index bbba09e..c0da54a 100644 (file)
@@ -39,7 +39,7 @@ ped_assert ( const char* cond_text,
 
 #define PED_DEBUG(level, ...) \
         ped_debug ( level, __FILE__, __LINE__, __PRETTY_FUNCTION__, \
-                    __VA_ARGS__ );
+                    __VA_ARGS__ )
 
 #define PED_ASSERT(cond, action)                               \
        do {                                                    \
@@ -79,8 +79,8 @@ static void PED_DEBUG (int level, ...)
 
 #else /* !DEBUG */
 
-#define PED_ASSERT(cond, action)       while (0) {}
-#define PED_DEBUG(level, ...)           while (0) {}
+#define PED_ASSERT(cond, action)       do {} while (0)
+#define PED_DEBUG(level, ...)           do {} while (0)
 
 
 #endif /* DEBUG */