Log4cxx
  1. Log4cxx
  2. LOGCXX-133

Missing parenthesis in LOG4CXX_ASSERT

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.9.7
    • Fix Version/s: 0.10.0
    • Component/s: None
    • Labels:
      None

      Description

      On Apr 11, 2006, at 4:13 AM, Ondrej Pacovsky wrote:

      Hi, I'd just like to note that the LOG4CXX_ASSERT macro might be a bit dangerous because of its usage of the "condition" param:

      #define LOG4CXX_ASSERT(logger, condition, message) { \
      if (!condition && logger->isErrorEnabled()) {\
      logger->forcedLog(::log4cxx::Level::getError(), message, LOG4CXX_LOCATION); }}

      when used e.g. as LOG4CXX_ASSERT(lmain, false || true, "damn"), it producess the error message when it shouldn't.

      FIX: use parentheses
      #define LOG4CXX_ASSERT(logger, condition, message) { \
      if (!(condition) && logger->isErrorEnabled()) {\
      logger->forcedLog(::log4cxx::Level::getError(), message, LOG4CXX_LOCATION); }}

      cheers,
      Ondrej

        Activity

        Hide
        Curt Arnold added a comment -

        Thanks for the report. Committed in rev 393255.

        Show
        Curt Arnold added a comment - Thanks for the report. Committed in rev 393255.

          People

          • Assignee:
            Curt Arnold
            Reporter:
            Curt Arnold
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development