clang-tidy: enable bugprone-implicit-widening-of-multiplication-result

Change-Id: I7c7bae6c27aa59da23097ec89305cfc60ec9e8e3
This commit is contained in:
Tom Hubrecht
2025-12-09 08:32:37 +00:00
parent b2bcd99d59
commit 3db533c637
19 changed files with 32 additions and 32 deletions
-2
View File
@@ -8,8 +8,6 @@ Checks:
- -bugprone-narrowing-conversions
# kind of nonsense
- -bugprone-easily-swappable-parameters
# too many warnings for now
- -bugprone-implicit-widening-of-multiplication-result
# Lix's exception handling is Questionable
- -bugprone-empty-catch
# many warnings
+2 -2
View File
@@ -210,9 +210,9 @@ void initLibExpr()
(resident) memory to be allocated. This might be a problem on
systems that don't overcommit. */
if (!getEnv("GC_INITIAL_HEAP_SIZE")) {
int64_t size = 32 * 1024 * 1024;
int64_t size = 32l * 1024 * 1024;
#if HAVE_SYSCONF && defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES)
int64_t maxSize = 384 * 1024 * 1024;
int64_t maxSize = 384l * 1024 * 1024;
int64_t pageSize = sysconf(_SC_PAGESIZE);
int64_t pages = sysconf(_SC_PHYS_PAGES);
if (pageSize != -1) {
+1 -1
View File
@@ -48,7 +48,7 @@ void detectStackOverflow()
requires an alternative stack, otherwise the signal cannot be
delivered when we're out of stack space. */
stack_t stack;
stack.ss_size = 4096 * 4 + MINSIGSTKSZ;
stack.ss_size = 4096ul * 4 + MINSIGSTKSZ;
static auto stackBuf = std::make_unique<std::vector<char>>(stack.ss_size);
stack.ss_sp = stackBuf->data();
if (!stack.ss_sp) throw Error("cannot allocate alternative stack");
+1 -1
View File
@@ -352,7 +352,7 @@ Derivation parseDerivation(
*/
static void printString(std::string & res, std::string_view s)
{
boost::container::small_vector<char, 64 * 1024> buffer;
boost::container::small_vector<char, 64ul * 1024> buffer;
buffer.reserve(s.size() * 2 + 2);
char * buf = buffer.data();
char * p = buf;
+1 -1
View File
@@ -333,7 +333,7 @@ struct TransferItem
// when the buffer is full (as determined by a historical magic value) we
// pause the transfer and wait for the receiver to unpause it when ready.
if (successfulStatuses.count(getHTTPStatus()) && state->data.size() > 1024 * 1024) {
if (successfulStatuses.count(getHTTPStatus()) && state->data.size() > 1024ul * 1024) {
return CURL_WRITEFUNC_PAUSE;
}
+1 -1
View File
@@ -253,7 +253,7 @@ time_t parseOlderThanTimeSpec(std::string_view timeSpec)
time_t curTime = time(0);
auto strDays = timeSpec.substr(0, timeSpec.size() - 1);
auto days = string2Int<int>(strDays);
auto days = string2Int<time_t>(strDays);
if (!days || *days < 1)
throw UsageError("invalid number of days specifier '%1%'", timeSpec);
+7 -4
View File
@@ -195,8 +195,8 @@ ref<Aws::Client::ClientConfiguration> S3Helper::makeConfig(
if (!endpoint.empty()) {
res->endpointOverride = endpoint;
}
res->requestTimeoutMs = 600 * 1000;
res->connectTimeoutMs = 5 * 1000;
res->requestTimeoutMs = 600l * 1000;
res->connectTimeoutMs = 5l * 1000;
res->retryStrategy = std::make_shared<RetryStrategy>();
res->caFile = settings.caFile;
// Use the system proxy env-vars in curl for s3, which is off by default for some reason
@@ -312,8 +312,11 @@ struct S3BinaryCacheStoreConfig final : BinaryCacheStoreConfig
"Whether to use multi-part uploads."};
const Setting<uint64_t> bufferSize{
this, 5 * 1024 * 1024, "buffer-size",
"Size (in bytes) of each part in multi-part uploads."};
this,
5ul * 1024 * 1024,
"buffer-size",
"Size (in bytes) of each part in multi-part uploads."
};
const std::string name() override { return "S3 Binary Cache Store"; }
+2 -2
View File
@@ -121,7 +121,7 @@ public:
{
}
AsyncBufferedInputStream(AsyncInputStream & inner, size_t bufSize = 32 * 1024)
AsyncBufferedInputStream(AsyncInputStream & inner, size_t bufSize = 32ul * 1024)
: AsyncBufferedInputStream(inner, make_ref<IoBuffer>(bufSize))
{
}
@@ -173,7 +173,7 @@ public:
{
}
AsyncBufferedOutputStream(AsyncOutputStream & inner, size_t bufSize = 32 * 1024)
AsyncBufferedOutputStream(AsyncOutputStream & inner, size_t bufSize = 32ul * 1024)
: AsyncBufferedOutputStream(inner, make_ref<IoBuffer>(bufSize))
{
}
+2 -2
View File
@@ -38,7 +38,7 @@ static const int COMPRESSION_LEVEL_DEFAULT = -1;
// Don't feed brotli too much at once.
struct ChunkedCompressionSink : CompressionSink
{
uint8_t outbuf[32 * 1024];
uint8_t outbuf[32ul * 1024];
void writeUnbuffered(std::string_view data) override
{
@@ -167,7 +167,7 @@ struct NoneSink : CompressionSink
struct BrotliDecompressionSource : Source
{
static constexpr size_t BUF_SIZE = 32 * 1024;
static constexpr size_t BUF_SIZE = 32ul * 1024;
std::unique_ptr<char[]> buf;
size_t avail_in = 0;
const uint8_t * next_in;
+1 -1
View File
@@ -133,7 +133,7 @@ Generator<Bytes> drainFDSource(int fd, bool block)
}
});
std::array<unsigned char, 64 * 1024> buf;
std::array<unsigned char, 64ul * 1024> buf;
while (1) {
checkInterrupt();
ssize_t rd = read(fd, buf.data(), buf.size());
+3 -3
View File
@@ -443,7 +443,7 @@ void writeFile(const Path & path, Source & source, mode_t mode)
{
AutoCloseFD fd = openForWrite(path, mode);
std::vector<char> buf(64 * 1024);
std::vector<char> buf(64ul * 1024);
try {
while (true) {
@@ -463,7 +463,7 @@ void writeFileExcl(const Path & path, Source & source, mode_t mode)
{
AutoCloseFD fd = openForWriteExcl(path, mode);
std::vector<char> buf(64 * 1024);
std::vector<char> buf(64ul * 1024);
try {
while (true) {
@@ -483,7 +483,7 @@ kj::Promise<Result<void>> writeFile(const Path & path, AsyncInputStream & source
try {
AutoCloseFD fd = openForWrite(path, mode);
std::vector<char> buf(64 * 1024);
std::vector<char> buf(64ul * 1024);
try {
while (true) {
+2 -3
View File
@@ -191,9 +191,8 @@ Hash::Hash(std::string_view rest, HashType type, bool isSRI)
};
for (unsigned int i = 0; i < hashSize; i++) {
hash[i] =
parseHexDigit(rest[i * 2]) << 4
| parseHexDigit(rest[i * 2 + 1]);
const size_t j = i << 1;
hash[i] = parseHexDigit(rest[j]) << 4 | parseHexDigit(rest[j + 1]);
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ class IoBuffer
std::unique_ptr<char[]> buffer;
public:
explicit IoBuffer(size_t bufSize = 32 * 1024) : bufSize(bufSize) {}
explicit IoBuffer(size_t bufSize = 32ul * 1024) : bufSize(bufSize) {}
size_t size() const
{
+2 -2
View File
@@ -107,8 +107,8 @@ struct RpcLogger : Logger
}
buffer->sizeEstimate += sizeof(e) + extraSize;
buffer->items.emplace_back(std::move(e));
return buffer->sizeEstimate >= 1024 * 1024 ? BufferState::NeedsFlush
: BufferState::HasSpace;
return buffer->sizeEstimate >= static_cast<size_t>(1024 * 1024) ? BufferState::NeedsFlush
: BufferState::HasSpace;
}
BufferState log(Verbosity lvl, std::string_view s) override
+1 -1
View File
@@ -214,7 +214,7 @@ Pid startProcess(std::function<void()> fun, const ProcessOptions & options)
// Not supported, since then we don't know when to free the stack.
assert(!(options.cloneFlags & CLONE_VM));
size_t stackSize = 1 * 1024 * 1024;
size_t stackSize = 1ul * 1024 * 1024;
auto stack = static_cast<char *>(mmap(0, stackSize,
PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0));
if (stack == MAP_FAILED) throw SysError("allocating stack");
+2 -2
View File
@@ -53,7 +53,7 @@ struct BufferedSink : virtual Sink
{
ref<IoBuffer> buffer;
BufferedSink(size_t bufSize = 32 * 1024) : buffer(make_ref<IoBuffer>(bufSize)) {}
BufferedSink(size_t bufSize = 32ul * 1024) : buffer(make_ref<IoBuffer>(bufSize)) {}
explicit BufferedSink(ref<IoBuffer> buffer) : buffer(std::move(buffer)) {}
void operator () (std::string_view data) override;
@@ -105,7 +105,7 @@ struct BufferedSource : Source
{
ref<IoBuffer> buffer;
BufferedSource(size_t bufSize = 32 * 1024) : buffer(make_ref<IoBuffer>(bufSize)) {}
BufferedSource(size_t bufSize = 32ul * 1024) : buffer(make_ref<IoBuffer>(bufSize)) {}
explicit BufferedSource(ref<IoBuffer> buffer) : buffer(std::move(buffer)) {}
size_t read(char * data, size_t len) override;
+1 -1
View File
@@ -152,7 +152,7 @@ void renderDiffInfo(
const std::string_view indent)
{
for (auto & [name, item] : diff) {
auto showDelta = std::abs(item.sizeDelta) >= 8 * 1024;
auto showDelta = std::abs(item.sizeDelta) >= 8l * 1024;
std::vector<std::string> line;
if (!item.removedVersions.empty() || !item.addedVersions.empty())
+1 -1
View File
@@ -659,7 +659,7 @@ int main(int argc, char * * argv)
// Increase the default stack size for the evaluator and for
// libstdc++'s std::regex.
nix::setStackSize(64 * 1024 * 1024);
nix::setStackSize(64ul * 1024 * 1024);
return nix::handleExceptions(argv[0], [&]() {
nix::AsyncIoRoot aio;
+1 -1
View File
@@ -256,7 +256,7 @@ TEST(FileTransfer, NOT_ON_DARWIN(defersFailures))
// initial wait for header data will also wait for the the response to
// complete (the source is only woken when curl returns data, and curl
// might only do so once its internal buffer has already been filled.)
return std::string(1024 * 1024, ' ');
return std::string(static_cast<size_t>(1024 * 1024), ' ');
});
AsyncIoRoot aio;
auto ft = makeFileTransfer(0);