From fd6f06c1af13d1624165095a7cd00c83820d9587 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 9 Feb 2023 10:54:24 -0800 Subject: [PATCH] Replace various #if 0 with if constexpr for regression visibility. --- ircd/exec.cc | 50 +++++++++++++++++++++++--------------------- ircd/server.cc | 34 +++++++++++++++--------------- ircd/sys.cc | 15 +++++++------ matrix/fetch.cc | 29 +++++++++++++------------ matrix/vm_execute.cc | 30 +++++++++++++------------- modules/m_push.cc | 23 ++++++++++---------- 6 files changed, 89 insertions(+), 92 deletions(-) diff --git a/ircd/exec.cc b/ircd/exec.cc index ae64b1f6b..f0d49ebd8 100644 --- a/ircd/exec.cc +++ b/ircd/exec.cc @@ -332,18 +332,19 @@ void ircd::exec::handler::on_exec_setup(executor &ex) const noexcept { - #if 0 // outputs from child; don't want - assert(e); - - log::logf + if constexpr((false)) // outputs from child; don't want { - log, log::level::DEBUG, - "id:%lu pid:%ld `%s' executing...", - e->id, - e->pid, - e->path, - }; - #endif + assert(e); + + log::logf + { + log, log::level::DEBUG, + "id:%lu pid:%ld `%s' executing...", + e->id, + e->pid, + e->path, + }; + } // Set the parent death signal in case of a crash so we won't go zombie. #if defined(HAVE_SYS_PRCTL_H) @@ -462,20 +463,21 @@ ircd::exec::handler::on_exec_error(executor &ex, const std::error_code &ec) const noexcept { - #if 0 // outputs from child; don't want - assert(e); - - char ecbuf[64]; - log::error + if constexpr((false)) // outputs from child; don't want { - log, "id:%lu pid:%ld `%s' exec() #%ld :%s", - e->id, - e->pid, - e->path, - ec.value(), - string(ecbuf, ec), - }; - #endif + assert(e); + + char ecbuf[64]; + log::error + { + log, "id:%lu pid:%ld `%s' exec() #%ld :%s", + e->id, + e->pid, + e->path, + ec.value(), + string(ecbuf, ec), + }; + } } template diff --git a/ircd/server.cc b/ircd/server.cc index d4d04952b..7d313c3ea 100644 --- a/ircd/server.cc +++ b/ircd/server.cc @@ -2273,15 +2273,16 @@ ircd::server::link::submit(request &request) request.tag? queue.emplace(end(queue), std::move(*request.tag)): queue.emplace(end(queue), request) }; -/* - log::debug - { - log, "tag(%p) submitted to link(%p) queue: %zu", - &(*it), - this, - tag_count() - }; -*/ + + if constexpr((false)) + log::debug + { + log, "tag(%p) submitted to link(%p) queue: %zu", + &(*it), + this, + tag_count() + }; + if(ready()) wait_writable(); } @@ -2347,14 +2348,13 @@ ircd::server::link::cleanup_canceled() continue; } - #if 0 - log::dwarning - { - log, "%s removing abandoned tag:%lu", - loghead(*this), - tag.state.id, - }; - #endif + if constexpr((false)) + log::dwarning + { + log, "%s removing abandoned tag:%lu", + loghead(*this), + tag.state.id, + }; it = queue.erase(it); } diff --git a/ircd/sys.cc b/ircd/sys.cc index a3f472349..49add3060 100644 --- a/ircd/sys.cc +++ b/ircd/sys.cc @@ -47,14 +47,13 @@ catch(const ctx::interrupted &) } catch(const std::exception &e) { - #if 0 - log::derror - { - log, "sysfs query `%s' :%s", - relpath, - e.what(), - }; - #endif + if constexpr((false)) + log::derror + { + log, "sysfs query `%s' :%s", + relpath, + e.what(), + }; return {}; } diff --git a/matrix/fetch.cc b/matrix/fetch.cc index cb0c92d13..caec41ba7 100644 --- a/matrix/fetch.cc +++ b/matrix/fetch.cc @@ -754,21 +754,20 @@ ircd::m::fetch::finish(request &request) { request.finished = ircd::now(); - #if 0 - log::logf - { - log, request.eptr? log::DERROR: log::DEBUG, - "Finished %s in %s started:%ld finished:%d attempted:%zu abandon:%b %s%s", - string_view{request.opts.event_id}, - string_view{request.opts.room_id}, - duration_cast(tse(request.started)).count(), - duration_cast(tse(request.finished)).count(), - request.attempted.size(), - !request.promise, - request.eptr? " :" : "", - what(request.eptr), - }; - #endif + if constexpr((false)) + log::logf + { + log, request.eptr? log::DERROR: log::DEBUG, + "Finished %s in %s started:%ld finished:%d attempted:%zu abandon:%b %s%s", + string_view{request.opts.event_id}, + string_view{request.opts.room_id}, + duration_cast(tse(request.started)).count(), + duration_cast(tse(request.finished)).count(), + request.attempted.size(), + !request.promise, + request.eptr? " :" : "", + what(request.eptr), + }; if(!request.promise) return; diff --git a/matrix/vm_execute.cc b/matrix/vm_execute.cc index 08c35e05e..dd470a547 100644 --- a/matrix/vm_execute.cc +++ b/matrix/vm_execute.cc @@ -1397,14 +1397,13 @@ ircd::m::vm::call_hook(hook::site &hook, T&& data) try { - #if 0 - log::debug - { - log, "%s hook:%s enter", - loghead(eval), - hook.name(), - }; - #endif + if constexpr((false)) + log::debug + { + log, "%s hook:%s enter", + loghead(eval), + hook.name(), + }; // Providing a pointer to the eval.hook pointer allows the hook site to // provide updates for observers in other contexts for which hook is @@ -1416,14 +1415,13 @@ try hook(cur, event, std::forward(data)); - #if 0 - log::debug - { - log, "%s hook:%s leave", - loghead(eval), - hook.name(), - }; - #endif + if constexpr((false)) + log::debug + { + log, "%s hook:%s leave", + loghead(eval), + hook.name(), + }; } catch(const m::error &e) { diff --git a/modules/m_push.cc b/modules/m_push.cc index de4e5b7e0..56837a515 100644 --- a/modules/m_push.cc +++ b/modules/m_push.cc @@ -148,18 +148,17 @@ try event, rule, opts }; - #if 0 - log::debug - { - log, "event %s rule { %s, %s, %s } for %s %s", - string_view{event.event_id}, - scope, - kind, - ruleid, - string_view{user_id}, - bool(match)? "MATCH"_sv : string_view{} - }; - #endif + if constexpr((false)) + log::debug + { + log, "event %s rule { %s, %s, %s } for %s %s", + string_view{event.event_id}, + scope, + kind, + ruleid, + string_view{user_id}, + bool(match)? "MATCH"_sv : string_view{} + }; return bool(match); }