Bug 83767

Summary: turn runtime assertions into compile-time assertions
Product: dbus Reporter: Simon McVittie <smcv>
Component: coreAssignee: Simon McVittie <smcv>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: low CC: alban.crequy, smcv, thiago, walters
Version: unspecifiedKeywords: patch
Hardware: Other   
OS: All   
Whiteboard: review?
i915 platform: i915 features:
Attachments: Add _DBUS_GNUC_UNUSED, and use it in _DBUS_STATIC_ASSERT
Replace some runtime assertions with compile-time assertions

Description Simon McVittie 2014-09-11 13:34:13 UTC
Static assertions are good: they prevent dbus from even compiling on platforms where certain assumptions don't hold.
Comment 1 Simon McVittie 2014-09-11 13:35:42 UTC
Created attachment 106131 [details] [review]
Add _DBUS_GNUC_UNUSED, and use it in _DBUS_STATIC_ASSERT

This means we can use _DBUS_STATIC_ASSERT at non-global scope without
tripping -Wunused-local-typedefs.

Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>

---

My colleague Alban already reviewed this internally.
Comment 2 Simon McVittie 2014-09-11 13:35:57 UTC
Created attachment 106132 [details] [review]
Replace some runtime assertions with compile-time  assertions

This requires a little bit of code re-ordering, because
_DBUS_STATIC_ASSERT can appear anywhere that a variable declaration
would be valid, i.e. not after executable code.
Comment 3 Alban Crequy 2014-09-12 16:24:58 UTC
Comment on attachment 106132 [details] [review]
Replace some runtime assertions with compile-time  assertions

Review of attachment 106132 [details] [review]:
-----------------------------------------------------------------

It looks good to me.
Comment 4 Simon McVittie 2014-09-15 12:02:23 UTC
Fixed in git for 1.9.0

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.