Skip to content

Commit

Permalink
Fix implicit conversions in fsutil
Browse files Browse the repository at this point in the history
  • Loading branch information
rikyoz committed Oct 21, 2023
1 parent 0399535 commit fc6de4e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/internal/fsutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,17 @@ auto restore_symlink( const std::string& name ) -> bool {
return !error && symlink( linkPath.c_str(), name.c_str() ) == 0;
}

static const mode_t global_umask = []() noexcept {
static const mode_t global_umask = []() noexcept -> mode_t {
// Getting and setting the current umask.
// Note: flawfinder warns about umask with the mask set to 0;
// however, we use it only to read the current umask,
// then we restore the old value, hence we can ignore the warning!
// then we restore the old value, hence we can ignore the warning.
const mode_t currentUmask{ umask( 0 ) }; // flawfinder: ignore

// Restoring the umask.
umask( currentUmask ); // flawfinder: ignore

return static_cast<int>( fs::perms::all ) & ( ~currentUmask );
return static_cast< mode_t >( static_cast< int >( fs::perms::all ) & ( ~currentUmask ) );
}();

#endif
Expand Down Expand Up @@ -268,8 +268,9 @@ auto fsutil::get_file_attributes_ex( const fs::path& filePath,
if ( ( statInfo.st_mode & S_IWUSR ) == 0 ) {
fileMetadata.dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
}
constexpr auto kMask = 0xFFFF;
fileMetadata.dwFileAttributes |= FILE_ATTRIBUTE_UNIX_EXTENSION + ( ( statInfo.st_mode & kMask ) << 16 );
constexpr auto kMask = 0xFFFFu;
std::uint32_t unixAttributes = ( ( statInfo.st_mode & kMask ) << 16u );
fileMetadata.dwFileAttributes |= FILE_ATTRIBUTE_UNIX_EXTENSION + unixAttributes;

// File times
fileMetadata.ftCreationTime = time_to_FILETIME( statInfo.st_ctime );
Expand Down

0 comments on commit fc6de4e

Please sign in to comment.