From d8c09b583644105c25e3023e98ffceb75333af2e Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 14 Jul 2024 22:43:50 +0200 Subject: [PATCH] libutil: remove warnOnce macro it's only used once, and even that one use is highly questionable. more instances of warnOnce should be much more principled than this has been Change-Id: I5856570c99cb44462e700d753d0c706a5db03c4b --- src/libmain/shared.cc | 10 +++++++--- src/libutil/logging.hh | 6 ------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index af7f46d87..a407c647f 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -33,9 +33,13 @@ void printGCWarning() { if (!gcWarning) return; static bool haveWarned = false; - warnOnce(haveWarned, - "you did not specify '--add-root'; " - "the result might be removed by the garbage collector"); + if (!haveWarned) { + haveWarned = true; + warn( + "you did not specify '--add-root'; " + "the result might be removed by the garbage collector" + ); + } } diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh index 7990ffce0..96f9f0782 100644 --- a/src/libutil/logging.hh +++ b/src/libutil/logging.hh @@ -283,12 +283,6 @@ inline void warn(const std::string & fs, const Args & ... args) logger->warn(HintFmt(fs, args...).str()); } -#define warnOnce(haveWarned, args...) \ - if (!haveWarned) { \ - haveWarned = true; \ - warn(args); \ - } - void writeToStderr(std::string_view s); }