Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/libexpr/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,11 @@ class DebuggerGuard
inDebugger = true;
}

DebuggerGuard(DebuggerGuard &&) = delete;
DebuggerGuard(const DebuggerGuard &) = delete;
DebuggerGuard & operator=(DebuggerGuard &&) = delete;
DebuggerGuard & operator=(const DebuggerGuard &) = delete;

~DebuggerGuard()
{
inDebugger = false;
Expand Down
2 changes: 2 additions & 0 deletions src/libexpr/include/nix/expr/attr-set.hh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ private:
Bindings & operator=(const Bindings &) = delete;
Bindings & operator=(Bindings &&) = delete;

~Bindings() = default;

friend class BindingsBuilder;

/**
Expand Down
7 changes: 5 additions & 2 deletions src/libexpr/include/nix/expr/value.hh
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,18 @@ public:
Value ** elems;
ListBuilder(EvalMemory & mem, size_t size);

// NOTE: Can be noexcept because we are just copying integral values and
// raw pointers.
ListBuilder(ListBuilder && x) noexcept
: size(x.size)
, inlineElems{x.inlineElems[0], x.inlineElems[1]}
, elems(size <= 2 ? inlineElems : x.elems)
{
}

ListBuilder(const ListBuilder &) = delete;
ListBuilder & operator=(ListBuilder &&) = delete;
ListBuilder & operator=(const ListBuilder &) = delete;
~ListBuilder() = default;

Value *& operator[](size_t n)
{
return elems[n];
Expand Down
20 changes: 20 additions & 0 deletions src/libstore/include/nix/store/pathlocks.hh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ private:
public:
PathLocks();
PathLocks(const std::set<std::filesystem::path> & paths, const std::string & waitMsg = "");

PathLocks(PathLocks && other) noexcept
: fds(std::exchange(other.fds, {}))
, deletePaths(other.deletePaths)
{
}

PathLocks & operator=(PathLocks && other) noexcept
{
fds = std::exchange(other.fds, {});
deletePaths = other.deletePaths;
return *this;
}

PathLocks(const PathLocks &) = delete;
PathLocks & operator=(const PathLocks &) = delete;
bool lockPaths(const std::set<std::filesystem::path> & _paths, const std::string & waitMsg = "", bool wait = true);
~PathLocks();
void unlock();
Expand All @@ -45,6 +61,10 @@ struct FdLock
bool acquired = false;

FdLock(Descriptor desc, LockType lockType, bool wait, std::string_view waitMsg);
FdLock(const FdLock &) = delete;
FdLock & operator=(const FdLock &) = delete;
FdLock(FdLock &&) = delete;
FdLock & operator=(FdLock &&) = delete;

~FdLock()
{
Expand Down
18 changes: 18 additions & 0 deletions src/libutil/freebsd/include/nix/util/freebsd-jail.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ class AutoRemoveJail
bool del;
public:
AutoRemoveJail(int jid);
AutoRemoveJail(const AutoRemoveJail &) = delete;
AutoRemoveJail & operator=(const AutoRemoveJail &) = delete;

AutoRemoveJail(AutoRemoveJail && other) noexcept
: jid(other.jid)
, del(other.del)
{
other.cancel();
}

AutoRemoveJail & operator=(AutoRemoveJail && other) noexcept
{
jid = other.jid;
del = other.del;
other.cancel();
return *this;
}

AutoRemoveJail();
~AutoRemoveJail();
void cancel();
Expand Down
17 changes: 16 additions & 1 deletion src/libutil/include/nix/util/file-system.hh
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,23 @@ class AutoUnmount
Path path;
bool del;
public:
AutoUnmount(Path &);
AutoUnmount();
AutoUnmount(Path &);
AutoUnmount(const AutoUnmount &) = delete;

AutoUnmount(AutoUnmount && other) noexcept
: path(std::move(other.path))
, del(std::exchange(other.del, false))
{
}

AutoUnmount & operator=(AutoUnmount && other) noexcept
{
path = std::move(other.path);
del = std::exchange(other.del, false);
return *this;
}

~AutoUnmount();
void cancel();
};
Expand Down
21 changes: 20 additions & 1 deletion src/libutil/include/nix/util/serialise.hh
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ struct FdSink : BufferedSink
}

FdSink(FdSink &&) = default;
FdSink(const FdSink &) = delete;
FdSink & operator=(const FdSink &) = delete;

FdSink & operator=(FdSink && s)
{
Expand Down Expand Up @@ -200,8 +202,10 @@ struct FdSource : BufferedSource, RestartableSource
}

FdSource(FdSource &&) = default;

FdSource & operator=(FdSource && s) = default;
FdSource(const FdSource &) = delete;
FdSource & operator=(const FdSource & s) = delete;
~FdSource() = default;

bool good() override;
void restart() override;
Expand Down Expand Up @@ -452,6 +456,11 @@ struct LambdaSink : Sink
{
}

LambdaSink(LambdaSink &&) = delete;
LambdaSink(const LambdaSink &) = delete;
LambdaSink & operator=(LambdaSink &&) = delete;
LambdaSink & operator=(const LambdaSink &) = delete;

~LambdaSink()
{
cleanupFun();
Expand Down Expand Up @@ -628,6 +637,11 @@ struct FramedSource : Source
{
}

FramedSource(FramedSource &&) = delete;
FramedSource(const FramedSource &) = delete;
FramedSource & operator=(FramedSource &&) = delete;
FramedSource & operator=(const FramedSource &) = delete;

~FramedSource()
{
try {
Expand Down Expand Up @@ -685,6 +699,11 @@ struct FramedSink : nix::BufferedSink
{
}

FramedSink(FramedSink &&) = delete;
FramedSink(const FramedSink &) = delete;
FramedSink & operator=(FramedSink &&) = delete;
FramedSink & operator=(const FramedSink &) = delete;

~FramedSink()
{
try {
Expand Down
13 changes: 7 additions & 6 deletions src/libutil/include/nix/util/sync.hh
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,10 @@ public:
{
}
public:
Lock(Lock && l)
: s(l.s)
{
unreachable();
}

Lock(Lock && l) = delete;
Lock(const Lock & l) = delete;
Lock & operator=(Lock && l) = delete;
Lock & operator=(const Lock & l) = delete;

~Lock() {}

Expand Down Expand Up @@ -110,6 +107,8 @@ public:

struct WriteLock : Lock<WL>
{
using Lock<WL>::Lock;

T * operator->()
{
return &WriteLock::s->data;
Expand All @@ -131,6 +130,8 @@ public:

struct ReadLock : Lock<RL>
{
using Lock<RL>::Lock;

const T * operator->()
{
return &ReadLock::s->data;
Expand Down
5 changes: 5 additions & 0 deletions src/libutil/include/nix/util/util.hh
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ struct MaintainCount
counter += delta;
}

MaintainCount(MaintainCount &&) = delete;
MaintainCount(const MaintainCount &) = delete;
MaintainCount & operator=(MaintainCount &&) = delete;
MaintainCount & operator=(const MaintainCount &) = delete;

~MaintainCount()
{
counter -= delta;
Expand Down
5 changes: 5 additions & 0 deletions src/libutil/include/nix/util/xml-writer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public:
writer.openElement(name, attrs);
}

XMLOpenElement(XMLOpenElement &&) = delete;
XMLOpenElement(const XMLOpenElement &) = delete;
XMLOpenElement & operator=(XMLOpenElement &&) = delete;
XMLOpenElement & operator=(const XMLOpenElement &) = delete;

~XMLOpenElement()
{
writer.closeElement();
Expand Down
4 changes: 4 additions & 0 deletions src/libutil/unix/include/nix/util/monitor-fd.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ private:

public:
MonitorFdHup(int fd);
MonitorFdHup(MonitorFdHup &&) = delete;
MonitorFdHup(const MonitorFdHup &) = delete;
MonitorFdHup & operator=(MonitorFdHup &&) = delete;
MonitorFdHup & operator=(const MonitorFdHup &) = delete;

~MonitorFdHup()
{
Expand Down
16 changes: 11 additions & 5 deletions src/libutil/unix/signals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ struct InterruptCallbackImpl : InterruptCallback
{
InterruptCallbacks::Token token;

InterruptCallbackImpl(InterruptCallbacks::Token token)
: token(token)
{
}

InterruptCallbackImpl(InterruptCallbackImpl &&) = delete;
InterruptCallbackImpl(const InterruptCallbackImpl &) = delete;
InterruptCallbackImpl & operator=(InterruptCallbackImpl &&) = delete;
InterruptCallbackImpl & operator=(const InterruptCallbackImpl &) = delete;

~InterruptCallbackImpl() override
{
auto interruptCallbacks(_interruptCallbacks.lock());
Expand All @@ -153,11 +163,7 @@ std::unique_ptr<InterruptCallback> createInterruptCallback(std::function<void()>
auto interruptCallbacks(_interruptCallbacks.lock());
auto token = interruptCallbacks->nextToken++;
interruptCallbacks->callbacks.emplace(token, callback);

std::unique_ptr<InterruptCallbackImpl> res{new InterruptCallbackImpl{}};
res->token = token;

return std::unique_ptr<InterruptCallback>(res.release());
return std::make_unique<InterruptCallbackImpl>(token);
}

} // namespace nix
Loading