From d20c3d3643f34180ebe0d5397db9a3788aab6585 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Mon, 14 Jul 2025 17:17:12 +0200 Subject: [PATCH] libutil: remove ErrorInfo::programName it's effectively unused. one use is a write and a read immediately after the write, the other use checks whether it's not equal to itself (..wat) Change-Id: I5f6ce26e75a6bfa500c2e9ac3fc70e8dafc9bd74 --- lix/libmain/shared.cc | 3 +-- lix/libutil/error.cc | 8 +------- lix/libutil/error.hh | 2 -- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/lix/libmain/shared.cc b/lix/libmain/shared.cc index 5ac7df087..ef197502e 100644 --- a/lix/libmain/shared.cc +++ b/lix/libmain/shared.cc @@ -317,11 +317,10 @@ int handleExceptions(const std::string & programName, std::function fun) { ReceiveInterrupts receiveInterrupts; // FIXME: need better place for this - ErrorInfo::programName = baseNameOf(programName); /* Lix command line is not yet stabilized. * Explain that it is experimental and reserved for custom subcommands for now. * */ - bool onlyForSubcommands = ErrorInfo::programName == "lix"; + bool onlyForSubcommands = baseNameOf(programName) == "lix"; std::string error = ANSI_RED "error:" ANSI_NORMAL " "; try { diff --git a/lix/libutil/error.cc b/lix/libutil/error.cc index 34e2ec98f..93b188ba9 100644 --- a/lix/libutil/error.cc +++ b/lix/libutil/error.cc @@ -33,8 +33,6 @@ const std::string & BaseError::calcWhat() const } } -std::optional ErrorInfo::programName = std::nullopt; - std::ostream & operator <<(std::ostream & os, const HintFmt & hf) { return os << hf.str(); @@ -264,11 +262,7 @@ std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool s assert(false); } - // FIXME: show the program name as part of the trace? - if (einfo.programName && einfo.programName != ErrorInfo::programName) - prefix += fmt(" [%s]:" ANSI_NORMAL " ", einfo.programName.value_or("")); - else - prefix += ":" ANSI_NORMAL " "; + prefix += ":" ANSI_NORMAL " "; std::ostringstream oss; diff --git a/lix/libutil/error.hh b/lix/libutil/error.hh index d2c127ff2..dea4ecc31 100644 --- a/lix/libutil/error.hh +++ b/lix/libutil/error.hh @@ -89,8 +89,6 @@ struct ErrorInfo { unsigned int status = 1; Suggestions suggestions = {}; - - static std::optional programName; }; std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool showTrace);