mirror of
https://github.com/NixOS/nix.git
synced 2025-12-22 17:01:08 +01:00
Merge pull request #14791 from NixOS/fix-special-member-functions-a-lot
treewide: Follow rule of five
This commit is contained in:
commit
a38fc659cc
12 changed files with 118 additions and 15 deletions
|
|
@ -741,6 +741,11 @@ public:
|
|||
inDebugger = true;
|
||||
}
|
||||
|
||||
DebuggerGuard(DebuggerGuard &&) = delete;
|
||||
DebuggerGuard(const DebuggerGuard &) = delete;
|
||||
DebuggerGuard & operator=(DebuggerGuard &&) = delete;
|
||||
DebuggerGuard & operator=(const DebuggerGuard &) = delete;
|
||||
|
||||
~DebuggerGuard()
|
||||
{
|
||||
inDebugger = false;
|
||||
|
|
|
|||
|
|
@ -107,6 +107,8 @@ private:
|
|||
Bindings & operator=(const Bindings &) = delete;
|
||||
Bindings & operator=(Bindings &&) = delete;
|
||||
|
||||
~Bindings() = default;
|
||||
|
||||
friend class BindingsBuilder;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -164,8 +164,6 @@ 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]}
|
||||
|
|
@ -173,6 +171,11 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
ListBuilder(const ListBuilder &) = delete;
|
||||
ListBuilder & operator=(ListBuilder &&) = delete;
|
||||
ListBuilder & operator=(const ListBuilder &) = delete;
|
||||
~ListBuilder() = default;
|
||||
|
||||
Value *& operator[](size_t n)
|
||||
{
|
||||
return elems[n];
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -159,6 +159,8 @@ struct FdSink : BufferedSink
|
|||
}
|
||||
|
||||
FdSink(FdSink &&) = default;
|
||||
FdSink(const FdSink &) = delete;
|
||||
FdSink & operator=(const FdSink &) = delete;
|
||||
|
||||
FdSink & operator=(FdSink && s)
|
||||
{
|
||||
|
|
@ -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;
|
||||
|
|
@ -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();
|
||||
|
|
@ -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 {
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
||||
|
|
@ -110,6 +107,8 @@ public:
|
|||
|
||||
struct WriteLock : Lock<WL>
|
||||
{
|
||||
using Lock<WL>::Lock;
|
||||
|
||||
T * operator->()
|
||||
{
|
||||
return &WriteLock::s->data;
|
||||
|
|
@ -131,6 +130,8 @@ public:
|
|||
|
||||
struct ReadLock : Lock<RL>
|
||||
{
|
||||
using Lock<RL>::Lock;
|
||||
|
||||
const T * operator->()
|
||||
{
|
||||
return &ReadLock::s->data;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
@ -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…
Add table
Add a link
Reference in a new issue