[PATCH 6/7] Protect 'orig_len' in |recover_unused_bytes| by DBUS_ENABLE_VERBOSE_MODE
tdz at users.sourceforge.net
Mon Aug 15 15:47:13 UTC 2016
Some thoughts on this problem: with gcc, one can do something like this:
__typeof (!(condition)) val __attribute__((__unused__));
} while (0)
// do debug
This should use the type of 'condition' without evaluating it. The
declared variable itself is unused. Unfortunately I don't know how to do
this with _dbus_verbose's VA args.
Maybe additional annotation can be used, like
#define DEBUG_OR(expression, default_value) \
(DEBUG ? expression : default_value)
and called like this:
my_debug_value = DEBUG_OR(compute_val(), 0);
Here DEBUG is evaluated by the C compiler, so compute_val() doesn't have
to protected by DEBUG-based preprocessor guards.
Am 15.08.2016 um 13:17 schrieb Simon McVittie:
> On 10/08/16 16:08, Thiago Macieira wrote:
>> One way I've solved this problem is to "use" the expression in even disabled
> That results in the expression's side-effects still happening: for
> instance if it calls a function, we pay the CPU cost of calling that
> function. I don't think we want that here.
Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 181 bytes
Desc: OpenPGP digital signature
More information about the dbus