Jeremy Cole <jeremycole@google.com> writes:
The attached patch adds what amounts to compile-time checking for unmatched DBUG_ENTER/DBUG_LEAVE (DBUG_RETURN, DBUG_VOID_RETURN) by introducing a variable in DBUG_ENTER which is only used in DBUG_LEAVE. This allows any compiler which can robustly detect unused variables to detect the mismatch at compile-time. There is already a run-time check for this case, but it is somewhat limited as it requires _db_return_ to be called in order to detect the mismatch, and this is in practice not always the case. Particularly three cases allow this to escape detection:
Ideally we'd be able to check for gcc attribute noreturn but I'm not sure there's a way to do that (as it's not a preproceessor thing). I'm pretty sure that with some optimization levels that the temp variable can get optimized out (although I haven't looked at the produced code). Personally, looks good and I'm tempted to pull it into Percona Server. -- Stewart Smith