[PATCH v2 2/2] util: Consolidate and improve workarounds for clang-tidy issue 58992