diff options
author | Eliseo Martínez <eliseomarmol@gmail.com> | 2014-11-04 15:41:45 +0100 |
---|---|---|
committer | Eliseo Martínez <eliseomarmol@gmail.com> | 2014-11-06 09:51:44 +0100 |
commit | 9de544c785aa11a9edf380bc8aeaabad75357aa9 (patch) | |
tree | 078fa9b8c4d2e4e58524a1e865314da6c30eb18d | |
parent | 0c135a2ff40d18ef5cfeb5a0233475ab49ae4973 (diff) | |
download | rneovim-9de544c785aa11a9edf380bc8aeaabad75357aa9.tar.gz rneovim-9de544c785aa11a9edf380bc8aeaabad75357aa9.tar.bz2 rneovim-9de544c785aa11a9edf380bc8aeaabad75357aa9.zip |
Fix warnings: ops.c: cursor_pos_info(): Various (2): MI.
Problems: Result of operation is garbage or undefined @ 5087.
http://neovim.org/doc/reports/clang/report-2e3118.html#EndPath
Result of operation is garbage or undefined @ 5149.
Diagnostic: Multithreading issues.
Rationale : All reported problems can only occur if accesed globals
change state while executing function, which could only
happen in a multithreaded environment.
Resolution: Use local variables (copy globals on entry).
Note that this change alters function semantics, as now
function only depends on global values at entry time.
This shouldn't be a problem, though, as new semantics should
be in fact better.
-rw-r--r-- | src/nvim/ops.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index a8b0420fca..e7079e02d0 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -5028,6 +5028,8 @@ void cursor_pos_info(void) pos_T min_pos, max_pos; oparg_T oparg; struct block_def bd; + const int l_VIsual_active = VIsual_active; + const int l_VIsual_mode = VIsual_mode; /* * Compute the length of the file in characters. @@ -5040,7 +5042,7 @@ void cursor_pos_info(void) else eol_size = 1; - if (VIsual_active) { + if (l_VIsual_active) { if (lt(VIsual, curwin->w_cursor)) { min_pos = VIsual; max_pos = curwin->w_cursor; @@ -5051,7 +5053,7 @@ void cursor_pos_info(void) if (*p_sel == 'e' && max_pos.col > 0) --max_pos.col; - if (VIsual_mode == Ctrl_V) { + if (l_VIsual_mode == Ctrl_V) { char_u * saved_sbr = p_sbr; /* Make 'sbr' empty for a moment to get the correct size. */ @@ -5084,12 +5086,12 @@ void cursor_pos_info(void) } /* Do extra processing for VIsual mode. */ - if (VIsual_active + if (l_VIsual_active && lnum >= min_pos.lnum && lnum <= max_pos.lnum) { char_u *s = NULL; long len = 0L; - switch (VIsual_mode) { + switch (l_VIsual_mode) { case Ctrl_V: virtual_op = virtual_active(); block_prep(&oparg, &bd, lnum, 0); @@ -5142,8 +5144,8 @@ void cursor_pos_info(void) if (!curbuf->b_p_eol && curbuf->b_p_bin) byte_count -= eol_size; - if (VIsual_active) { - if (VIsual_mode == Ctrl_V && curwin->w_curswant < MAXCOL) { + if (l_VIsual_active) { + if (l_VIsual_mode == Ctrl_V && curwin->w_curswant < MAXCOL) { getvcols(curwin, &min_pos, &max_pos, &min_pos.col, &max_pos.col); vim_snprintf((char *)buf1, sizeof(buf1), _("%" PRId64 " Cols; "), |