From 8440283985dfdff365719701e90ab7d81abb487d Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Fri, 3 Nov 2023 15:32:55 -0700 Subject: [PATCH] Reduce number of warnings on Windows --- t/CMakeLists.txt | 6 ++++++ t/bad_pointers_t.c | 3 +-- t/maxminddb_test_helper.c | 7 ++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/t/CMakeLists.txt b/t/CMakeLists.txt index 44993718..06f17e82 100644 --- a/t/CMakeLists.txt +++ b/t/CMakeLists.txt @@ -29,6 +29,12 @@ if(UNIX) # or if (NOT WIN32) find_package(Threads) endif() +if(WIN32) + # libtap caused a significant number of conversion warning on Windows + add_definitions("/wd4244 /wd4267") +endif(WIN32) + + foreach(TEST_TARGET_NAME ${TEST_TARGET_NAMES}) add_executable(${TEST_TARGET_NAME} ${TEST_TARGET_NAME}.c maxminddb_test_helper.c) target_include_directories(${TEST_TARGET_NAME} PRIVATE ../src) diff --git a/t/bad_pointers_t.c b/t/bad_pointers_t.c index 6247539a..9dd0cf81 100644 --- a/t/bad_pointers_t.c +++ b/t/bad_pointers_t.c @@ -36,8 +36,7 @@ void run_tests(int mode, const char *mode_desc) { const char *ip = "1.1.1.32"; int gai_error, mmdb_error; - MMDB_lookup_result_s UNUSED(result) = - MMDB_lookup_string(mmdb, ip, &gai_error, &mmdb_error); + MMDB_lookup_string(mmdb, ip, &gai_error, &mmdb_error); cmp_ok(mmdb_error, "==", diff --git a/t/maxminddb_test_helper.c b/t/maxminddb_test_helper.c index 8193c6f0..be2eb1b8 100644 --- a/t/maxminddb_test_helper.c +++ b/t/maxminddb_test_helper.c @@ -80,7 +80,12 @@ char *dup_entry_string_or_bail(MMDB_entry_data_s entry_data) { } MMDB_s *open_ok(const char *db_file, int mode, const char *mode_desc) { - if (0 != access(db_file, R_OK)) { +#ifdef _WIN32 + int access_rv = _access(db_file, 04); +#else + int access_rv = access(db_file, R_OK); +#endif + if (access_rv != 0) { BAIL_OUT("could not read the specified file - %s\nIf you are in a git " "checkout try running 'git submodule update --init'", db_file);