mirror of
https://github.com/NixOS/nix
synced 2025-06-27 12:41:15 +02:00
chore: get rid of dead code and unused variables where appropriate
Looks like some cruft has been left over from previous refactorings. This removes dead variables, which should not have side effects in their constructors. In cases where the variable initialization has a purpose [[maybe_unused]] is inserted to silence compiler warnings.
This commit is contained in:
parent
feb46688a2
commit
756758d968
12 changed files with 4 additions and 20 deletions
|
@ -129,7 +129,6 @@ std::pair<SourcePath, uint32_t> findPackageFilename(EvalState & state, Value & v
|
||||||
try {
|
try {
|
||||||
auto colon = fn.rfind(':');
|
auto colon = fn.rfind(':');
|
||||||
if (colon == std::string::npos) fail();
|
if (colon == std::string::npos) fail();
|
||||||
std::string filename(fn, 0, colon);
|
|
||||||
auto lineno = std::stoi(std::string(fn, colon + 1, std::string::npos));
|
auto lineno = std::stoi(std::string(fn, colon + 1, std::string::npos));
|
||||||
return {SourcePath{path.accessor, CanonPath(fn.substr(0, colon))}, lineno};
|
return {SourcePath{path.accessor, CanonPath(fn.substr(0, colon))}, lineno};
|
||||||
} catch (std::invalid_argument & e) {
|
} catch (std::invalid_argument & e) {
|
||||||
|
|
|
@ -66,14 +66,12 @@ StringMap EvalState::realiseContext(const NixStringContext & context, StorePathS
|
||||||
ensureValid(b.drvPath->getBaseStorePath());
|
ensureValid(b.drvPath->getBaseStorePath());
|
||||||
},
|
},
|
||||||
[&](const NixStringContextElem::Opaque & o) {
|
[&](const NixStringContextElem::Opaque & o) {
|
||||||
auto ctxS = store->printStorePath(o.path);
|
|
||||||
ensureValid(o.path);
|
ensureValid(o.path);
|
||||||
if (maybePathsOut)
|
if (maybePathsOut)
|
||||||
maybePathsOut->emplace(o.path);
|
maybePathsOut->emplace(o.path);
|
||||||
},
|
},
|
||||||
[&](const NixStringContextElem::DrvDeep & d) {
|
[&](const NixStringContextElem::DrvDeep & d) {
|
||||||
/* Treat same as Opaque */
|
/* Treat same as Opaque */
|
||||||
auto ctxS = store->printStorePath(d.drvPath);
|
|
||||||
ensureValid(d.drvPath);
|
ensureValid(d.drvPath);
|
||||||
if (maybePathsOut)
|
if (maybePathsOut)
|
||||||
maybePathsOut->emplace(d.drvPath);
|
maybePathsOut->emplace(d.drvPath);
|
||||||
|
|
|
@ -514,8 +514,6 @@ struct GitInputScheme : InputScheme
|
||||||
|
|
||||||
auto origRev = input.getRev();
|
auto origRev = input.getRev();
|
||||||
|
|
||||||
std::string name = input.getName();
|
|
||||||
|
|
||||||
auto originalRef = input.getRef();
|
auto originalRef = input.getRef();
|
||||||
auto ref = originalRef ? *originalRef : getDefaultRef(repoInfo);
|
auto ref = originalRef ? *originalRef : getDefaultRef(repoInfo);
|
||||||
input.attrs.insert_or_assign("ref", ref);
|
input.attrs.insert_or_assign("ref", ref);
|
||||||
|
|
|
@ -257,8 +257,6 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
|
||||||
{
|
{
|
||||||
using namespace fetchers;
|
using namespace fetchers;
|
||||||
|
|
||||||
std::smatch match;
|
|
||||||
|
|
||||||
if (auto res = parseFlakeIdRef(fetchSettings, url, isFlake)) {
|
if (auto res = parseFlakeIdRef(fetchSettings, url, isFlake)) {
|
||||||
return *res;
|
return *res;
|
||||||
} else if (auto res = parseURLFlakeRef(fetchSettings, url, baseDir, isFlake)) {
|
} else if (auto res = parseURLFlakeRef(fetchSettings, url, baseDir, isFlake)) {
|
||||||
|
|
|
@ -1229,7 +1229,7 @@ HookReply DerivationGoal::tryBuildHook()
|
||||||
hook->toHook.writeSide.close();
|
hook->toHook.writeSide.close();
|
||||||
|
|
||||||
/* Create the log file and pipe. */
|
/* Create the log file and pipe. */
|
||||||
Path logFile = openLogFile();
|
[[maybe_unused]] Path logFile = openLogFile();
|
||||||
|
|
||||||
std::set<MuxablePipePollState::CommChannel> fds;
|
std::set<MuxablePipePollState::CommChannel> fds;
|
||||||
fds.insert(hook->fromHook.readSide.get());
|
fds.insert(hook->fromHook.readSide.get());
|
||||||
|
|
|
@ -13,14 +13,9 @@ void Store::exportPaths(const StorePathSet & paths, Sink & sink)
|
||||||
auto sorted = topoSortPaths(paths);
|
auto sorted = topoSortPaths(paths);
|
||||||
std::reverse(sorted.begin(), sorted.end());
|
std::reverse(sorted.begin(), sorted.end());
|
||||||
|
|
||||||
std::string doneLabel("paths exported");
|
|
||||||
//logger->incExpected(doneLabel, sorted.size());
|
|
||||||
|
|
||||||
for (auto & path : sorted) {
|
for (auto & path : sorted) {
|
||||||
//Activity act(*logger, lvlInfo, "exporting path '%s'", path);
|
|
||||||
sink << 1;
|
sink << 1;
|
||||||
exportPath(path, sink);
|
exportPath(path, sink);
|
||||||
//logger->incProgress(doneLabel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sink << 0;
|
sink << 0;
|
||||||
|
|
|
@ -883,7 +883,7 @@ void LocalDerivationGoal::startBuilder()
|
||||||
printMsg(lvlVomit, "setting builder env variable '%1%'='%2%'", i.first, i.second);
|
printMsg(lvlVomit, "setting builder env variable '%1%'='%2%'", i.first, i.second);
|
||||||
|
|
||||||
/* Create the log file. */
|
/* Create the log file. */
|
||||||
Path logFile = openLogFile();
|
[[maybe_unused]] Path logFile = openLogFile();
|
||||||
|
|
||||||
/* Create a pseudoterminal to get the output of the builder. */
|
/* Create a pseudoterminal to get the output of the builder. */
|
||||||
builderOut = posix_openpt(O_RDWR | O_NOCTTY);
|
builderOut = posix_openpt(O_RDWR | O_NOCTTY);
|
||||||
|
|
|
@ -136,7 +136,6 @@ TEST_F(nix_api_util_context, nix_err_name)
|
||||||
// no error
|
// no error
|
||||||
EXPECT_THROW(nix_err_name(NULL, ctx, OBSERVE_STRING(err_name)), nix::Error);
|
EXPECT_THROW(nix_err_name(NULL, ctx, OBSERVE_STRING(err_name)), nix::Error);
|
||||||
|
|
||||||
std::string err_msg_ref;
|
|
||||||
try {
|
try {
|
||||||
throw nix::Error("testing error");
|
throw nix::Error("testing error");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
|
@ -90,7 +90,6 @@ void Source::operator () (std::string_view data)
|
||||||
|
|
||||||
void Source::drainInto(Sink & sink)
|
void Source::drainInto(Sink & sink)
|
||||||
{
|
{
|
||||||
std::string s;
|
|
||||||
std::array<char, 8192> buf;
|
std::array<char, 8192> buf;
|
||||||
while (true) {
|
while (true) {
|
||||||
size_t n;
|
size_t n;
|
||||||
|
@ -427,7 +426,7 @@ Error readError(Source & source)
|
||||||
auto type = readString(source);
|
auto type = readString(source);
|
||||||
assert(type == "Error");
|
assert(type == "Error");
|
||||||
auto level = (Verbosity) readInt(source);
|
auto level = (Verbosity) readInt(source);
|
||||||
auto name = readString(source); // removed
|
[[maybe_unused]] auto name = readString(source); // removed
|
||||||
auto msg = readString(source);
|
auto msg = readString(source);
|
||||||
ErrorInfo info {
|
ErrorInfo info {
|
||||||
.level = level,
|
.level = level,
|
||||||
|
|
|
@ -26,7 +26,7 @@ bool isTTY()
|
||||||
|
|
||||||
std::string filterANSIEscapes(std::string_view s, bool filterAll, unsigned int width)
|
std::string filterANSIEscapes(std::string_view s, bool filterAll, unsigned int width)
|
||||||
{
|
{
|
||||||
std::string t, e;
|
std::string t;
|
||||||
size_t w = 0;
|
size_t w = 0;
|
||||||
auto i = s.begin();
|
auto i = s.begin();
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,6 @@ struct CmdSearch : InstallableValueCommand, MixJSON
|
||||||
{"description", description},
|
{"description", description},
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
auto name2 = hiliteMatches(name.name, nameMatches, ANSI_GREEN, "\e[0;2m");
|
|
||||||
if (results > 1) logger->cout("");
|
if (results > 1) logger->cout("");
|
||||||
logger->cout(
|
logger->cout(
|
||||||
"* %s%s",
|
"* %s%s",
|
||||||
|
|
|
@ -41,7 +41,6 @@ struct CmdCopySigs : StorePathsCommand
|
||||||
|
|
||||||
ThreadPool pool;
|
ThreadPool pool;
|
||||||
|
|
||||||
std::string doneLabel = "done";
|
|
||||||
std::atomic<size_t> added{0};
|
std::atomic<size_t> added{0};
|
||||||
|
|
||||||
//logger->setExpected(doneLabel, storePaths.size());
|
//logger->setExpected(doneLabel, storePaths.size());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue