From 184b87ee31170465b072b11c21e2bb15b15f6fe5 Mon Sep 17 00:00:00 2001 From: ddcien Date: Mon, 22 Jul 2019 18:38:14 +0800 Subject: build: fix gcc warnings #10568 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc version 8.3.0 (Debian 8.3.0-6) ../src/nvim/ex_docmd.c: In function ‘commands_array’: ../src/nvim/ex_docmd.c:10192:36: warning: ‘%ld’ directive output may be truncated writing between 1 and 19 bytes into a region of size 10 [-Wformat-truncation=] snprintf(str, sizeof(str), "%" PRId64, (int64_t)cmd->uc_def); ^~~ ../src/nvim/ex_docmd.c:10192:37: note: format string is defined here snprintf(str, sizeof(str), "%" PRId64, (int64_t)cmd->uc_def); ../src/nvim/ex_docmd.c:10192:36: note: directive argument in the range [0, 9223372036854775807] snprintf(str, sizeof(str), "%" PRId64, (int64_t)cmd->uc_def); ^~~ ../src/nvim/ex_docmd.c:10192:9: note: ‘snprintf’ output between 2 and 20 bytes into a destination of size 10 snprintf(str, sizeof(str), "%" PRId64, (int64_t)cmd->uc_def); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/nvim/ex_docmd.c:10205:36: warning: ‘%ld’ directive output may be truncated writing between 1 and 19 bytes into a region of size 10 [-Wformat-truncation=] snprintf(str, sizeof(str), "%" PRId64, (int64_t)cmd->uc_def); ^~~ ../src/nvim/ex_docmd.c:10205:37: note: format string is defined here snprintf(str, sizeof(str), "%" PRId64, (int64_t)cmd->uc_def); ../src/nvim/ex_docmd.c:10205:36: note: directive argument in the range [0, 9223372036854775807] snprintf(str, sizeof(str), "%" PRId64, (int64_t)cmd->uc_def); ^~~ ../src/nvim/ex_docmd.c:10205:9: note: ‘snprintf’ output between 2 and 20 bytes into a destination of size 10 snprintf(str, sizeof(str), "%" PRId64, (int64_t)cmd->uc_def); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/nvim/spell.c: In function ‘did_set_spelllang’: ../src/nvim/spell.c:1631:61: warning: ‘%s’ directive output may be truncated writing up to 254 bytes into a region of size 84 [-Wformat-truncation=] "autocmd VimEnter * call spellfile#LoadFile('%s')|set spell", ^~ ../src/nvim/spell.c:2063:25: spell_load_lang(lang); ~~~~ ../src/nvim/spell.c:1630:7: note: ‘snprintf’ output between 57 and 311 bytes into a destination of size 128 snprintf(autocmd_buf, sizeof(autocmd_buf), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "autocmd VimEnter * call spellfile#LoadFile('%s')|set spell", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lang); ~~~~~ ../src/nvim/window.c: In function ‘win_rotate’: ../src/nvim/window.c:1780:22: warning: ‘wp2’ may be used uninitialized in this function [-Wmaybe-uninitialized] wp2->w_pos_changed = true; ^ ../src/nvim/window.c:1779:22: warning: ‘wp1’ may be used uninitialized in this function [-Wmaybe-uninitialized] wp1->w_pos_changed = true; --- src/nvim/ex_docmd.c | 2 +- src/nvim/spell.c | 2 +- src/nvim/window.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index af4f34d907..af5635ddba 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -10172,7 +10172,7 @@ Dictionary commands_array(buf_T *buf) Dictionary rv = ARRAY_DICT_INIT; Object obj = NIL; (void)obj; // Avoid "dead assignment" warning. - char str[10]; + char str[20]; garray_T *gap = (buf == NULL) ? &ucmds : &buf->b_ucmds; for (int i = 0; i < gap->ga_len; i++) { diff --git a/src/nvim/spell.c b/src/nvim/spell.c index b5885e65f3..66eb4ac3c6 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -1626,7 +1626,7 @@ static void spell_load_lang(char_u *lang) if (starting) { // Prompt the user at VimEnter if spell files are missing. #3027 // Plugins aren't loaded yet, so spellfile.vim cannot handle this case. - char autocmd_buf[128] = { 0 }; + char autocmd_buf[512] = { 0 }; snprintf(autocmd_buf, sizeof(autocmd_buf), "autocmd VimEnter * call spellfile#LoadFile('%s')|set spell", lang); diff --git a/src/nvim/window.c b/src/nvim/window.c index 377d712a50..22a8969b88 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1713,7 +1713,7 @@ static void win_rotate(bool upwards, int count) return; } - if (firstwin == curwin && lastwin_nofloating() == curwin) { + if (count <= 0 || (firstwin == curwin && lastwin_nofloating() == curwin)) { // nothing to do beep_flush(); return; -- cgit