Delete copy constructors and assignment operators (#2257)

One of these was buggy and others had the wrong parameters and return
types.
This commit is contained in:
Andrew Gaul 2023-08-11 13:12:03 +09:00 committed by GitHub
parent 3790a0f8b4
commit c5a75a1fb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 52 deletions

View File

@ -40,7 +40,8 @@ class AutoLock
bool is_lock_acquired;
private:
AutoLock(const AutoLock&);
AutoLock(const AutoLock&) = delete;
AutoLock& operator=(const AutoLock&) = delete;
public:
explicit AutoLock(pthread_mutex_t* pmutex, Type type = NONE);

View File

@ -31,24 +31,6 @@ AutoFdEntity::AutoFdEntity() : pFdEntity(nullptr), pseudo_fd(-1)
{
}
// [NOTE]
// The copy constructor should not be called, then this is private method.
// Even if it is called, the consistency of the number of
// references can be maintained, but this case is not assumed.
//
AutoFdEntity::AutoFdEntity(AutoFdEntity& other) : pFdEntity(nullptr), pseudo_fd(-1)
{
S3FS_PRN_WARN("This method should not be called. Please check the caller.");
if(other.pFdEntity){
if(-1 != (pseudo_fd = other.pFdEntity->Dup(other.pseudo_fd))){
pFdEntity = other.pFdEntity;
}else{
S3FS_PRN_ERR("Failed duplicating fd in AutoFdEntity.");
}
}
}
AutoFdEntity::~AutoFdEntity()
{
Close();
@ -131,28 +113,6 @@ FdEntity* AutoFdEntity::OpenExistFdEntity(const char* path, int flags)
return pFdEntity;
}
// [NOTE]
// This operator should not be called, then this is private method.
// Even if it is called, the consistency of the number of
// references can be maintained, but this case is not assumed.
//
bool AutoFdEntity::operator=(AutoFdEntity& other)
{
S3FS_PRN_WARN("This method should not be called. Please check the caller.");
Close();
if(other.pFdEntity){
if(-1 != (pseudo_fd = other.pFdEntity->Dup(other.pseudo_fd))){
pFdEntity = other.pFdEntity;
}else{
S3FS_PRN_ERR("Failed duplicating fd in AutoFdEntity.");
return false;
}
}
return true;
}
/*
* Local variables:
* tab-width: 4

View File

@ -43,8 +43,8 @@ class AutoFdEntity
int pseudo_fd;
private:
AutoFdEntity(AutoFdEntity& other);
bool operator=(AutoFdEntity& other);
AutoFdEntity(const AutoFdEntity&) = delete;
AutoFdEntity& operator=(const AutoFdEntity&) = delete;
public:
AutoFdEntity();

View File

@ -358,14 +358,6 @@ PageList::PageList(off_t size, bool is_loaded, bool is_modified, bool shrinked)
Init(size, is_loaded, is_modified);
}
PageList::PageList(const PageList& other)
{
for(fdpage_list_t::const_iterator iter = other.pages.begin(); iter != other.pages.end(); ++iter){
pages.push_back(*iter);
}
is_shrink = other.is_shrink;
}
PageList::~PageList()
{
Clear();

View File

@ -98,7 +98,8 @@ class PageList
static void FreeList(fdpage_list_t& list);
explicit PageList(off_t size = 0, bool is_loaded = false, bool is_modified = false, bool shrinked = false);
explicit PageList(const PageList& other);
PageList(const PageList&) = delete;
PageList& operator=(const PageList&) = delete;
~PageList();
bool Init(off_t size, bool is_loaded, bool is_modified);