Bug 39046 - Make DEBUG a no-op static inline with --disable-debug.
Summary: Make DEBUG a no-op static inline with --disable-debug.
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: general (show other bugs)
Version: git master
Hardware: Other All
: medium normal
Assignee: Telepathy bugs list
QA Contact: Telepathy bugs list
URL:
Whiteboard: r+
Keywords: patch
Depends on:
Blocks:
 
Reported: 2011-07-07 12:07 UTC by Will Thompson
Modified: 2011-07-11 10:07 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Will Thompson 2011-07-07 12:07:07 UTC
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
Comment 2 Guillaume Desmottes 2011-07-08 02:51:48 UTC
tp-glib branch++
Comment 3 Will Thompson 2011-07-11 10:07:15 UTC
Merged to Wocky, Gabble and tp-glib master. Ta!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.