diff options
| author | Eliseo Martínez <eliseomarmol@gmail.com> | 2014-11-04 15:41:37 +0100 | 
|---|---|---|
| committer | Eliseo Martínez <eliseomarmol@gmail.com> | 2014-11-06 09:51:42 +0100 | 
| commit | a32442db8559de722bee39f9614e9041c6f3782b (patch) | |
| tree | ccae3db929e600884cc767d494709d013f8838af /src/nvim/screen.c | |
| parent | b6c1fae6a94d01024d30c24c32e99ec78b4b2517 (diff) | |
| download | rneovim-a32442db8559de722bee39f9614e9041c6f3782b.tar.gz rneovim-a32442db8559de722bee39f9614e9041c6f3782b.tar.bz2 rneovim-a32442db8559de722bee39f9614e9041c6f3782b.zip  | |
Fix warnings: screen.c: redraw_asap(): Various (6): MI.
Problems: Argument with 'nonnull' attribute passed null @ 277.
          http://neovim.org/doc/reports/clang/report-9c3614.html#EndPath
          Result of operation is garbage or undefined @ 281.
          http://neovim.org/doc/reports/clang/report-45efbf.html#EndPath
          Argument with 'nonnull' attribute passed null @ 306.
          http://neovim.org/doc/reports/clang/report-ffb84f.html#EndPath
          Result of operation is garbage or undefined @ 311.
          http://neovim.org/doc/reports/clang/report-d04333.html#EndPath
          Argument with 'nonnull' attribute passed null @ 315.
          http://neovim.org/doc/reports/clang/report-786819.html#EndPath
          Uninitialized argument value @ 328.
          http://neovim.org/doc/reports/clang/report-2a5506.html#EndPath
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.
            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.
Diffstat (limited to 'src/nvim/screen.c')
| -rw-r--r-- | src/nvim/screen.c | 27 | 
1 files changed, 15 insertions, 12 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c index ac726f7988..450ea5e3f1 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -244,6 +244,9 @@ int redraw_asap(int type)    u8char_T    *screenlineUC = NULL;     /* copy from ScreenLinesUC[] */    u8char_T    *screenlineC[MAX_MCO];    /* copy from ScreenLinesC[][] */    schar_T     *screenline2 = NULL;      /* copy from ScreenLines2[] */ +  const bool l_enc_utf8 = enc_utf8; +  const int l_enc_dbcs = enc_dbcs; +  const long l_p_mco = p_mco;    redraw_later(type);    if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY)) @@ -254,14 +257,14 @@ int redraw_asap(int type)    screenline = xmalloc((size_t)(rows * Columns * sizeof(schar_T)));    screenattr = xmalloc((size_t)(rows * Columns * sizeof(sattr_T))); -  if (enc_utf8) { +  if (l_enc_utf8) {      screenlineUC = xmalloc((size_t)(rows * Columns * sizeof(u8char_T))); -    for (i = 0; i < p_mco; ++i) { +    for (i = 0; i < l_p_mco; ++i) {        screenlineC[i] = xmalloc((size_t)(rows * Columns * sizeof(u8char_T)));      }    } -  if (enc_dbcs == DBCS_JPNU) { +  if (l_enc_dbcs == DBCS_JPNU) {      screenline2 = xmalloc((size_t)(rows * Columns * sizeof(schar_T)));    } @@ -273,16 +276,16 @@ int redraw_asap(int type)      memmove(screenattr + r * Columns,          ScreenAttrs + LineOffset[cmdline_row + r],          (size_t)Columns * sizeof(sattr_T)); -    if (enc_utf8) { +    if (l_enc_utf8) {        memmove(screenlineUC + r * Columns,            ScreenLinesUC + LineOffset[cmdline_row + r],            (size_t)Columns * sizeof(u8char_T)); -      for (i = 0; i < p_mco; ++i) +      for (i = 0; i < l_p_mco; ++i)          memmove(screenlineC[i] + r * Columns,              ScreenLinesC[r] + LineOffset[cmdline_row + r],              (size_t)Columns * sizeof(u8char_T));      } -    if (enc_dbcs == DBCS_JPNU) +    if (l_enc_dbcs == DBCS_JPNU)        memmove(screenline2 + r * Columns,            ScreenLines2 + LineOffset[cmdline_row + r],            (size_t)Columns * sizeof(schar_T)); @@ -302,16 +305,16 @@ int redraw_asap(int type)        memmove(ScreenAttrs + off,            screenattr + r * Columns,            (size_t)Columns * sizeof(sattr_T)); -      if (enc_utf8) { +      if (l_enc_utf8) {          memmove(ScreenLinesUC + off,              screenlineUC + r * Columns,              (size_t)Columns * sizeof(u8char_T)); -        for (i = 0; i < p_mco; ++i) +        for (i = 0; i < l_p_mco; ++i)            memmove(ScreenLinesC[i] + off,                screenlineC[i] + r * Columns,                (size_t)Columns * sizeof(u8char_T));        } -      if (enc_dbcs == DBCS_JPNU) +      if (l_enc_dbcs == DBCS_JPNU)          memmove(ScreenLines2 + off,              screenline2 + r * Columns,              (size_t)Columns * sizeof(schar_T)); @@ -322,12 +325,12 @@ int redraw_asap(int type)    free(screenline);    free(screenattr); -  if (enc_utf8) { +  if (l_enc_utf8) {      free(screenlineUC); -    for (i = 0; i < p_mco; ++i) +    for (i = 0; i < l_p_mco; ++i)        free(screenlineC[i]);    } -  if (enc_dbcs == DBCS_JPNU) +  if (l_enc_dbcs == DBCS_JPNU)      free(screenline2);    /* Show the intro message when appropriate. */  | 
