Skip to content

Commit

Permalink
Build fixes:
Browse files Browse the repository at this point in the history
- Fixed build error, which was previously introduced by commit
c8ca891

- Treat warnings as errors
  • Loading branch information
9EOR9 committed Aug 16, 2023
1 parent c8ca891 commit 1acb81e
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 12 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Expand Up @@ -99,8 +99,6 @@ IF(MSVC)
INCLUDE(${CC_SOURCE_DIR}/cmake/WindowsCache.cmake)
ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN -DNOGDI)
IF (MSVC)
# Treat warnings as errors
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -WX")
SET(CONFIG_TYPES "DEBUG" "RELEASE" "RELWITHDEBINFO")
FOREACH(BUILD_TYPE ${CONFIG_TYPES})
FOREACH(COMPILER CXX C)
Expand Down Expand Up @@ -144,6 +142,13 @@ IF(CMAKE_COMPILER_IS_GNUCC)
ENDFOREACH()
ENDIF()

IF (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "GNU")
SET(WARNING_AS_ERROR "-Werror" CACHE INTERNAL "WARNING_AS_ERROR")
ELSEIF(CMAKE_C_COMPILER_ID MATCHES "MSVC")
SET(WARNING_AS_ERROR "/WX" CACHE INTERNAL "WARNING_AS_ERROR")
ENDIF()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_AS_ERROR}")

# If the build type isn't specified, set to Relwithdebinfo as default.
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "RelWithDebInfo")
Expand Down
3 changes: 3 additions & 0 deletions external/zlib/CMakeLists.txt
Expand Up @@ -5,6 +5,9 @@ project(zlib C)

set(VERSION "1.2.13")

# Don't treat warnings as error for zlib
STRING(REPLACE ${WARNING_AS_ERROR} "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})

set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
Expand Down
1 change: 1 addition & 0 deletions include/ma_global.h
Expand Up @@ -27,6 +27,7 @@
#include <stdlib.h>
#define strcasecmp _stricmp
#define strtok_r strtok_s
#define strdup _strdup
#define sleep(x) Sleep(1000*(x))
#ifdef _MSC_VER
#define inline __inline
Expand Down
2 changes: 2 additions & 0 deletions libmariadb/ma_default.c
Expand Up @@ -29,6 +29,8 @@
#include <io.h>
#include "shlwapi.h"

#define access _access

static const char *ini_exts[]= {"ini", "cnf", 0};
#define R_OK 4
#else
Expand Down
5 changes: 3 additions & 2 deletions libmariadb/mariadb_rpl.c
Expand Up @@ -962,7 +962,7 @@ static uint8_t mariadb_rpl_send_semisync_ack(MARIADB_RPL* rpl, MARIADB_RPL_EVENT
rpl_set_error(rpl, CR_BINLOG_SEMI_SYNC_ERROR, 0, "semi synchronous replication is not enabled");
return 1;
}
if (!event->is_semi_sync || !event->semi_sync_flags != SEMI_SYNC_ACK_REQ)
if (!event->is_semi_sync || (event->semi_sync_flags != SEMI_SYNC_ACK_REQ))
{
rpl_set_error(rpl, CR_BINLOG_SEMI_SYNC_ERROR, 0, "This event doesn't require to send semi synchronous acknoledgement");
return 1;
Expand All @@ -972,7 +972,7 @@ static uint8_t mariadb_rpl_send_semisync_ack(MARIADB_RPL* rpl, MARIADB_RPL_EVENT
buf = alloca(buf_size);

buf[0] = SEMI_SYNC_INDICATOR;
int8store(buf + 1, event->next_event_pos);
int8store(buf + 1, (uint64_t)event->next_event_pos);
memcpy(buf + 9, rpl->filename, rpl->filename_length);

ma_net_clear(&rpl->mysql->net);
Expand Down Expand Up @@ -2084,6 +2084,7 @@ int STDCALL mariadb_rpl_get_optionsv(MARIADB_RPL *rpl,
{
unsigned int* semi_sync = va_arg(ap, unsigned int*);
*semi_sync = rpl->is_semi_sync;
break;
}

default:
Expand Down
6 changes: 1 addition & 5 deletions unittest/libmariadb/ma_getopt.h
Expand Up @@ -121,11 +121,7 @@ extern int _getopt_internal (int argc, char *const *argv,
const struct option *longopts, int *longind,
int long_only);
#else /* not __STDC__ */
extern int getopt ();
extern int getopt_long ();
extern int getopt_long_only ();

extern int _getopt_internal ();
extern int getopt (int argc, char *const *argv, const char *optstring);
#endif /* __STDC__ */

#ifdef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions unittest/libmariadb/my_test.h
Expand Up @@ -38,6 +38,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <pthread.h>
#else
#include <io.h>
#define unlink _unlink
#endif

#ifndef OK
Expand Down
6 changes: 3 additions & 3 deletions unittest/libmariadb/rpl_api.c
Expand Up @@ -342,9 +342,9 @@ static int test_conc592(MYSQL *my __attribute__((unused)))
}

struct my_tests_st my_tests[] = {
// {"test_conc592", test_conc592, TEST_CONNECTION_NEW, 0, NULL, NULL},
//{"test_rpl_async", test_rpl_async, TEST_CONNECTION_NEW, 0, NULL, NULL},
//{"test_rpl_semisync", test_rpl_semisync, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc592", test_conc592, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_rpl_async", test_rpl_async, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_rpl_semisync", test_rpl_semisync, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc467", test_conc467, TEST_CONNECTION_NEW, 0, NULL, NULL},
{NULL, NULL, 0, 0, NULL, NULL}
};
Expand Down

0 comments on commit 1acb81e

Please sign in to comment.