From 7751cd21f5ae8952f578a0ccd892e32c95a4ae8a Mon Sep 17 00:00:00 2001 From: Lucas Hermann Negri Date: Sun, 1 Feb 2015 15:31:58 -0200 Subject: [PATCH] Enable -Wconversion for version.c #1923 --- src/nvim/CMakeLists.txt | 1 - src/nvim/version.c | 21 ++++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index d78bd5f711..6fc5022d48 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -82,7 +82,6 @@ set(CONV_SOURCES syntax.c tag.c ui.c - version.c window.c) foreach(sfile ${CONV_SOURCES}) diff --git a/src/nvim/version.c b/src/nvim/version.c index 6056a9d2a7..892382ab65 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -4,6 +4,8 @@ /// Vim originated from Stevie version 3.6 (Fish disk 217) by GRWalter (Fred). #include +#include +#include #include "nvim/vim.h" #include "nvim/ascii.h" @@ -1008,8 +1010,8 @@ void maybe_intro_message(void) void intro_message(int colon) { int i; - int row; - int blanklines; + long row; + long blanklines; int sponsor; char *p; static char *(lines[]) = { @@ -1027,7 +1029,10 @@ void intro_message(int colon) }; // blanklines = screen height - # message lines - blanklines = (int)Rows - (ARRAY_SIZE(lines) - 1); + size_t lines_size = ARRAY_SIZE(lines); + assert(lines_size <= LONG_MAX); + + blanklines = Rows - ((long)lines_size - 1l); // Don't overwrite a statusline. Depends on 'cmdheight'. if (p_ls > 1) { @@ -1073,13 +1078,14 @@ void intro_message(int colon) // Make the wait-return message appear just below the text. if (colon) { - msg_row = row; + assert(row <= INT_MAX); + msg_row = (int)row; } } -static void do_intro_line(int row, char_u *mesg, int attr) +static void do_intro_line(long row, char_u *mesg, int attr) { - int col; + long col; char_u *p; int l; int clen; @@ -1106,7 +1112,8 @@ static void do_intro_line(int row, char_u *mesg, int attr) clen += byte2cells(p[l]); } } - screen_puts_len(p, l, row, col, *p == '<' ? hl_attr(HLF_8) : attr); + assert(row <= INT_MAX && col <= INT_MAX); + screen_puts_len(p, l, (int)row, (int)col, *p == '<' ? hl_attr(HLF_8) : attr); col += clen; } }