From 9d7c5eb93796777a2ef867bef33b39238032e40f Mon Sep 17 00:00:00 2001 From: crueter Date: Fri, 14 Nov 2025 22:26:08 -0500 Subject: [PATCH] shorten Signed-off-by: crueter --- src/common/logging/backend.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 49f13fc21f..a1966dc8a1 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -112,17 +112,13 @@ public: // This must be a static otherwise it would get checked on EVERY // instance of logging an entry... static std::string username = []() -> std::string { - const char* s = getenv("USER"); - if (s == nullptr) - s = getenv("USERNAME"); + char* s; - if (s == nullptr) - s = getenv("LOGNAME"); + if ((s = getenv("USER")) != nullptr || (s = getenv("USERNAME")) != nullptr + || (s = getenv("LOGNAME")) != nullptr) + return std::string{s}; - if (s == nullptr) - return std::string{}; - - return std::string{s}; + return std::string{}; }(); if (!username.empty()) boost::replace_all(message, username, "user");