Skip to content

Commit

Permalink
fcntl here is the equivalent of dup. Using fcntl because it's support…
Browse files Browse the repository at this point in the history
…ed in VxWorks too
  • Loading branch information
kevin-f-ortega committed Nov 25, 2024
1 parent fecde80 commit 4842e8a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
8 changes: 2 additions & 6 deletions Os/Posix/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,17 @@ static_assert(std::numeric_limits<FwSignedSizeType>::min() <= std::numeric_limit
"Minimum value of FwSizeType larger than the minimum value of ssize_t. Configure a larger type.");

//!\brief default copy constructor
#ifndef TGT_OS_TYPE_VXWORKS
PosixFile::PosixFile(const PosixFile& other) {
// Must properly duplicate the file handle
this->m_handle.m_file_descriptor = ::dup(other.m_handle.m_file_descriptor);
this->m_handle.m_file_descriptor = fcntl(other.m_handle.m_file_descriptor, F_DUPFD, 0);

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter other has not been checked.
}
#endif

#ifndef TGT_OS_TYPE_VXWORKS
PosixFile& PosixFile::operator=(const PosixFile& other) {
if (this != &other) {
this->m_handle.m_file_descriptor = ::dup(other.m_handle.m_file_descriptor);
this->m_handle.m_file_descriptor = fcntl(other.m_handle.m_file_descriptor, F_DUPFD, 0);
}
return *this;
}
#endif

PosixFile::Status PosixFile::open(const char* filepath,
PosixFile::Mode requested_mode,
Expand Down
18 changes: 2 additions & 16 deletions Os/Posix/File.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,10 @@ class PosixFile : public FileInterface {
PosixFile() = default;

//! \brief copy constructor
#ifdef TGT_OS_TYPE_VXWORKS
// Adding this pound-if-define code to allow building VxWorks for POSIX.
// Better than the alternative of copying this entire file to the VxWorks repo
// and removing this line.
PosixFile(const PosixFile& other) = delete;
#else
PosixFile(const PosixFile& other);
#endif

//! \brief assignment operator that copies the internal representation
#ifdef TGT_OS_TYPE_VXWORKS
// Adding this pound-if-define code to allow building VxWorks for POSIX.
// Better than the alternative of copying this entire file to the VxWorks repo
// and removing this line.
PosixFile& operator=(const PosixFile& other) = delete;
#else

//! \brief assignment operator that copies the internal representation
PosixFile& operator=(const PosixFile& other);
#endif

//! \brief destructor
//!
Expand Down

0 comments on commit 4842e8a

Please sign in to comment.