Commit Graph

8 Commits

Author SHA1 Message Date
João Valverde 7aae691f7d wsutil: Rewrite ws_assert() to minimize dependencies
This includes as little as possible in the assertion header, so
that it can be included globally in every file without pulling
any unwanted definitions. In particular pulling stdlib.h is
avoided because that can have side effects if it wants to
include non-portable extensions.

It is possible to have side-effects from include glib.h too, for
example because of G_LOG_DOMAIN.

These side-effects are usually avoidable with careful ordering
of pre-processor directives but with multiple levels of indirections
it can be hard to track. Better to make it robust to these kinds
of failures in the first place.

Also integrate with our logger for a cohesive experience (but
keep it a private dependency).
2021-06-25 22:06:32 +00:00
Guy Harris 72b2cf6672 ws_assert: remove a stray semicolon at the end of an inline function. 2021-06-19 03:04:49 +00:00
João Valverde 1a702e5430 Try to avoid -Wunused with vanishing macros 2021-06-10 00:51:59 +01:00
João Valverde c4aa583d8e wsutil: Rename ws_assert_bounds()
It is not necessary to categorize every assertion that
is not conditional to WS_DISABLE_ASSERT.
2021-05-24 01:35:30 +00:00
João Valverde cee1b443b5 wsutil: Add ws_assert_bounds() 2021-05-20 03:01:05 +01:00
João Valverde adfb0b99c2 wsutil: Avoid using g_abort()
g_abort() requires GLib 2.50, our minimum required version
is 2.38.
2021-05-20 03:01:05 +01:00
João Valverde cf0cb5819f Fixup ws_assert() macro
Use a void expression instead of removing the expression
entirely. Under certain conditions, for example as the only
statement in an if() conditional, removing the assertion
will generate compiler warnings.
2021-05-20 03:01:05 +01:00
João Valverde 8eacd615c8 Disable assertions for release builds
Currently our build generates very many warnings if
G_DISABLE_ASSERT is defined.

Add ws_assert() and ws_assert_not_reached() to incrementally
replace existing assertions and then disable them using
WS_DISABLE_ASSERT.

Assertions are disabled with CMake build type Release.
By default the build type is RelWithDebInfo so the current
behaviour of enabling assertions by default is (for now) preserved.

Add some notes to README.Developer.
2021-05-19 03:52:45 +01:00