[Bug 39046] New: Make DEBUG a no-op static inline with --disable-debug.

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu Jul 7 21:07:08 CEST 2011


https://bugs.freedesktop.org/show_bug.cgi?id=39046

           Summary: Make DEBUG a no-op static inline with --disable-debug.
           Product: Telepathy
           Version: git master
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: patch
          Severity: normal
          Priority: medium
         Component: general
        AssignedTo: telepathy-bugs at lists.freedesktop.org
        ReportedBy: will.thompson at collabora.co.uk
         QAContact: telepathy-bugs at lists.freedesktop.org


Most Telepathy(-related) C components define DEBUG(...) to do { } while (0); if
--disable-debug is passed to configure. This has the unpleasant side-effect of
triggering unused variable warnings and the like.

I realised today that they could instead be defined as follows:

  static inline void
  DEBUG (const gchar *format, ...)
  {
  }

This avoids us ever having to guard variables only used in debug statements
with ENABLE_DEBUG ever again. If the compiler is smart enough (which it should
be), it will optimise away the function call; if it's *really* smart it'll also
optimize away the variables which (after the function call has been eliminated)
are set but never used. (I don't know how smart GCC is, but it *should* do at
least the first.)

I've got branches for Wocky and tp-glib so far. I vetted tp-glib and there are
no particularly expensive function calls as arguments to DEBUG(). The most
expensive is tp_handle_set_size().

http://cgit.collabora.com/git/user/wjt/wocky.git/log/?h=oh-god-the-warnings
http://cgit.collabora.com/git/user/wjt/telepathy-glib.git/log/?h=debug-stub

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.



More information about the telepathy-bugs mailing list