Add a Windows build target to Travis checks. by dbaarda · Pull Request #208 · librsync/librsync

added 14 commits

June 1, 2020 13:46
Using cmake works regardless of what build system is chosen on the different
target platforms. In particular, this should make it work for Windows builds.
This is the only place we have LIBRSYNC_EXPORT on function definitions in *.c
files and they shouldn't be there, as they break compiling tests on windows.

Note the introduction of netint_test is the first test that links trace.c, so
is the first time we've noticed this failure on Windows.
This is necessary for build systems that support multiple configurations, like
Windows.
It seems passing `--config Debug` to cmake in .travis.yml didn't work. Instead
we need to pass `-C Debug` to ctest in CMakeLists.txt to make it work on
Windows.
Add explicit typecasts whenever truncating or upsizing values. Add 'U' to any
literals that were intended to be unsigned.
This silences MSVC warnings about constant overflows from using a multiply.
Add explicit typecasts for truncating or expanding values. This silences MSVC
warnings about possible loss of data.
In job.h change copy_len and write_len to size_t from rs_long_t and int.

In stream.[hc] and tube.c remove unimplemented/unused rs_buffers_is_empty(),
rs_check_tube(), and rs_buffers_check_exit(). Change all len arguments to
size_t. Change rs_tube_catchup() return to rs_result from int. Tidy code order
in header to reflect order in code. Make trace output more consistent.
This closes out a TODO for this. Move big description comment from stream.c to
stream.h. Move rs_buffers_copy() from stream.c to rs_tube_copy_from_stream()
in tube.c. Make rs_tube_catchup_write()'s trace output a little more
consistent. Make rs_tube_copy_from_scoop() do nothing when there's no input
our output space.
Add 2 explicit conversions where trucation is desired behavour.

sourcefrog

This makes the structure and trace output of rs_tube_catchup_write() more
consistent with the tube.c copy handling functions.
Fix s_patch_s_copying() to use rs_long_t for the request copy length, and make
it -Wconversion compliant. This would have broken long file support on 32bit
platforms.

Improve trace output from rs_patch_s_cmdbyte(). Make rs_patch_s_params() more
-Wconversion compliant by using size_t for a buffer length.

Change prototab.h len_1 and len_2 fields from size_t to int, which makes
various code more -Wconversion compliant (netint.c use int for lengths of
these parameters).
This ensures that Windows compiles don't complain about export stuff when
compiling this test.
This ensures literal cmds that are 0 or greater than size_t will abort with an
error instead of potentially corrupting the output.
This silences the last warning about hashtable.[ch] when building on windows.
Add `/D_CRT_SECURE_NO_WARNINGS` to MSVC CFLAGS to turn off warnings about
posix functions.

Also add optional commented out `-Wconversion` and `-Wno-sign-conversion`
flags for gcc and clang for easy experimenting with more warnings.
This silences the last warning on Travis when compiling with MSVC.
This silences the last warnings for stats.c when compiling with MSVC.
This silences the last warnings about sumset.[ch] compiling with MSVC.

Note this still has `-Wsign-conversion` warnings, but they are annoyingly
spurious, and nearly all about mixing size_t with signed ints.
On window io.h is needed for _setmode(), and it has both fileno() and
_fileno() but warns that fileno() is deprecated.

@dbaarda

@dbaarda

Apparently fread() returns a size_t which can never be negative, so returning
-1 is not how it indicates an error. Instead you should use ferror() to check
if there was an error.

This also makes fileutil.c `-Wconversion -Wno-sign-conversion` compliant.

@dbaarda

@dbaarda