From d70832dfe4c8087826e96760f4ed7e815e1106d2 Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Wed, 13 Nov 2024 10:08:14 -0500 Subject: [PATCH] ScopedFD - only use move semantics --- crypto/test/file_util.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crypto/test/file_util.h b/crypto/test/file_util.h index 9d3d76e3e6..376e151287 100644 --- a/crypto/test/file_util.h +++ b/crypto/test/file_util.h @@ -46,12 +46,15 @@ class ScopedFD { explicit ScopedFD(int fd) : fd_(fd) {} ~ScopedFD() { reset(); } - ScopedFD(ScopedFD &&other) { *this = std::move(other); } - ScopedFD &operator=(ScopedFD other) { + ScopedFD(ScopedFD &&other) noexcept { *this = std::move(other); } + ScopedFD &operator=(ScopedFD&& other) { reset(other.release()); return *this; } + ScopedFD(const ScopedFD &other) = delete; + ScopedFD &operator=(ScopedFD& other) = delete; + bool is_valid() const { return fd_ >= 0; } int get() const { return fd_; }