Skip to content
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

Fix vs2019 pre-commit failures relating to zlib warnings #5766

Merged
merged 7 commits into from
Nov 30, 2022
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,14 @@ function (mac_add_inc_and_lib header lib)
endfunction ()

# zlib, snappy, and lz4 are used for some clients/ and tests.
find_package(ZLIB)
# TODO i#5767: Install an explicit zlib package on our Windows GA CI images
# (this find_package finds a strawberry perl zlib which causes 32-bit build
# and 64-bit private loader issues).
if (WIN32 AND AUTOMATED_TESTING)
set(ZLIB_FOUND OFF)
else ()
find_package(ZLIB)
endif ()
# On Ubuntu 14.10, 32-bit builds fail to link with -lsnappy, just ignore.
if (UNIX AND X64)
find_library(libsnappy snappy)
Expand Down
2 changes: 1 addition & 1 deletion clients/drcachesim/common/gzip_istream.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class gzip_istreambuf_t : public std::basic_streambuf<char, std::char_traits<cha
if (dir == std::ios_base::cur &&
((off >= 0 && gptr() + off < egptr()) ||
(off < 0 && gptr() + off >= eback())))
gbump(off);
gbump(static_cast<int>(off));
else {
// Unsupported!
return -1;
Expand Down
3 changes: 2 additions & 1 deletion clients/drcachesim/common/gzip_ostream.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class gzip_streambuf_t : public std::basic_streambuf<char, std::char_traits<char
}
int res = traits_type::not_eof(extra_char);
if (pptr() > pbase()) {
int len = gzwrite(file_, pbase(), pptr() - pbase());
int len =
gzwrite(file_, pbase(), static_cast<unsigned int>(pptr() - pbase()));
if (len < pptr() - pbase())
res = traits_type::eof();
}
Expand Down
2 changes: 1 addition & 1 deletion clients/drcachesim/common/zipfile_istream.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class zipfile_istreambuf_t : public std::basic_streambuf<char, std::char_traits<
if (dir == std::ios_base::cur &&
((off >= 0 && gptr() + off < egptr()) ||
(off < 0 && gptr() + off >= eback())))
gbump(off);
gbump(static_cast<int>(off));
else {
// Unsupported!
return -1;
Expand Down
3 changes: 2 additions & 1 deletion clients/drcachesim/common/zipfile_ostream.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ class zipfile_streambuf_t : public std::basic_streambuf<char, std::char_traits<c
}
int res = traits_type::not_eof(extra_char);
if (pptr() > pbase()) {
if (zipWriteInFileInZip(zip_, pbase(), pptr() - pbase()) != ZIP_OK)
if (zipWriteInFileInZip(
zip_, pbase(), static_cast<unsigned int>(pptr() - pbase())) != ZIP_OK)
res = traits_type::eof();
}
setp(buf_, buf_ + buffer_size_ - 1);
Expand Down
5 changes: 3 additions & 2 deletions clients/drcachesim/common/zlib_istream.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class zlib_istreambuf_t : public std::basic_streambuf<char, std::char_traits<cha
// If the last inflate didn't fill the output buffer, it
// finished with the input buffer and we need to read more.
if (zstream_.avail_out != 0) {
zstream_.avail_in = fread(buf_compressed_, 1, buffer_size_, file_);
zstream_.avail_in =
static_cast<uInt>(fread(buf_compressed_, 1, buffer_size_, file_));
if (ferror(file_) || zstream_.avail_in == 0)
return traits_type::eof();
zstream_.next_in = reinterpret_cast<Bytef *>(buf_compressed_);
Expand All @@ -110,7 +111,7 @@ class zlib_istreambuf_t : public std::basic_streambuf<char, std::char_traits<cha
if (dir == std::ios_base::cur &&
((off >= 0 && gptr() + off < egptr()) ||
(off < 0 && gptr() + off >= eback())))
gbump(off);
gbump(static_cast<int>(off));
else {
// Unsupported!
return -1;
Expand Down
6 changes: 3 additions & 3 deletions clients/drcachesim/tracer/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ close_thread_file(void *drcontext)
const int MAX_ITERS = 32; // Sanity limit to avoid hang.
do {
data->zstream.next_out = (Bytef *)data->buf_compressed;
data->zstream.avail_out = max_buf_size;
data->zstream.avail_out = static_cast<uInt>(max_buf_size);
res = deflate(&data->zstream, Z_FINISH);
NOTIFY(3, "final deflate => %d in=%d out=%d => in=%d, out=%d, wrote=%d\n",
res, 0, max_buf_size, data->zstream.avail_in, data->zstream.avail_out,
Expand Down Expand Up @@ -502,11 +502,11 @@ write_trace_data(void *drcontext, byte *towrite_start, byte *towrite_end,
(op_raw_compress.get_value() == "zlib" ||
op_raw_compress.get_value() == "gzip")) {
data->zstream.next_in = (Bytef *)towrite_start;
data->zstream.avail_in = size;
data->zstream.avail_in = static_cast<uInt>(size);
int res;
do {
data->zstream.next_out = (Bytef *)data->buf_compressed;
data->zstream.avail_out = max_buf_size;
data->zstream.avail_out = static_cast<uInt>(max_buf_size);
res = deflate(&data->zstream, Z_NO_FLUSH);
NOTIFY(3, "deflate => %d in=%d out=%d => in=%d, out=%d, write=%d\n",
res, size, size, data->zstream.avail_in,
Expand Down
2 changes: 1 addition & 1 deletion suite/runsuite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ if (arg_automated_ci)
else ()
# Disable -msgbox_mask by default to avoid hangs on cases where DR hits errors
# prior to option parsing.
set(build_tests "${build_tests}
set(base_cache "${base_cache}
AUTOMATED_TESTING:BOOL=ON")
# We assume our GitHub Actions automated CI has password-less sudo.
# Our Jenkins tester does not. CI_TRIGGER is only set for Actions.
Expand Down