diff options
author | Slava Barinov <v.barinov@samsung.com> | 2024-03-29 16:52:32 +0300 |
---|---|---|
committer | Dongkyun Son <dongkyun.s@samsung.com> | 2024-03-31 15:15:01 +0900 |
commit | 5815c63fc8c8ed2d8a19d13996b041b998f1bf14 (patch) | |
tree | 0b30bf22e52d87a72d4200cb51f30fa296224ece | |
parent | 4d9fd473486d569403784157ac47f27c0900303f (diff) | |
download | trust-anchor-accepted/tizen_unified_toolchain.tar.gz trust-anchor-accepted/tizen_unified_toolchain.tar.bz2 trust-anchor-accepted/tizen_unified_toolchain.zip |
Migrate to custom deleter type for unique_ptraccepted/tizen/unified/toolchain/20240401.041530sandbox/dkson95/buildaccepted/tizen_unified_toolchain
This prevents the error
In file included from /home/abuild/rpmbuild/BUILD/trust-anchor-2.1.2/src/file-system.cpp:22:
/home/abuild/rpmbuild/BUILD/trust-anchor-2.1.2/src/file-system.hxx:29:58: error: ignoring attributes on template argument 'int (*)(FILE*)' [-Werror=ignored-attributes]
29 | using FilePtr = std::unique_ptr<FILE, decltype(&::fclose)>;
| ^ ^
When building with new toolchain
Change-Id: I4ef59f8a3c7d90e664f4fdd363cd385df980cd1d
-rw-r--r-- | src/certificate.cpp | 2 | ||||
-rw-r--r-- | src/file-system.cpp | 2 | ||||
-rw-r--r-- | src/file-system.hxx | 8 | ||||
-rw-r--r-- | tests/test-util.cpp | 14 |
4 files changed, 19 insertions, 7 deletions
diff --git a/src/certificate.cpp b/src/certificate.cpp index 13a8f70..628f6ca 100644 --- a/src/certificate.cpp +++ b/src/certificate.cpp @@ -51,7 +51,7 @@ Certificate::Certificate(const std::string &path) : m_path(path) std::string Certificate::getSubjectNameHash() const { - FilePtr fp = FilePtr(::fopen(this->m_path.c_str(), "rb"), ::fclose); + FilePtr fp = FilePtr(::fopen(this->m_path.c_str(), "rb")); if (fp == nullptr) throw std::invalid_argument("Failed to open [" + this->m_path + "]."); diff --git a/src/file-system.cpp b/src/file-system.cpp index 55783e0..82456b4 100644 --- a/src/file-system.cpp +++ b/src/file-system.cpp @@ -40,7 +40,7 @@ void File::linkTo(const std::string &src, const std::string &dst) std::string File::read(const std::string &path) { - FilePtr fp = FilePtr(::fopen(path.c_str(), "rb"), ::fclose); + FilePtr fp = FilePtr(::fopen(path.c_str(), "rb")); if (fp == nullptr) throw std::invalid_argument("Failed to open [" + path + "]."); diff --git a/src/file-system.hxx b/src/file-system.hxx index ce1df38..1ca29c2 100644 --- a/src/file-system.hxx +++ b/src/file-system.hxx @@ -26,7 +26,13 @@ namespace tanchor { -using FilePtr = std::unique_ptr<FILE, decltype(&::fclose)>; +struct file_closer { + void operator() (FILE* f) const { + fclose(f); + } +}; + +using FilePtr = std::unique_ptr<FILE, file_closer>; class File { public: diff --git a/tests/test-util.cpp b/tests/test-util.cpp index 11ddd33..5c28742 100644 --- a/tests/test-util.cpp +++ b/tests/test-util.cpp @@ -32,13 +32,19 @@ namespace test { namespace util { +struct pipe_closer { + void operator() (FILE* f) const { + pclose(f); + } +}; + std::string ls(const char *path) { - using FilePtr = std::unique_ptr<FILE, decltype(&::pclose)>; + using FilePtr = std::unique_ptr<FILE, pipe_closer>; std::string cmd("/bin/ls "); cmd.append(path); - FilePtr ls(::popen(cmd.c_str(), "r"), ::pclose); + FilePtr ls(::popen(cmd.c_str(), "r")); if (ls == nullptr) return std::string(); @@ -52,11 +58,11 @@ std::string ls(const char *path) std::string cat(const char *path) { - using FilePtr = std::unique_ptr<FILE, decltype(&::pclose)>; + using FilePtr = std::unique_ptr<FILE, pipe_closer>; std::string cmd("/bin/cat "); cmd.append(path); - FilePtr ls(::popen(cmd.c_str(), "r"), ::pclose); + FilePtr ls(::popen(cmd.c_str(), "r")); if (ls == nullptr) return std::string(); |