From f7f71465884582deb64e961c83ac0100e5af2c8c Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 8 Mar 2021 20:57:58 -0500 Subject: [PATCH 1/3] vim-patch:8.2.2577: compiler warning for type conversion Problem: Compiler warning for type conversion. Solution: Add a typecast. (Mike Williams) https://github.com/vim/vim/commit/9355ae41497cbcce58ddd79f9125eb3e9dfe0a43 N/A patches for version.c: vim-patch:8.1.0783: compiler warning for signed/unsigned Problem: Compiler warning for signed/unsigned. Solution: Add type cast. Change type of buffer. (Ozaki Kiichi, closes vim/vim#3827) https://github.com/vim/vim/commit/63c0ccd2b68ce854f294e6f149cc700c7f543674 Neovim was refactored to prefer char type for string functions, not char_u. vim-patch:8.2.2152: screenpos() does not include the WinBar offset Problem: screenpos() does not include the WinBar offset. Solution: Use W_WINROW() instead of directly using w_window. (closes vim/vim#7487) https://github.com/vim/vim/commit/8dd46e72cfb13b8de793c808ee009c45e881903a W_WINROW() was removed so port only the test changes. The test is currently skipped. --- src/nvim/screen.c | 2 +- src/nvim/testdir/test_cursor_func.vim | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 20e3cc0a2e..47f1cb6423 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2656,7 +2656,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, // already be in use. xfree(p_extra_free); p_extra_free = xmalloc(MAX_MCO * fdc + 1); - n_extra = fill_foldcolumn(p_extra_free, wp, foldinfo, lnum); + n_extra = (int)fill_foldcolumn(p_extra_free, wp, foldinfo, lnum); p_extra_free[n_extra] = NUL; p_extra = p_extra_free; c_extra = NUL; diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index 2e190911b2..53b7da517e 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -92,6 +92,11 @@ func Test_screenpos() \ 'endcol': wincol + 9}, screenpos(winid, 2, 22)) close bwipe! + + call assert_equal({'col': 1, 'row': 1, 'endcol': 1, 'curscol': 1}, screenpos(win_getid(), 1, 1)) + nmenu WinBar.TEST : + call assert_equal({'col': 1, 'row': 2, 'endcol': 1, 'curscol': 1}, screenpos(win_getid(), 1, 1)) + nunmenu WinBar.TEST endfunc func Test_screenpos_number() From effd234960140be4ec9a66411db162594a2b6906 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 8 Mar 2021 21:15:23 -0500 Subject: [PATCH 2/3] vim-patch:8.2.1507: using malloc() directly Problem: Using malloc() directly. Solution: Use ALLOC_ONE(). Remove superfluous typecast. (Hussam al-Homsi, closes vim/vim#6768) https://github.com/vim/vim/commit/51b6eb47b3c41b01a5559b099e65354c8897093e --- src/nvim/eval.c | 24 ++++++++---------------- src/nvim/memline.c | 4 ++-- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 6d97310c1c..63d5216cc4 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5280,14 +5280,10 @@ bool set_ref_in_item(typval_T *tv, int copyID, ht_stack_T **ht_stack, if (ht_stack == NULL) { abort = set_ref_in_ht(&dd->dv_hashtab, copyID, list_stack); } else { - ht_stack_T *newitem = try_malloc(sizeof(ht_stack_T)); - if (newitem == NULL) { - abort = true; - } else { - newitem->ht = &dd->dv_hashtab; - newitem->prev = *ht_stack; - *ht_stack = newitem; - } + ht_stack_T *const newitem = xmalloc(sizeof(ht_stack_T)); + newitem->ht = &dd->dv_hashtab; + newitem->prev = *ht_stack; + *ht_stack = newitem; } QUEUE *w = NULL; @@ -5308,14 +5304,10 @@ bool set_ref_in_item(typval_T *tv, int copyID, ht_stack_T **ht_stack, if (list_stack == NULL) { abort = set_ref_in_list(ll, copyID, ht_stack); } else { - list_stack_T *newitem = try_malloc(sizeof(list_stack_T)); - if (newitem == NULL) { - abort = true; - } else { - newitem->list = ll; - newitem->prev = *list_stack; - *list_stack = newitem; - } + list_stack_T *const newitem = xmalloc(sizeof(list_stack_T)); + newitem->list = ll; + newitem->prev = *list_stack; + *list_stack = newitem; } } break; diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 293a4d01db..34d8eb0ffe 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -3859,8 +3859,8 @@ static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype) /* May resize here so we don't have to do it in both cases below */ if (buf->b_ml.ml_usedchunks + 1 >= buf->b_ml.ml_numchunks) { buf->b_ml.ml_numchunks = buf->b_ml.ml_numchunks * 3 / 2; - buf->b_ml.ml_chunksize = (chunksize_T *) - xrealloc(buf->b_ml.ml_chunksize, + buf->b_ml.ml_chunksize = xrealloc( + buf->b_ml.ml_chunksize, sizeof(chunksize_T) * buf->b_ml.ml_numchunks); } From 7da8056607331f12b912b4a7c65592ac317c2ff4 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 8 Mar 2021 23:29:30 -0500 Subject: [PATCH 3/3] vim-patch:8.2.2438: out of bounds compiler warning Problem: Out of bounds compiler warning. Solution: Increase the size of uf_name. https://github.com/vim/vim/commit/6a12e3342d84a1d754d793ed5019778bd60e7494 Do not set size of uf_name to avoid compiler warnings. Port only the comments. --- src/nvim/eval/typval.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 6fcb01aace..531b17cb59 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -341,8 +341,9 @@ struct ufunc { ///< used for s: variables int uf_refcount; ///< reference count, see func_name_refcount() funccall_T *uf_scoped; ///< l: local variables for closure - char_u uf_name[]; ///< Name of function; can start with 123_ - ///< ( is K_SPECIAL KS_EXTRA KE_SNR) + char_u uf_name[]; ///< Name of function (actual size equals name); + ///< can start with 123_ + ///< ( is K_SPECIAL KS_EXTRA KE_SNR) }; struct partial_S {