Skip to content

Commit

Permalink
Use do { ... } while (0) for the *_LOG macros
Browse files Browse the repository at this point in the history
Without this patch, such code would not compile:

if (cond)
    WARN_LOG(FOO, "msg");
else
    WARN_LOG(FOO, "msg2");
  • Loading branch information
delroth committed Aug 20, 2012
1 parent 603bd99 commit 54fc402
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions Source/Core/Common/Src/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type,
}
#endif

#define ERROR_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) }
#define WARN_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) }
#define NOTICE_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) }
#define INFO_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) }
#define DEBUG_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) }
#define ERROR_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } while (0)
#define WARN_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) } while (0)
#define NOTICE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } while (0)
#define INFO_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) } while (0)
#define DEBUG_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) } while (0)

#if MAX_LOGLEVEL >= DEBUG_LEVEL
#define _dbg_assert_(_t_, _a_) \
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Src/HW/DVDInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ void ExecuteCommand(UDICR& _DICR)
_dbg_assert_(DVDINTERFACE, m_DILENGTH.Length == 0x20);
if (!DVDRead(m_DICMDBUF[1].Hex, m_DIMAR.Address, m_DILENGTH.Length))
PanicAlertT("Cant read from DVD_Plugin - DVD-Interface: Fatal Error");
WARN_LOG(DVDINTERFACE, "Read DiscID %08x", Memory::Read_U32(m_DIMAR.Address))
WARN_LOG(DVDINTERFACE, "Read DiscID %08x", Memory::Read_U32(m_DIMAR.Address));
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DiscIO/Src/DiscScrubber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ bool ParsePartitionData(SPartition& _rPartition)

if (!FileSystem)
{
ERROR_LOG(DISCIO, "Failed to create filesystem for group %d partition %u", _rPartition.GroupNumber, _rPartition.Number)
ERROR_LOG(DISCIO, "Failed to create filesystem for group %d partition %u", _rPartition.GroupNumber, _rPartition.Number);
ParsedOK = false;
}
else
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoCommon/Src/VideoCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ struct TargetRectangle : public MathUtil::Rectangle<int>
};

#ifdef _WIN32
#define PRIM_LOG(...) {DEBUG_LOG(VIDEO, __VA_ARGS__)}
#define PRIM_LOG(...) DEBUG_LOG(VIDEO, __VA_ARGS__)
#else
#define PRIM_LOG(...) {DEBUG_LOG(VIDEO, ##__VA_ARGS__)}
#define PRIM_LOG(...) DEBUG_LOG(VIDEO, ##__VA_ARGS__)
#endif


Expand Down

0 comments on commit 54fc402

Please sign in to comment.