From e32c9f888bf63427c923e2f6621d582e95680c70 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 1 Apr 2019 02:57:43 +0200 Subject: [PATCH 1/3] clang/"result is garbage/undefined": win_close win_free_mem: set `dirp` to a dummy value. --- src/nvim/window.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/nvim/window.c b/src/nvim/window.c index ad38a34dac..e135d7436d 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2575,15 +2575,12 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) free_tabpage(tp); } -/* - * Free the memory used for a window. - * Returns a pointer to the window that got the freed up space. - */ -static win_T * -win_free_mem ( +// Free the memory used for a window. +// Returns a pointer to the window that got the freed up space. +static win_T *win_free_mem( win_T *win, - int *dirp, /* set to 'v' or 'h' for direction if 'ea' */ - tabpage_T *tp /* tab page "win" is in, NULL for current */ + int *dirp, // set to 'v' or 'h' for direction if 'ea' + tabpage_T *tp // tab page "win" is in, NULL for current ) { frame_T *frp; @@ -2595,6 +2592,7 @@ win_free_mem ( wp = winframe_remove(win, dirp, tp); xfree(frp); } else { + *dirp = 'h'; // Dummy value. if (win_valid(prevwin) && prevwin != win) { wp = prevwin; } else { @@ -2603,10 +2601,11 @@ win_free_mem ( } win_free(win, tp); - /* When deleting the current window of another tab page select a new - * current window. */ - if (tp != NULL && win == tp->tp_curwin) + // When deleting the current window of another tab page select a new + // current window. + if (tp != NULL && win == tp->tp_curwin) { tp->tp_curwin = wp; + } return wp; } From cf4e14c74663304f7cf61f587963b91587b3034e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 1 Apr 2019 03:05:03 +0200 Subject: [PATCH 2/3] clang/"null pointer dereference": insert_execute --- src/nvim/edit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/nvim/edit.c b/src/nvim/edit.c index e6d9dcf092..1814e9d3d4 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -667,8 +667,9 @@ static int insert_execute(VimState *state, int key) // there is nothing to add, CTRL-L works like CTRL-P then. if (s->c == Ctrl_L && (!CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode) - || (int)STRLEN(compl_shown_match->cp_str) - > curwin->w_cursor.col - compl_col)) { + || (compl_shown_match->cp_str != NULL + && (int)STRLEN(compl_shown_match->cp_str) + > curwin->w_cursor.col - compl_col))) { ins_compl_addfrommatch(); return 1; // continue } From acdcae6b1e14233e75b98b8e88840afeb96d5fb7 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 1 Apr 2019 03:07:24 +0200 Subject: [PATCH 3/3] PVS/V560: expression is always true --- src/nvim/edit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 1814e9d3d4..4d22d427e4 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -3006,7 +3006,6 @@ bool ins_compl_active(void) // Get complete information void get_complete_info(list_T *what_list, dict_T *retdict) { - int ret = OK; #define CI_WHAT_MODE 0x01 #define CI_WHAT_PUM_VISIBLE 0x02 #define CI_WHAT_ITEMS 0x04 @@ -3038,7 +3037,8 @@ void get_complete_info(list_T *what_list, dict_T *retdict) } } - if (ret == OK && (what_flag & CI_WHAT_MODE)) { + int ret = OK; + if (what_flag & CI_WHAT_MODE) { ret = tv_dict_add_str(retdict, S_LEN("mode"), (char *)ins_compl_mode()); }