diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/content-address.cc | 4 | ||||
-rw-r--r-- | src/libstore/content-address.hh | 4 | ||||
-rw-r--r-- | src/libstore/filetransfer.cc | 5 | ||||
-rw-r--r-- | src/libstore/local-store.cc | 8 | ||||
-rw-r--r-- | src/libutil/logging.cc | 4 | ||||
-rw-r--r-- | src/libutil/source-path.cc | 1 |
6 files changed, 16 insertions, 10 deletions
diff --git a/src/libstore/content-address.cc b/src/libstore/content-address.cc index 77f23b0b3..811ddbed7 100644 --- a/src/libstore/content-address.cc +++ b/src/libstore/content-address.cc @@ -157,7 +157,7 @@ size_t StoreReferences::size() const return (self ? 1 : 0) + others.size(); } -ContentAddressWithReferences ContentAddressWithReferences::withoutRefs(const ContentAddress & ca) noexcept +ContentAddressWithReferences ContentAddressWithReferences::withoutRefs(const ContentAddress & ca) { return std::visit(overloaded { [&](const TextIngestionMethod &) -> ContentAddressWithReferences { @@ -177,7 +177,7 @@ ContentAddressWithReferences ContentAddressWithReferences::withoutRefs(const Con } std::optional<ContentAddressWithReferences> ContentAddressWithReferences::fromPartsOpt( - ContentAddressMethod method, Hash hash, StoreReferences refs) noexcept + ContentAddressMethod method, Hash hash, StoreReferences refs) { return std::visit(overloaded { [&](TextIngestionMethod _) -> std::optional<ContentAddressWithReferences> { diff --git a/src/libstore/content-address.hh b/src/libstore/content-address.hh index c4d619bdc..200543704 100644 --- a/src/libstore/content-address.hh +++ b/src/libstore/content-address.hh @@ -255,7 +255,7 @@ struct ContentAddressWithReferences * Create a `ContentAddressWithReferences` from a mere * `ContentAddress`, by claiming no references. */ - static ContentAddressWithReferences withoutRefs(const ContentAddress &) noexcept; + static ContentAddressWithReferences withoutRefs(const ContentAddress &); /** * Create a `ContentAddressWithReferences` from 3 parts: @@ -270,7 +270,7 @@ struct ContentAddressWithReferences * returns for invalid combinations. */ static std::optional<ContentAddressWithReferences> fromPartsOpt( - ContentAddressMethod method, Hash hash, StoreReferences refs) noexcept; + ContentAddressMethod method, Hash hash, StoreReferences refs); ContentAddressMethod getMethod() const; diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index b843a95f9..ef2480863 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -142,7 +142,7 @@ struct curlFileTransfer : public FileTransfer template<class T> void fail(T && e) { - failEx(std::make_exception_ptr(std::move(e))); + failEx(std::make_exception_ptr(std::forward<T>(e))); } LambdaSink finalSink; @@ -270,6 +270,9 @@ struct curlFileTransfer : public FileTransfer return 0; auto count = std::min(size * nitems, request.data->length() - readOffset); assert(count); + // Lint: this is turning a string into a byte array to hand to + // curl, which is fine. + // NOLINTNEXTLINE(bugprone-not-null-terminated-result) memcpy(buffer, request.data->data() + readOffset, count); readOffset += count; return count; diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index db3934d5e..f252b449c 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1315,10 +1315,12 @@ StorePath LocalStore::addToStoreFromDump(Source & source0, std::string_view name auto oldSize = dump.size(); constexpr size_t chunkSize = 65536; auto want = std::min(chunkSize, settings.narBufferSize - oldSize); - if (auto tmp = realloc(dumpBuffer.get(), oldSize + want)) { - dumpBuffer.release(); - dumpBuffer.reset((char*) tmp); + + auto *toRealloc = dumpBuffer.release(); + if (auto realloced = realloc(toRealloc, oldSize + want)) { + dumpBuffer.reset((char*) realloced); } else { + free(toRealloc); throw std::bad_alloc(); } auto got = 0; diff --git a/src/libutil/logging.cc b/src/libutil/logging.cc index 691b77e95..0e63f9bd6 100644 --- a/src/libutil/logging.cc +++ b/src/libutil/logging.cc @@ -69,8 +69,8 @@ public: case lvlWarn: c = '4'; break; case lvlNotice: case lvlInfo: c = '5'; break; case lvlTalkative: case lvlChatty: c = '6'; break; - case lvlDebug: case lvlVomit: c = '7'; break; - default: c = '7'; break; // should not happen, and missing enum case is reported by -Werror=switch-enum + case lvlDebug: case lvlVomit: + default: c = '7'; break; // default case should not happen, and missing enum case is reported by -Werror=switch-enum } prefix = std::string("<") + c + ">"; } diff --git a/src/libutil/source-path.cc b/src/libutil/source-path.cc index e6721f808..cfaac20c0 100644 --- a/src/libutil/source-path.cc +++ b/src/libutil/source-path.cc @@ -50,6 +50,7 @@ InputAccessor::DirEntries SourcePath::readDirectory() const case DT_REG: type = InputAccessor::Type::tRegular; break; case DT_LNK: type = InputAccessor::Type::tSymlink; break; case DT_DIR: type = InputAccessor::Type::tDirectory; break; + default: break; // unknown type } res.emplace(entry.name, type); } |