-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Os file vxworks #3009
Os file vxworks #3009
Conversation
NOTE: I used F Prime's .clang-format to format the files I modified. |
} | ||
|
||
PosixFile::Status PosixFile::open(const char* filepath, PosixFile::Mode requested_mode, PosixFile::OverwriteType overwrite) { | ||
PosixFile::Status PosixFile::open(const char* filepath, |
Check notice
Code scanning / CodeQL
Long function without assertion Note
@@ -95,7 +111,7 @@ | |||
} | |||
} | |||
|
|||
PosixFile::Status PosixFile::size(FwSignedSizeType& size_result) { | |||
PosixFile::Status PosixFile::size(FwSignedSizeType& size_result) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
@@ -118,7 +134,7 @@ | |||
return status; | |||
} | |||
|
|||
PosixFile::Status PosixFile::position(FwSignedSizeType &position_result) { | |||
PosixFile::Status PosixFile::position(FwSignedSizeType& position_result) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
@@ -198,18 +216,18 @@ | |||
return status; | |||
} | |||
|
|||
PosixFile::Status PosixFile::read(U8* buffer, FwSignedSizeType &size, PosixFile::WaitType wait) { | |||
PosixFile::Status PosixFile::read(U8* buffer, FwSignedSizeType& size, PosixFile::WaitType wait) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
@@ -234,15 +252,19 @@ | |||
return status; | |||
} | |||
|
|||
PosixFile::Status PosixFile::write(const U8* buffer, FwSignedSizeType &size, PosixFile::WaitType wait) { | |||
PosixFile::Status PosixFile::write(const U8* buffer, FwSignedSizeType& size, PosixFile::WaitType wait) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
@@ -6,7 +6,9 @@ | |||
#include "Os/Posix/error.hpp" | |||
|
|||
#include <dirent.h> | |||
#ifndef TGT_OS_TYPE_VXWORKS |
Check notice
Code scanning / CodeQL
Conditional compilation Note
@@ -58,11 +59,19 @@ | |||
return status; | |||
} | |||
|
|||
PosixFileSystem::Status PosixFileSystem::_getFreeSpace(const char* path, FwSizeType& totalBytes, FwSizeType& freeBytes) { | |||
PosixFileSystem::Status PosixFileSystem::_getFreeSpace(const char* path, |
Check notice
Code scanning / CodeQL
Long function without assertion Note
PosixFileSystem::Status PosixFileSystem::_getFreeSpace(const char* path, | ||
FwSizeType& totalBytes, | ||
FwSizeType& freeBytes) { | ||
#ifdef TGT_OS_TYPE_VXWORKS |
Check notice
Code scanning / CodeQL
Conditional compilation Note
} | ||
|
||
PosixFile::Status PosixFile::open(const char* filepath, PosixFile::Mode requested_mode, PosixFile::OverwriteType overwrite) { | ||
PosixFile::Status PosixFile::open(const char* filepath, |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -95,7 +111,7 @@ | |||
} | |||
} | |||
|
|||
PosixFile::Status PosixFile::size(FwSignedSizeType& size_result) { | |||
PosixFile::Status PosixFile::size(FwSignedSizeType& size_result) { |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -118,7 +134,7 @@ | |||
return status; | |||
} | |||
|
|||
PosixFile::Status PosixFile::position(FwSignedSizeType &position_result) { | |||
PosixFile::Status PosixFile::position(FwSignedSizeType& position_result) { |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -179,7 +196,8 @@ | |||
|
|||
PosixFile::Status PosixFile::seek(FwSignedSizeType offset, PosixFile::SeekType seekType) { | |||
Status status = OP_OK; | |||
off_t actual = ::lseek(this->m_handle.m_file_descriptor, offset, (seekType == SeekType::ABSOLUTE) ? SEEK_SET : SEEK_CUR); | |||
off_t actual = |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -198,18 +216,18 @@ | |||
return status; | |||
} | |||
|
|||
PosixFile::Status PosixFile::read(U8* buffer, FwSignedSizeType &size, PosixFile::WaitType wait) { | |||
PosixFile::Status PosixFile::read(U8* buffer, FwSignedSizeType& size, PosixFile::WaitType wait) { |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
|
||
for (FwSignedSizeType i = 0; i < maximum && accumulated < size; i++) { | ||
// char* for some posix implementations | ||
ssize_t write_size = ::write(this->m_handle.m_file_descriptor, reinterpret_cast<const CHAR*>(&buffer[accumulated]), static_cast<size_t>(size - accumulated)); | ||
ssize_t write_size = |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -258,11 +280,11 @@ | |||
size = accumulated; | |||
// When waiting, sync to disk | |||
if (wait) { | |||
PlatformIntType fsync_return = ::fsync(this->m_handle.m_file_descriptor); | |||
if (PosixFileHandle::ERROR_RETURN_VALUE == fsync_return) { | |||
PlatformIntType fsync_return = ::fsync(this->m_handle.m_file_descriptor); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -58,11 +59,19 @@ | |||
return status; | |||
} | |||
|
|||
PosixFileSystem::Status PosixFileSystem::_getFreeSpace(const char* path, FwSizeType& totalBytes, FwSizeType& freeBytes) { | |||
PosixFileSystem::Status PosixFileSystem::_getFreeSpace(const char* path, |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -58,11 +59,19 @@ | |||
return status; | |||
} | |||
|
|||
PosixFileSystem::Status PosixFileSystem::_getFreeSpace(const char* path, FwSizeType& totalBytes, FwSizeType& freeBytes) { | |||
PosixFileSystem::Status PosixFileSystem::_getFreeSpace(const char* path, | |||
FwSizeType& totalBytes, |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
PosixFileSystem::Status PosixFileSystem::_getFreeSpace(const char* path, FwSizeType& totalBytes, FwSizeType& freeBytes) { | ||
PosixFileSystem::Status PosixFileSystem::_getFreeSpace(const char* path, | ||
FwSizeType& totalBytes, | ||
FwSizeType& freeBytes) { |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -179,7 +196,8 @@ | |||
|
|||
PosixFile::Status PosixFile::seek(FwSignedSizeType offset, PosixFile::SeekType seekType) { | |||
Status status = OP_OK; | |||
off_t actual = ::lseek(this->m_handle.m_file_descriptor, offset, (seekType == SeekType::ABSOLUTE) ? SEEK_SET : SEEK_CUR); | |||
off_t actual = | |||
::lseek(this->m_handle.m_file_descriptor, offset, (seekType == SeekType::ABSOLUTE) ? SEEK_SET : SEEK_CUR); |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
this->m_handle.m_file_descriptor, | ||
reinterpret_cast<CHAR*>(&buffer[accumulated]), | ||
static_cast<size_t>(size - accumulated)); | ||
ssize_t read_size = ::read(this->m_handle.m_file_descriptor, reinterpret_cast<CHAR*>(&buffer[accumulated]), |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
|
||
for (FwSignedSizeType i = 0; i < maximum && accumulated < size; i++) { | ||
// char* for some posix implementations | ||
ssize_t write_size = ::write(this->m_handle.m_file_descriptor, reinterpret_cast<const CHAR*>(&buffer[accumulated]), static_cast<size_t>(size - accumulated)); | ||
ssize_t write_size = | ||
::write(this->m_handle.m_file_descriptor, reinterpret_cast<const CHAR*>(&buffer[accumulated]), |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently a runtime-check that asserts when running. Would it be better to do a build-time check? This could be done by conditionally setting the constructors to =delete in the header in the VxWorks build.
Rather than crash the FSW, this would fail to link if that code was ever used. Thoughts?
…en building VxWorks using Posix. Better to do a pound-if here than copying the entire file and deleting a line in the vxworks repo
@@ -43,19 +45,25 @@ | |||
"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 |
Check notice
Code scanning / CodeQL
Conditional compilation Note
|
||
#ifndef TGT_OS_TYPE_VXWORKS |
Check notice
Code scanning / CodeQL
Conditional compilation Note
Change Description
Adding macros to include/exclude code when compiling for VxWorks.
Rationale
This allows VxWorks to build with the Posix file implementation.
Testing/Review Recommendations
I ran a simple hello world program in the VxSim. The hello world program opened a file and wrote some bytes to the file.
Future Work
Note any additional work that will be done relating to this issue.