From 863dbbb3d4a6d248ccd33092c17dcded2f194006 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 21 Oct 2018 20:11:13 +0200 Subject: fix warning: "Uninitialized argument" clang scan-build thinks os_system() could set `do_profiling` flag. Found by clang scan-build 5.0 --- src/nvim/eval.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 515dd0e69f..052e0e3f35 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -16461,6 +16461,7 @@ static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, bool retlist) { proftime_T wait_time; + bool profiling = do_profiling == PROF_YES; rettv->v_type = VAR_STRING; rettv->vval.v_string = NULL; @@ -16497,7 +16498,7 @@ static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, xfree(cmdstr); } - if (do_profiling == PROF_YES) { + if (profiling) { prof_child_enter(&wait_time); } @@ -16506,7 +16507,7 @@ static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, char *res = NULL; int status = os_system(argv, input, input_len, &res, &nread); - if (do_profiling == PROF_YES) { + if (profiling) { prof_child_exit(&wait_time); } -- cgit From e0f6f46c1b7ab486a84f2cfb8cda3e62035594aa Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 21 Oct 2018 21:33:49 +0200 Subject: fix warning: garbage/uninitialized value According to clang scan-build, `fromcol` could be uninitialized at line 2645. Found by clang scan-build 5.0 --- src/nvim/screen.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index f6d162aec2..5033a6dd7f 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2175,11 +2175,11 @@ win_line ( int n_skip = 0; /* nr of chars to skip for 'nowrap' */ - int fromcol, tocol; /* start/end of inverting */ - int fromcol_prev = -2; /* start of inverting after cursor */ - int noinvcur = FALSE; /* don't invert the cursor */ - pos_T *top, *bot; - int lnum_in_visual_area = FALSE; + int fromcol = 0, tocol = 0; // start/end of inverting + int fromcol_prev = -2; // start of inverting after cursor + int noinvcur = false; // don't invert the cursor + pos_T *top, *bot; + int lnum_in_visual_area = false; pos_T pos; long v; -- cgit From a8422818a74b56ab42a92cbf3c044165657a4060 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 21 Oct 2018 22:07:47 +0200 Subject: fix warning: null pointer dereference Found by clang scan-build 5.0 --- src/nvim/message.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/message.c b/src/nvim/message.c index 1778e0048f..5dafde5bd1 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1475,11 +1475,13 @@ void msg_prt_line(char_u *s, int list) while (!got_int) { if (n_extra > 0) { - --n_extra; - if (c_extra) + n_extra--; + if (c_extra) { c = c_extra; - else + } else { + assert(p_extra != NULL); c = *p_extra++; + } } else if ((l = utfc_ptr2len(s)) > 1) { col += utf_ptr2cells(s); char buf[MB_MAXBYTES + 1]; -- cgit From 2afebc4e5f551c7a4f7655d6d693a0ca745a6a31 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 21 Oct 2018 22:12:50 +0200 Subject: fix warning: "Dead assignment" `tv` is passed to the TYPVAL_ENCODE_CONV_FUNC_BEFORE_* macros, which don't appear to actually use that parameter. Found by clang scan-build 5.0 --- src/nvim/eval/typval_encode.c.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/eval/typval_encode.c.h b/src/nvim/eval/typval_encode.c.h index 4556ce8193..623bdfc93b 100644 --- a/src/nvim/eval/typval_encode.c.h +++ b/src/nvim/eval/typval_encode.c.h @@ -741,6 +741,7 @@ typval_encode_stop_converting_one_item: case kMPConvPartial: { partial_T *const pt = cur_mpsv->data.p.pt; tv = cur_mpsv->tv; + (void)tv; switch (cur_mpsv->data.p.stage) { case kMPConvPartialArgs: { TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv, -- cgit From f97496a21c5377990aeb65f940005159acd62a27 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 21 Oct 2018 22:38:48 +0200 Subject: fix warning: "Assigned value is garbage" clang scan-build noticed that find_command() may bitmask `eap->flags`. cmd_can_preview() only uses `ea.cmdidx`, but let's fix the warning... Found by clang scan-build 5.0 --- src/nvim/ex_docmd.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 2a733f5831..5533c57adb 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -10048,6 +10048,7 @@ bool cmd_can_preview(char_u *cmd) } exarg_T ea; + memset(&ea, 0, sizeof(ea)); // parse the command line ea.cmd = skip_range(cmd, NULL); if (*ea.cmd == '*') { -- cgit From 902ca26856b54125ca773da753b1ea361f064f09 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 21 Oct 2018 22:50:12 +0200 Subject: fix warning: null arg passed to 'nonnull' param Found by clang scan-build 5.0 --- src/nvim/ex_cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index bce0c35f67..99f8963dad 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -3299,7 +3299,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, endcolumn = (curwin->w_curswant == MAXCOL); } - if (sub_joining_lines(eap, pat, sub, cmd, !preview)) { + if (sub != NULL && sub_joining_lines(eap, pat, sub, cmd, !preview)) { return NULL; } -- cgit From 11ae6f418d6c8b62ea328e90a0ada3aff1ab9979 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 21 Oct 2018 23:13:19 +0200 Subject: fix warning: null arg passed to 'nonnull' param Found by clang scan-build 5.0 --- src/nvim/quickfix.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 89e0f40f4e..51a7dd670f 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4492,6 +4492,7 @@ static int qf_set_properties(qf_info_T *qi, dict_T *what, int action, } if ((di = tv_dict_find(what, S_LEN("items"))) != NULL) { if (di->di_tv.v_type == VAR_LIST) { + assert(qi->qf_lists[qf_idx].qf_title != NULL); char_u *title_save = vim_strsave(qi->qf_lists[qf_idx].qf_title); retval = qf_add_entries(qi, qf_idx, di->di_tv.vval.v_list, -- cgit