Merge pull request #21031 from dundargoc/fix/windows

ci(windows): treat compiler warnings as errors
This commit is contained in:
bfredl 2022-11-15 10:35:25 +01:00 committed by GitHub
commit c6c265a86c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 13 deletions

View File

@ -5,6 +5,12 @@
# Version should match the tested CMAKE_URL in .github/workflows/ci.yml. # Version should match the tested CMAKE_URL in .github/workflows/ci.yml.
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
# Can be removed once minimum version is at least 3.15
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW)
endif()
project(nvim C) project(nvim C)
if(POLICY CMP0075) if(POLICY CMP0075)
@ -270,7 +276,7 @@ int main(void)
option(ENABLE_COMPILER_SUGGESTIONS "Enable -Wsuggest compiler warnings" OFF) option(ENABLE_COMPILER_SUGGESTIONS "Enable -Wsuggest compiler warnings" OFF)
if(MSVC) if(MSVC)
# XXX: /W4 gives too many warnings. #3241 # XXX: /W4 gives too many warnings. #3241
add_compile_options(/W3) add_compile_options(-W1 -wd4311)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-DMSWIN) add_definitions(-DMSWIN)
else() else()
@ -364,11 +370,15 @@ option(CI_BUILD "CI, extra flags will be set" OFF)
if(CI_BUILD) if(CI_BUILD)
message(STATUS "CI build enabled") message(STATUS "CI build enabled")
if(MSVC)
add_compile_options(-WX)
else()
add_compile_options(-Werror) add_compile_options(-Werror)
if(DEFINED ENV{BUILD_UCHAR}) if(DEFINED ENV{BUILD_UCHAR})
# Get some test coverage for unsigned char # Get some test coverage for unsigned char
add_compile_options(-funsigned-char) add_compile_options(-funsigned-char)
endif() endif()
endif()
endif() endif()
option(LOG_LIST_ACTIONS "Add list actions logging" OFF) option(LOG_LIST_ACTIONS "Add list actions logging" OFF)

View File

@ -1512,7 +1512,7 @@ static char *find_pipe(const char *cmd)
for (const char *p = cmd; *p != NUL; p++) { for (const char *p = cmd; *p != NUL; p++) {
if (!inquote && *p == '|') { if (!inquote && *p == '|') {
return p; return (char *)p;
} }
if (*p == '"') { if (*p == '"') {
inquote = !inquote; inquote = !inquote;

View File

@ -1639,6 +1639,7 @@ int execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo, bool preview)
char *errormsg = NULL; char *errormsg = NULL;
int retv = 0; int retv = 0;
#undef ERROR
#define ERROR(msg) \ #define ERROR(msg) \
do { \ do { \
errormsg = msg; \ errormsg = msg; \

View File

@ -585,7 +585,7 @@ static bool nlua_init_packages(lua_State *lstate)
lua_getglobal(lstate, "require"); lua_getglobal(lstate, "require");
lua_pushstring(lstate, "vim._init_packages"); lua_pushstring(lstate, "vim._init_packages");
if (nlua_pcall(lstate, 1, 0)) { if (nlua_pcall(lstate, 1, 0)) {
mch_errmsg(lua_tostring(lstate, -1)); mch_errmsg((char *)lua_tostring(lstate, -1));
mch_errmsg("\n"); mch_errmsg("\n");
return false; return false;
} }

View File

@ -1273,7 +1273,7 @@ scripterror:
vim_snprintf((char *)IObuff, IOSIZE, vim_snprintf((char *)IObuff, IOSIZE,
_("Attempt to open script file again: \"%s %s\"\n"), _("Attempt to open script file again: \"%s %s\"\n"),
argv[-1], argv[0]); argv[-1], argv[0]);
mch_errmsg((const char *)IObuff); mch_errmsg(IObuff);
os_exit(2); os_exit(2);
} }
int error; int error;
@ -1292,7 +1292,7 @@ scripterror:
vim_snprintf((char *)IObuff, IOSIZE, vim_snprintf((char *)IObuff, IOSIZE,
_("Cannot open for reading: \"%s\": %s\n"), _("Cannot open for reading: \"%s\": %s\n"),
argv[0], os_strerror(error)); argv[0], os_strerror(error));
mch_errmsg((const char *)IObuff); mch_errmsg(IObuff);
os_exit(2); os_exit(2);
} }
save_typebuf(); save_typebuf();
@ -2055,7 +2055,7 @@ static void mainerr(const char *errstr, const char *str)
mch_errmsg(_(errstr)); mch_errmsg(_(errstr));
if (str != NULL) { if (str != NULL) {
mch_errmsg(": \""); mch_errmsg(": \"");
mch_errmsg(str); mch_errmsg((char *)str);
mch_errmsg("\""); mch_errmsg("\"");
} }
mch_errmsg(_("\nMore info with \"")); mch_errmsg(_("\nMore info with \""));

View File

@ -67,7 +67,7 @@ conpty_t *os_conpty_init(char **in_name, char **out_name, uint16_t width, uint16
| PIPE_ACCESS_OUTBOUND | FILE_FLAG_FIRST_PIPE_INSTANCE; | PIPE_ACCESS_OUTBOUND | FILE_FLAG_FIRST_PIPE_INSTANCE;
sa.nLength = sizeof(sa); sa.nLength = sizeof(sa);
snprintf(buf, sizeof(buf), "\\\\.\\pipe\\nvim-term-in-%d-%d", snprintf(buf, sizeof(buf), "\\\\.\\pipe\\nvim-term-in-%lld-%d",
os_get_pid(), count); os_get_pid(), count);
*in_name = xstrdup(buf); *in_name = xstrdup(buf);
if ((in_read = CreateNamedPipeA(*in_name, if ((in_read = CreateNamedPipeA(*in_name,
@ -81,7 +81,7 @@ conpty_t *os_conpty_init(char **in_name, char **out_name, uint16_t width, uint16
emsg = "create input pipe failed"; emsg = "create input pipe failed";
goto failed; goto failed;
} }
snprintf(buf, sizeof(buf), "\\\\.\\pipe\\nvim-term-out-%d-%d", snprintf(buf, sizeof(buf), "\\\\.\\pipe\\nvim-term-out-%lld-%d",
os_get_pid(), count); os_get_pid(), count);
*out_name = xstrdup(buf); *out_name = xstrdup(buf);
if ((out_write = CreateNamedPipeA(*out_name, if ((out_write = CreateNamedPipeA(*out_name,

View File

@ -1867,7 +1867,7 @@ char *fix_fname(const char *fname)
fname = xstrdup(fname); fname = xstrdup(fname);
# ifdef USE_FNAME_CASE # ifdef USE_FNAME_CASE
path_fix_case(fname); // set correct case for file name path_fix_case((char *)fname); // set correct case for file name
# endif # endif
return (char *)fname; return (char *)fname;