aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/charptr-cast.hh1
-rw-r--r--src/libutil/compression.cc7
-rw-r--r--src/libutil/file-descriptor.cc3
-rw-r--r--src/libutil/tarfile.cc3
4 files changed, 9 insertions, 5 deletions
diff --git a/src/libutil/charptr-cast.hh b/src/libutil/charptr-cast.hh
index 990f2ec55..ec53d8924 100644
--- a/src/libutil/charptr-cast.hh
+++ b/src/libutil/charptr-cast.hh
@@ -134,6 +134,7 @@ template<typename To, typename From>
requires charptr_cast_detail::IsCharCastable<From, To>
inline To charptr_cast(From p)
{
+ // NOLINTNEXTLINE(lix-charptrcast): stop the linter ever getting too clever and causing funny recursion
return reinterpret_cast<To>(p);
}
diff --git a/src/libutil/compression.cc b/src/libutil/compression.cc
index 6b0fa9d15..5152a2146 100644
--- a/src/libutil/compression.cc
+++ b/src/libutil/compression.cc
@@ -1,3 +1,4 @@
+#include "charptr-cast.hh"
#include "compression.hh"
#include "tarfile.hh"
#include "signals.hh"
@@ -160,7 +161,7 @@ struct BrotliDecompressionSource : Source
size_t read(char * data, size_t len) override
{
- uint8_t * out = reinterpret_cast<uint8_t *>(data);
+ uint8_t * out = charptr_cast<uint8_t *>(data);
const auto * begin = out;
while (len && !BrotliDecoderIsFinished(state.get())) {
@@ -172,7 +173,7 @@ struct BrotliDecompressionSource : Source
} catch (EndOfFile &) {
break;
}
- next_in = reinterpret_cast<const uint8_t *>(buf.get());
+ next_in = charptr_cast<const uint8_t *>(buf.get());
}
if (!BrotliDecoderDecompressStream(
@@ -238,7 +239,7 @@ struct BrotliCompressionSink : ChunkedCompressionSink
void writeInternal(std::string_view data) override
{
- auto next_in = reinterpret_cast<const uint8_t *>(data.data());
+ auto next_in = charptr_cast<const uint8_t *>(data.data());
size_t avail_in = data.size();
uint8_t * next_out = outbuf;
size_t avail_out = sizeof(outbuf);
diff --git a/src/libutil/file-descriptor.cc b/src/libutil/file-descriptor.cc
index 7c82988b3..be9f8c889 100644
--- a/src/libutil/file-descriptor.cc
+++ b/src/libutil/file-descriptor.cc
@@ -1,3 +1,4 @@
+#include "charptr-cast.hh"
#include "file-system.hh"
#include "finally.hh"
#include "logging.hh"
@@ -115,7 +116,7 @@ Generator<Bytes> drainFDSource(int fd, bool block)
throw SysError("reading from file");
}
else if (rd == 0) break;
- else co_yield std::span{reinterpret_cast<char *>(buf.data()), (size_t) rd};
+ else co_yield std::span{charptr_cast<char *>(buf.data()), (size_t) rd};
}
}
diff --git a/src/libutil/tarfile.cc b/src/libutil/tarfile.cc
index f024149ec..316751533 100644
--- a/src/libutil/tarfile.cc
+++ b/src/libutil/tarfile.cc
@@ -1,6 +1,7 @@
#include <archive.h>
#include <archive_entry.h>
+#include "charptr-cast.hh"
#include "file-system.hh"
#include "logging.hh"
#include "serialise.hh"
@@ -19,7 +20,7 @@ static ssize_t callback_read(struct archive * archive, void * _self, const void
*buffer = self->buffer.data();
try {
- return self->source->read(reinterpret_cast<char *>(self->buffer.data()), self->buffer.size());
+ return self->source->read(charptr_cast<char *>(self->buffer.data()), self->buffer.size());
} catch (EndOfFile &) {
return 0;
} catch (std::exception & err) {