Kaynağa Gözat

Wrap BAIL_* and GOTO_* macros in do { } while (0) ...

Ryan C. Gordon 15 yıl önce
ebeveyn
işleme
68632d3c57
2 değiştirilmiş dosya ile 9 ekleme ve 9 silme
  1. 1 1
      src/archiver_iso9660.c
  2. 8 8
      src/physfs_internal.h

+ 1 - 1
src/archiver_iso9660.c

@@ -347,7 +347,7 @@ static int iso_readimage(ISO9660Handle *handle, PHYSFS_uint64 where,
                          PHYSFS_uint32 objCount)
                          PHYSFS_uint32 objCount)
 {
 {
     BAIL_IF_MACRO(!__PHYSFS_platformGrabMutex(handle->mutex),
     BAIL_IF_MACRO(!__PHYSFS_platformGrabMutex(handle->mutex),
-            ERR_LOCK_VIOLATION, -1)
+            ERR_LOCK_VIOLATION, -1);
     int rc = -1;
     int rc = -1;
     if (where != handle->currpos)
     if (where != handle->currpos)
         GOTO_IF_MACRO(!__PHYSFS_platformSeek(handle->fhandle,where), NULL,
         GOTO_IF_MACRO(!__PHYSFS_platformSeek(handle->fhandle,where), NULL,

+ 8 - 8
src/physfs_internal.h

@@ -1022,14 +1022,14 @@ void __PHYSFS_sort(void *entries, PHYSFS_uint32 max,
 
 
 
 
 /* These get used all over for lessening code clutter. */
 /* These get used all over for lessening code clutter. */
-#define BAIL_MACRO(e, r) { __PHYSFS_setError(e); return r; }
-#define BAIL_IF_MACRO(c, e, r) if (c) { __PHYSFS_setError(e); return r; }
-#define BAIL_MACRO_MUTEX(e, m, r) { __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); return r; }
-#define BAIL_IF_MACRO_MUTEX(c, e, m, r) if (c) { __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); return r; }
-#define GOTO_MACRO(e, g) { __PHYSFS_setError(e); goto g; }
-#define GOTO_IF_MACRO(c, e, g) if (c) { __PHYSFS_setError(e); goto g; }
-#define GOTO_MACRO_MUTEX(e, m, g) { __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); goto g; }
-#define GOTO_IF_MACRO_MUTEX(c, e, m, g) if (c) { __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); goto g; }
+#define BAIL_MACRO(e, r) do { __PHYSFS_setError(e); return r; } while (0)
+#define BAIL_IF_MACRO(c, e, r) do { if (c) { __PHYSFS_setError(e); return r; } } while (0)
+#define BAIL_MACRO_MUTEX(e, m, r) do {  __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); return r; } while (0)
+#define BAIL_IF_MACRO_MUTEX(c, e, m, r) do { if (c) { __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); return r; } } while (0)
+#define GOTO_MACRO(e, g) do { __PHYSFS_setError(e); goto g; } while (0)
+#define GOTO_IF_MACRO(c, e, g) do { if (c) { __PHYSFS_setError(e); goto g; } } while (0)
+#define GOTO_MACRO_MUTEX(e, m, g) do { __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); goto g; } while (0)
+#define GOTO_IF_MACRO_MUTEX(c, e, m, g) do { if (c) { __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); goto g; } } while (0)
 
 
 #define __PHYSFS_ARRAYLEN(x) ( (sizeof (x)) / (sizeof (x[0])) )
 #define __PHYSFS_ARRAYLEN(x) ( (sizeof (x)) / (sizeof (x[0])) )