aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/error.hh5
-rw-r--r--src/libutil/finally.hh1
-rw-r--r--src/libutil/hash.cc3
-rw-r--r--src/libutil/serialise.cc1
-rw-r--r--src/libutil/serialise.hh25
-rw-r--r--src/libutil/signals.cc1
-rw-r--r--src/libutil/thread-pool.hh1
-rw-r--r--src/libutil/url.hh1
-rw-r--r--src/libutil/variant-wrapper.hh2
9 files changed, 27 insertions, 13 deletions
diff --git a/src/libutil/error.hh b/src/libutil/error.hh
index 06dfba0df..73c1ccadd 100644
--- a/src/libutil/error.hh
+++ b/src/libutil/error.hh
@@ -16,16 +16,12 @@
*/
#include "suggestions.hh"
-#include "ref.hh"
-#include "types.hh"
#include "fmt.hh"
#include <cstring>
#include <list>
#include <memory>
-#include <map>
#include <optional>
-#include <compare>
#include <sys/types.h>
#include <sys/stat.h>
@@ -173,6 +169,7 @@ public:
};
#define MakeError(newClass, superClass) \
+ /* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
class newClass : public superClass \
{ \
public: \
diff --git a/src/libutil/finally.hh b/src/libutil/finally.hh
index dc51d7b1e..5e62dfa3b 100644
--- a/src/libutil/finally.hh
+++ b/src/libutil/finally.hh
@@ -22,6 +22,7 @@ public:
Finally(Finally &&other) : fun(std::move(other.fun)) {
other.movedFrom = true;
}
+ // NOLINTNEXTLINE(bugprone-exception-escape): the noexcept is declared properly here, the analysis seems broken
~Finally() noexcept(noexcept(fun()))
{
try {
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc
index 925f71f80..f05d4aa98 100644
--- a/src/libutil/hash.cc
+++ b/src/libutil/hash.cc
@@ -7,6 +7,7 @@
#include "args.hh"
#include "hash.hh"
#include "archive.hh"
+#include "charptr-cast.hh"
#include "logging.hh"
#include "split.hh"
@@ -129,7 +130,7 @@ std::string Hash::to_string(Base base, bool includeType) const
break;
case Base::Base64:
case Base::SRI:
- s += base64Encode(std::string_view(reinterpret_cast<const char *>(hash), hashSize));
+ s += base64Encode(std::string_view(charptr_cast<const char *>(hash), hashSize));
break;
}
return s;
diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc
index f1db05b0b..a6dd7e200 100644
--- a/src/libutil/serialise.cc
+++ b/src/libutil/serialise.cc
@@ -1,4 +1,5 @@
#include "serialise.hh"
+#include "charptr-cast.hh"
#include "signals.hh"
#include <cstring>
diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh
index 8218db440..d6a22b3e9 100644
--- a/src/libutil/serialise.hh
+++ b/src/libutil/serialise.hh
@@ -4,6 +4,7 @@
#include <concepts>
#include <memory>
+#include "charptr-cast.hh"
#include "generator.hh"
#include "strings.hh"
#include "types.hh"
@@ -385,7 +386,7 @@ struct SerializingTransform
buf[5] = (n >> 40) & 0xff;
buf[6] = (n >> 48) & 0xff;
buf[7] = (unsigned char) (n >> 56) & 0xff;
- return {reinterpret_cast<const char *>(buf.begin()), 8};
+ return {charptr_cast<const char *>(buf.begin()), 8};
}
static Bytes padding(size_t unpadded)
@@ -417,6 +418,9 @@ struct SerializingTransform
void writePadding(size_t len, Sink & sink);
+// NOLINTBEGIN(cppcoreguidelines-avoid-capturing-lambda-coroutines):
+// These coroutines do their entire job before the semicolon and are not
+// retained, so they live long enough.
inline Sink & operator<<(Sink & sink, uint64_t u)
{
return sink << [&]() -> WireFormatGenerator { co_yield u; }();
@@ -441,6 +445,7 @@ inline Sink & operator<<(Sink & sink, const Error & ex)
{
return sink << [&]() -> WireFormatGenerator { co_yield ex; }();
}
+// NOLINTEND(cppcoreguidelines-avoid-capturing-lambda-coroutines)
MakeError(SerialisationError, Error);
@@ -448,7 +453,7 @@ template<typename T>
T readNum(Source & source)
{
unsigned char buf[8];
- source((char *) buf, sizeof(buf));
+ source(charptr_cast<char *>(buf), sizeof(buf));
auto n = readLittleEndian<uint64_t>(buf);
@@ -540,13 +545,17 @@ struct FramedSource : Source
~FramedSource()
{
- if (!eof) {
- while (true) {
- auto n = readInt(from);
- if (!n) break;
- std::vector<char> data(n);
- from(data.data(), n);
+ try {
+ if (!eof) {
+ while (true) {
+ auto n = readInt(from);
+ if (!n) break;
+ std::vector<char> data(n);
+ from(data.data(), n);
+ }
}
+ } catch (...) {
+ ignoreException();
}
}
diff --git a/src/libutil/signals.cc b/src/libutil/signals.cc
index a94c2802a..04a697d01 100644
--- a/src/libutil/signals.cc
+++ b/src/libutil/signals.cc
@@ -3,6 +3,7 @@
#include "sync.hh"
#include "terminal.hh"
+#include <map>
#include <thread>
namespace nix {
diff --git a/src/libutil/thread-pool.hh b/src/libutil/thread-pool.hh
index 3db7ce88f..380e1a2d2 100644
--- a/src/libutil/thread-pool.hh
+++ b/src/libutil/thread-pool.hh
@@ -4,6 +4,7 @@
#include "error.hh"
#include "sync.hh"
+#include <map>
#include <queue>
#include <functional>
#include <thread>
diff --git a/src/libutil/url.hh b/src/libutil/url.hh
index d2413ec0e..a821301ba 100644
--- a/src/libutil/url.hh
+++ b/src/libutil/url.hh
@@ -2,6 +2,7 @@
///@file
#include "error.hh"
+#include <map>
namespace nix {
diff --git a/src/libutil/variant-wrapper.hh b/src/libutil/variant-wrapper.hh
index cedcb999c..a809cd2a4 100644
--- a/src/libutil/variant-wrapper.hh
+++ b/src/libutil/variant-wrapper.hh
@@ -8,6 +8,7 @@
* Force the default versions of all constructors (copy, move, copy
* assignment).
*/
+// NOLINTBEGIN(bugprone-macro-parentheses)
#define FORCE_DEFAULT_CONSTRUCTORS(CLASS_NAME) \
CLASS_NAME(const CLASS_NAME &) = default; \
CLASS_NAME(CLASS_NAME &) = default; \
@@ -15,6 +16,7 @@
\
CLASS_NAME & operator =(const CLASS_NAME &) = default; \
CLASS_NAME & operator =(CLASS_NAME &) = default;
+// NOLINTEND(bugprone-macro-parentheses)
/**
* Make a wrapper constructor. All args are forwarded to the