mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #1488 from fwalch/invert-wconversion
Invert -Wconversion handling & fix some warnings.
This commit is contained in:
commit
32ec851270
@ -67,6 +67,9 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||||||
# Default to -O2 on release builds.
|
# Default to -O2 on release builds.
|
||||||
string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
||||||
|
|
||||||
|
# Enable -Wconversion.
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion")
|
||||||
|
|
||||||
# gcc 4.0 and better turn on _FORTIFY_SOURCE=2 automatically. This currently
|
# gcc 4.0 and better turn on _FORTIFY_SOURCE=2 automatically. This currently
|
||||||
# does not work with Neovim due to some uses of dynamically-sized structures.
|
# does not work with Neovim due to some uses of dynamically-sized structures.
|
||||||
# See https://github.com/neovim/neovim/issues/223 for details.
|
# See https://github.com/neovim/neovim/issues/223 for details.
|
||||||
|
@ -38,19 +38,57 @@ endforeach()
|
|||||||
|
|
||||||
list(REMOVE_ITEM NEOVIM_SOURCES ${to_remove})
|
list(REMOVE_ITEM NEOVIM_SOURCES ${to_remove})
|
||||||
|
|
||||||
|
# Handle legacy files that don't yet pass -Wconversion.
|
||||||
set(CONV_SOURCES
|
set(CONV_SOURCES
|
||||||
arabic.c
|
buffer.c
|
||||||
cursor.c
|
charset.c
|
||||||
garray.c
|
diff.c
|
||||||
hashtab.c
|
edit.c
|
||||||
log.c
|
eval.c
|
||||||
map.c
|
ex_cmds2.c
|
||||||
memfile.c
|
ex_cmds.c
|
||||||
memory.c
|
ex_docmd.c
|
||||||
misc2.c
|
ex_eval.c
|
||||||
profile.c
|
ex_getln.c
|
||||||
tempfile.c
|
farsi.c
|
||||||
)
|
fileio.c
|
||||||
|
file_search.c
|
||||||
|
fold.c
|
||||||
|
getchar.c
|
||||||
|
hardcopy.c
|
||||||
|
if_cscope.c
|
||||||
|
indent.c
|
||||||
|
indent_c.c
|
||||||
|
keymap.c
|
||||||
|
main.c
|
||||||
|
mark.c
|
||||||
|
mbyte.c
|
||||||
|
memline.c
|
||||||
|
menu.c
|
||||||
|
message.c
|
||||||
|
misc1.c
|
||||||
|
move.c
|
||||||
|
normal.c
|
||||||
|
ops.c
|
||||||
|
option.c
|
||||||
|
os_unix.c
|
||||||
|
path.c
|
||||||
|
popupmnu.c
|
||||||
|
quickfix.c
|
||||||
|
regexp.c
|
||||||
|
regexp_nfa.c
|
||||||
|
screen.c
|
||||||
|
search.c
|
||||||
|
sha256.c
|
||||||
|
spell.c
|
||||||
|
strings.c
|
||||||
|
syntax.c
|
||||||
|
tag.c
|
||||||
|
term.c
|
||||||
|
ui.c
|
||||||
|
undo.c
|
||||||
|
version.c
|
||||||
|
window.c)
|
||||||
|
|
||||||
foreach(sfile ${CONV_SOURCES})
|
foreach(sfile ${CONV_SOURCES})
|
||||||
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/src/nvim/${sfile}")
|
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/src/nvim/${sfile}")
|
||||||
@ -58,14 +96,8 @@ foreach(sfile ${CONV_SOURCES})
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
file(GLOB_RECURSE EXTRA_CONV_SOURCES os/*.c api/*.c msgpack_rpc/*.c)
|
|
||||||
foreach(sfile ${EXTRA_CONV_SOURCES})
|
|
||||||
file(RELATIVE_PATH f "${PROJECT_SOURCE_DIR}/src/nvim" "${sfile}")
|
|
||||||
list(APPEND CONV_SOURCES ${f})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
set_source_files_properties(
|
set_source_files_properties(
|
||||||
${CONV_SOURCES} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -Wconversion")
|
${CONV_SOURCES} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-conversion")
|
||||||
|
|
||||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||||
if(DEFINED ENV{SANITIZE})
|
if(DEFINED ENV{SANITIZE})
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
#include "nvim/ascii.h"
|
#include "nvim/ascii.h"
|
||||||
#include "nvim/cursor_shape.h"
|
#include "nvim/cursor_shape.h"
|
||||||
@ -52,7 +53,6 @@ char_u *parse_shape_opt(int what)
|
|||||||
int all_idx;
|
int all_idx;
|
||||||
int len;
|
int len;
|
||||||
int i;
|
int i;
|
||||||
long n;
|
|
||||||
int found_ve = FALSE; /* found "ve" flag */
|
int found_ve = FALSE; /* found "ve" flag */
|
||||||
int round;
|
int round;
|
||||||
|
|
||||||
@ -135,7 +135,9 @@ char_u *parse_shape_opt(int what)
|
|||||||
p += len;
|
p += len;
|
||||||
if (!VIM_ISDIGIT(*p))
|
if (!VIM_ISDIGIT(*p))
|
||||||
return (char_u *)N_("E548: digit expected");
|
return (char_u *)N_("E548: digit expected");
|
||||||
n = getdigits(&p);
|
long digits = getdigits(&p);
|
||||||
|
assert(digits <= INT_MAX);
|
||||||
|
int n = (int)digits;
|
||||||
if (len == 3) { /* "ver" or "hor" */
|
if (len == 3) { /* "ver" or "hor" */
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return (char_u *)N_("E549: Illegal percentage");
|
return (char_u *)N_("E549: Illegal percentage");
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
///
|
///
|
||||||
/// code for digraphs
|
/// code for digraphs
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
@ -1582,7 +1584,7 @@ int getdigraph(int char1, int char2, int meta_char)
|
|||||||
/// @param str
|
/// @param str
|
||||||
void putdigraph(char_u *str)
|
void putdigraph(char_u *str)
|
||||||
{
|
{
|
||||||
int char1, char2, n;
|
char_u char1, char2;
|
||||||
digr_T *dp;
|
digr_T *dp;
|
||||||
|
|
||||||
while (*str != NUL) {
|
while (*str != NUL) {
|
||||||
@ -1609,7 +1611,9 @@ void putdigraph(char_u *str)
|
|||||||
EMSG(_(e_number_exp));
|
EMSG(_(e_number_exp));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
n = getdigits(&str);
|
long digits = getdigits(&str);
|
||||||
|
assert(digits <= INT_MAX);
|
||||||
|
int n = (int)digits;
|
||||||
|
|
||||||
// If the digraph already exists, replace the result.
|
// If the digraph already exists, replace the result.
|
||||||
dp = (digr_T *)user_digraphs.ga_data;
|
dp = (digr_T *)user_digraphs.ga_data;
|
||||||
@ -1711,7 +1715,8 @@ static void printdigraph(digr_T *dp)
|
|||||||
if (char2cells(dp->result) == 1) {
|
if (char2cells(dp->result) == 1) {
|
||||||
*p++ = ' ';
|
*p++ = ' ';
|
||||||
}
|
}
|
||||||
vim_snprintf((char *)p, sizeof(buf) - (p - buf), " %3d", dp->result);
|
assert(p >= buf);
|
||||||
|
vim_snprintf((char *)p, sizeof(buf) - (size_t)(p - buf), " %3d", dp->result);
|
||||||
msg_outtrans(buf);
|
msg_outtrans(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user