From 2b7a8ceeb6849492b4273814f83e75adf5edd7c1 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 15 Apr 2018 21:44:36 +0300 Subject: ops: Fix PVS/V547: did_change is almost always set Only exception is early `goto theend`. --- src/nvim/ops.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 0483cc3e7a..d67737e845 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -4610,9 +4610,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) } } curwin->w_cursor.col = col; - if (!did_change) { - startpos = curwin->w_cursor; - } + startpos = curwin->w_cursor; did_change = true; (void)del_char(false); ins_char(firstdigit); @@ -4687,9 +4685,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) // Delete the old number. curwin->w_cursor.col = col; - if (!did_change) { - startpos = curwin->w_cursor; - } + startpos = curwin->w_cursor; did_change = true; todel = length; c = gchar_cursor(); @@ -4775,18 +4771,16 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) ins_str(buf1); // insert the new number xfree(buf1); endpos = curwin->w_cursor; - if (did_change && curwin->w_cursor.col) { + if (curwin->w_cursor.col) { curwin->w_cursor.col--; } } - if (did_change) { - // set the '[ and '] marks - curbuf->b_op_start = startpos; - curbuf->b_op_end = endpos; - if (curbuf->b_op_end.col > 0) { - curbuf->b_op_end.col--; - } + // set the '[ and '] marks + curbuf->b_op_start = startpos; + curbuf->b_op_end = endpos; + if (curbuf->b_op_end.col > 0) { + curbuf->b_op_end.col--; } theend: -- cgit