-
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
Refactor Os::FileSystem and Os::Directory #2871
Conversation
…dd RandomizedTesting
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.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
} | ||
|
||
|
||
Directory::Status Directory::readDirectory(Fw::String filenameArray[], const FwSizeType filenameArraySize, FwSizeType& filenameCount) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
bool isOpen(); //!< check if file descriptor is open or not. | ||
Status rewind(); //!< rewind directory stream to the beginning | ||
//! \brief default constructor | ||
DirectoryInterface() = default; |
Check notice
Code scanning / CodeQL
More than one statement per line Note
namespace Posix { | ||
namespace Directory { | ||
|
||
struct PosixDirectoryHandle : public DirectoryHandle { |
Check notice
Code scanning / CodeQL
More than one statement per line Note
return status; | ||
} | ||
|
||
PosixFileSystem::Status PosixFileSystem::_getFreeSpace(const char* path, FwSizeType& totalBytes, FwSizeType& freeBytes) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
@@ -48,6 +48,75 @@ | |||
return status; | |||
} | |||
|
|||
FileSystem::Status errno_to_filesystem_status(PlatformIntType errno_input) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
return status; | ||
} | ||
|
||
Directory::Status errno_to_directory_status(PlatformIntType errno_input) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
return fs_status; | ||
} // end appendFile | ||
|
||
FileSystem::Status FileSystem::moveFile(const char* source, const char* destination) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
return status; | ||
} // end handleFileError | ||
|
||
FileSystem::Status FileSystem::handleDirectoryError(Directory::Status dirStatus) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
FwSizeType count = 0; | ||
char unusedBuffer[1]; // buffer must have size but is unused | ||
Status readStatus = Status::OP_OK; | ||
fileCount = 0; |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
Status readStatus = Status::OP_OK; | ||
Status returnStatus = Status::OP_OK; | ||
FwSizeType index; | ||
filenameCount = 0; |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
FileSystem::Status FileSystem::_getFreeSpace(const char* path, FwSizeType& totalBytes, FwSizeType& freeBytes) { | ||
FW_ASSERT(&this->m_delegate == reinterpret_cast<FileSystemInterface*>(&this->m_handle_storage[0])); | ||
FW_ASSERT(path != nullptr); | ||
return this->m_delegate._getFreeSpace(path, totalBytes, freeBytes); |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
total_blocks > (std::numeric_limits<FwSizeType>::max() / block_size)) { | ||
return OVERFLOW_ERROR; | ||
} | ||
freeBytes = free_blocks * block_size; |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
return OVERFLOW_ERROR; | ||
} | ||
freeBytes = free_blocks * block_size; | ||
totalBytes = total_blocks * block_size; |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
@@ -48,6 +48,86 @@ | |||
return status; | |||
} | |||
|
|||
FileSystem::Status errno_to_filesystem_status(PlatformIntType errno_input) { | |||
FileSystem::Status status = FileSystem::Status::OP_OK; | |||
switch (errno_input) { |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
|
||
Directory::Status errno_to_directory_status(PlatformIntType errno_input) { | ||
Directory::Status status = Directory::Status::OP_OK; | ||
switch (errno_input) { |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
// Additional functions built on top of OS-specific operations | ||
// ------------------------------------------------------------ | ||
|
||
FileSystem::Status FileSystem::createDirectory(const char* path, bool errorIfAlreadyExists) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
return status; | ||
} | ||
|
||
FileSystem::Status FileSystem::touch(const char* path) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
return status; | ||
} | ||
|
||
FileSystem::PathType FileSystem::getPathType(const char* path) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
return FileSystem::getPathType(path) != PathType::NOT_EXIST; | ||
} // end exists | ||
|
||
FileSystem::Status FileSystem::copyFile(const char* sourcePath, const char* destPath) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
return status; | ||
} | ||
|
||
PosixDirectory::Status PosixDirectory::read(char* fileNameBuffer, FwSizeType bufSize) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
@LeStarch comments addressed and follow-up issues created. |
Change Description
Refactoring Os::FileSystem and Os::Directory to the new OSAL pattern
Rationale
See #2687
Future Work
Document the entire OSAL