Skip to content

Commit d12bdbe

Browse files
committed
refs #29, work on stricter warning set
1 parent 135015f commit d12bdbe

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

include/ghc/filesystem.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ GHC_INLINE unsigned consumeUtf8Fragment(const unsigned state, const uint8_t frag
12381238
0x88888880u, 0x22818108u, 0x88888881u, 0x88888882u, 0x88888884u, 0x88888887u, 0x88888886u, 0x82218108u, 0x82281108u, 0x88888888u, 0x88888883u, 0x88888885u, 0u, 0u, 0u, 0u,
12391239
};
12401240
uint8_t category = fragment < 128 ? 0 : (utf8_state_info[(fragment >> 3) & 0xf] >> ((fragment & 7) << 2)) & 0xf;
1241-
codepoint = (state ? (codepoint << 6) | (fragment & 0x3f) : (0xff >> category) & fragment);
1241+
codepoint = (state ? (codepoint << 6) | (fragment & 0x3fu) : (0xffu >> category) & fragment);
12421242
return state == S_RJCT ? static_cast<unsigned>(S_RJCT) : static_cast<unsigned>((utf8_state_info[category + 16] >> (state << 2)) & 0xf);
12431243
}
12441244

@@ -1320,7 +1320,7 @@ inline StringType fromUtf8(const std::string& utf8String, const typename StringT
13201320
std::uint32_t codepoint = 0;
13211321
while (iter < utf8String.end()) {
13221322
if ((utf8_state = consumeUtf8Fragment(utf8_state, (uint8_t)*iter++, codepoint)) == S_STRT) {
1323-
result += codepoint;
1323+
result += static_cast<typename StringType::value_type>(codepoint);
13241324
codepoint = 0;
13251325
}
13261326
else if (utf8_state == S_RJCT) {
@@ -1383,7 +1383,7 @@ inline std::string toUtf8(const std::basic_string<charT, traits, Alloc>& unicode
13831383
{
13841384
std::string result;
13851385
for (auto c : unicodeString) {
1386-
appendUTF8(result, c);
1386+
appendUTF8(result, static_cast<uint32_t>(c));
13871387
}
13881388
return result;
13891389
}
@@ -1732,7 +1732,7 @@ GHC_INLINE path resolveSymlink(const path& p, std::error_code& ec)
17321732
return path();
17331733
}
17341734
else if (rc < static_cast<int>(bufferSize)) {
1735-
return path(std::string(buffer.data(), rc));
1735+
return path(std::string(buffer.data(), static_cast<std::string::size_type>(rc)));
17361736
}
17371737
bufferSize *= 2;
17381738
}
@@ -1903,7 +1903,7 @@ GHC_INLINE file_status status_ex(const path& p, std::error_code& ec, file_status
19031903
}
19041904
}
19051905
if (sz) {
1906-
*sz = st.st_size;
1906+
*sz = static_cast<uintmax_t>(st.st_size);
19071907
}
19081908
if (nhl) {
19091909
*nhl = st.st_nlink;
@@ -3289,9 +3289,9 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options
32893289
std::shared_ptr<void> guard_out(nullptr, [out](void*) { ::close(out); });
32903290
ssize_t br, bw;
32913291
while ((br = ::read(in, buffer.data(), buffer.size())) > 0) {
3292-
int offset = 0;
3292+
ssize_t offset = 0;
32933293
do {
3294-
if ((bw = ::write(out, buffer.data() + offset, br)) > 0) {
3294+
if ((bw = ::write(out, buffer.data() + offset, static_cast<size_t>(br))) > 0) {
32953295
br -= bw;
32963296
offset += bw;
32973297
}
@@ -4170,7 +4170,7 @@ GHC_INLINE void resize_file(const path& p, uintmax_t size, std::error_code& ec)
41704170
ec = std::error_code(::GetLastError(), std::system_category());
41714171
}
41724172
#else
4173-
if (::truncate(p.c_str(), size) != 0) {
4173+
if (::truncate(p.c_str(), static_cast<off_t>(size)) != 0) {
41744174
ec = std::error_code(errno, std::system_category());
41754175
}
41764176
#endif

test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ else()
1818
add_executable(filesystem_test filesystem_test.cpp catch.hpp)
1919
target_link_libraries(filesystem_test ghc_filesystem)
2020
target_compile_options(filesystem_test PRIVATE
21-
$<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -Wshadow -Werror>
22-
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wshadow -Werror>
21+
$<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror>
22+
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror>
2323
$<$<CXX_COMPILER_ID:MSVC>:/WX>)
2424
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
2525
target_compile_definitions(filesystem_test PRIVATE _CRT_SECURE_NO_WARNINGS)

0 commit comments

Comments
 (0)