tree-wide: fix various lint warnings

Change-Id: I0fc80718eb7e02d84cc4b5d5deec4c0f41116134
This commit is contained in:
jade 2024-08-01 13:42:14 -07:00
parent 9238e62ae6
commit ca9d3e6e00
10 changed files with 25 additions and 18 deletions

View file

@ -53,7 +53,7 @@ void ConfigFile::apply()
bool trusted = whitelist.count(baseName); bool trusted = whitelist.count(baseName);
if (!trusted) { if (!trusted) {
switch (nix::fetchSettings.acceptFlakeConfig) { switch (nix::fetchSettings.acceptFlakeConfig.get()) {
case AcceptFlakeConfig::True: { case AcceptFlakeConfig::True: {
trusted = true; trusted = true;
break; break;

View file

@ -12,7 +12,6 @@
#include "state.hh" #include "state.hh"
#include <charconv> #include <charconv>
#include <clocale>
#include <memory> #include <memory>
// flip this define when doing parser development to enable some g checks. // flip this define when doing parser development to enable some g checks.
@ -254,7 +253,8 @@ struct AttrState : SubexprState {
std::vector<AttrName> attrs; std::vector<AttrName> attrs;
void pushAttr(auto && attr, PosIdx) { attrs.emplace_back(std::move(attr)); } template <typename T>
void pushAttr(T && attr, PosIdx) { attrs.emplace_back(std::forward<T>(attr)); }
}; };
template<> struct BuildAST<grammar::attr::simple> { template<> struct BuildAST<grammar::attr::simple> {
@ -290,7 +290,8 @@ struct InheritState : SubexprState {
std::unique_ptr<Expr> from; std::unique_ptr<Expr> from;
PosIdx fromPos; PosIdx fromPos;
void pushAttr(auto && attr, PosIdx pos) { attrs.emplace_back(std::move(attr), pos); } template <typename T>
void pushAttr(T && attr, PosIdx pos) { attrs.emplace_back(std::forward<T>(attr), pos); }
}; };
template<> struct BuildAST<grammar::inherit::from> { template<> struct BuildAST<grammar::inherit::from> {

View file

@ -477,8 +477,17 @@ struct curlFileTransfer : public FileTransfer
~curlFileTransfer() ~curlFileTransfer()
{ {
stopWorkerThread(); try {
stopWorkerThread();
} catch (nix::Error e) {
// This can only fail if a socket to our own process cannot be
// written to, so it is always a bug in the program if it fails.
//
// Joining the thread would probably only cause a deadlock if this
// happened, so just die on purpose.
printError("failed to join curl file transfer worker thread: %1%", e.what());
std::terminate();
}
workerThread.join(); workerThread.join();
if (curlm) curl_multi_cleanup(curlm); if (curlm) curl_multi_cleanup(curlm);

View file

@ -33,7 +33,7 @@ Machine::Machine(decltype(storeUri) storeUri,
systemTypes(systemTypes), systemTypes(systemTypes),
sshKey(sshKey), sshKey(sshKey),
maxJobs(maxJobs), maxJobs(maxJobs),
speedFactor(speedFactor == 0.0f ? 1.0f : std::move(speedFactor)), speedFactor(speedFactor == 0.0f ? 1.0f : speedFactor),
supportedFeatures(supportedFeatures), supportedFeatures(supportedFeatures),
mandatoryFeatures(mandatoryFeatures), mandatoryFeatures(mandatoryFeatures),
sshPublicHostKey(sshPublicHostKey) sshPublicHostKey(sshPublicHostKey)

View file

@ -192,7 +192,7 @@ static Generator<Entry> parseObject(Source & source, const Path & path)
#define EXPECT(raw, kind) \ #define EXPECT(raw, kind) \
do { \ do { \
const auto s = readString(source); \ const auto s = readString(source); \
if (s != raw) { \ if (s != (raw)) { \
throw badArchive("expected " kind " tag"); \ throw badArchive("expected " kind " tag"); \
} \ } \
co_yield MetadataString{s}; \ co_yield MetadataString{s}; \

View file

@ -131,7 +131,7 @@ AutoCloseFD::AutoCloseFD(AutoCloseFD && that) : fd{that.fd}
} }
AutoCloseFD & AutoCloseFD::operator =(AutoCloseFD && that) AutoCloseFD & AutoCloseFD::operator =(AutoCloseFD && that) noexcept(false)
{ {
close(); close();
fd = that.fd; fd = that.fd;

View file

@ -229,7 +229,7 @@ Hash::Hash(std::string_view rest, HashType type, bool isSRI)
for (unsigned int n = 0; n < rest.size(); ++n) { for (unsigned int n = 0; n < rest.size(); ++n) {
char c = rest[rest.size() - n - 1]; char c = rest[rest.size() - n - 1];
unsigned char digit; size_t digit;
for (digit = 0; digit < base32Chars.size(); ++digit) /* !!! slow */ for (digit = 0; digit < base32Chars.size(); ++digit) /* !!! slow */
if (base32Chars[digit] == c) break; if (base32Chars[digit] == c) break;
if (digit >= 32) if (digit >= 32)

View file

@ -62,6 +62,8 @@ std::vector<std::string> shell_split(const std::string & input)
begin = ++iterator; begin = ++iterator;
} }
break; break;
// no other relevant cases; silence exhaustiveness compiler warning
default: break;
} }
} }

View file

@ -63,7 +63,7 @@ std::string percentDecode(std::string_view in)
if (i + 2 >= in.size()) if (i + 2 >= in.size())
throw BadURL("invalid URI parameter '%s'", in); throw BadURL("invalid URI parameter '%s'", in);
try { try {
decoded += std::stoul(std::string(in, i + 1, 2), 0, 16); decoded += char8_t(std::stoul(std::string(in, i + 1, 2), 0, 16));
i += 3; i += 3;
} catch (...) { } catch (...) {
throw BadURL("invalid URI parameter '%s'", in); throw BadURL("invalid URI parameter '%s'", in);

View file

@ -1,20 +1,16 @@
#include "cli-literate-parser.hh" #include "cli-literate-parser.hh"
#include "escape-string.hh" #include "escape-string.hh"
#include "escape-char.hh"
#include "libexpr/print.hh"
#include "types.hh" #include "types.hh"
#include <ranges> #include <ranges>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/trim.hpp> #include <boost/algorithm/string/trim.hpp>
#include <iostream> #include <iostream>
#include <memory>
#include <sstream> #include <sstream>
#include <variant> #include <variant>
#include "cli-literate-parser.hh" #include "cli-literate-parser.hh"
#include "escape-string.hh" #include "escape-string.hh"
#include "fmt.hh" #include "fmt.hh"
#include "libexpr/print.hh"
#include "shlex.hh" #include "shlex.hh"
#include "types.hh" #include "types.hh"
#include "strings.hh" #include "strings.hh"
@ -361,9 +357,8 @@ const char * ParseError::what() const noexcept
return what_->c_str(); return what_->c_str();
} else { } else {
auto escaped = escapeString(rest, {.maxLength = 256, .escapeNonPrinting = true}); auto escaped = escapeString(rest, {.maxLength = 256, .escapeNonPrinting = true});
auto hint = auto hint = HintFmt("Parse error: Expected %1%, got:\n%2%", expected, Uncolored(escaped));
new HintFmt("Parse error: Expected %1%, got:\n%2%", expected, Uncolored(escaped)); what_ = hint.str();
what_ = hint->str();
return what_->c_str(); return what_->c_str();
} }
} }