mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 23:38:17 +00:00
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.
This commit is contained in:
@@ -244,6 +244,9 @@ int redraw_asap(int type)
|
|||||||
u8char_T *screenlineUC = NULL; /* copy from ScreenLinesUC[] */
|
u8char_T *screenlineUC = NULL; /* copy from ScreenLinesUC[] */
|
||||||
u8char_T *screenlineC[MAX_MCO]; /* copy from ScreenLinesC[][] */
|
u8char_T *screenlineC[MAX_MCO]; /* copy from ScreenLinesC[][] */
|
||||||
schar_T *screenline2 = NULL; /* copy from ScreenLines2[] */
|
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);
|
redraw_later(type);
|
||||||
if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY))
|
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)));
|
screenline = xmalloc((size_t)(rows * Columns * sizeof(schar_T)));
|
||||||
screenattr = xmalloc((size_t)(rows * Columns * sizeof(sattr_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)));
|
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)));
|
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)));
|
screenline2 = xmalloc((size_t)(rows * Columns * sizeof(schar_T)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,16 +276,16 @@ int redraw_asap(int type)
|
|||||||
memmove(screenattr + r * Columns,
|
memmove(screenattr + r * Columns,
|
||||||
ScreenAttrs + LineOffset[cmdline_row + r],
|
ScreenAttrs + LineOffset[cmdline_row + r],
|
||||||
(size_t)Columns * sizeof(sattr_T));
|
(size_t)Columns * sizeof(sattr_T));
|
||||||
if (enc_utf8) {
|
if (l_enc_utf8) {
|
||||||
memmove(screenlineUC + r * Columns,
|
memmove(screenlineUC + r * Columns,
|
||||||
ScreenLinesUC + LineOffset[cmdline_row + r],
|
ScreenLinesUC + LineOffset[cmdline_row + r],
|
||||||
(size_t)Columns * sizeof(u8char_T));
|
(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,
|
memmove(screenlineC[i] + r * Columns,
|
||||||
ScreenLinesC[r] + LineOffset[cmdline_row + r],
|
ScreenLinesC[r] + LineOffset[cmdline_row + r],
|
||||||
(size_t)Columns * sizeof(u8char_T));
|
(size_t)Columns * sizeof(u8char_T));
|
||||||
}
|
}
|
||||||
if (enc_dbcs == DBCS_JPNU)
|
if (l_enc_dbcs == DBCS_JPNU)
|
||||||
memmove(screenline2 + r * Columns,
|
memmove(screenline2 + r * Columns,
|
||||||
ScreenLines2 + LineOffset[cmdline_row + r],
|
ScreenLines2 + LineOffset[cmdline_row + r],
|
||||||
(size_t)Columns * sizeof(schar_T));
|
(size_t)Columns * sizeof(schar_T));
|
||||||
@@ -302,16 +305,16 @@ int redraw_asap(int type)
|
|||||||
memmove(ScreenAttrs + off,
|
memmove(ScreenAttrs + off,
|
||||||
screenattr + r * Columns,
|
screenattr + r * Columns,
|
||||||
(size_t)Columns * sizeof(sattr_T));
|
(size_t)Columns * sizeof(sattr_T));
|
||||||
if (enc_utf8) {
|
if (l_enc_utf8) {
|
||||||
memmove(ScreenLinesUC + off,
|
memmove(ScreenLinesUC + off,
|
||||||
screenlineUC + r * Columns,
|
screenlineUC + r * Columns,
|
||||||
(size_t)Columns * sizeof(u8char_T));
|
(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,
|
memmove(ScreenLinesC[i] + off,
|
||||||
screenlineC[i] + r * Columns,
|
screenlineC[i] + r * Columns,
|
||||||
(size_t)Columns * sizeof(u8char_T));
|
(size_t)Columns * sizeof(u8char_T));
|
||||||
}
|
}
|
||||||
if (enc_dbcs == DBCS_JPNU)
|
if (l_enc_dbcs == DBCS_JPNU)
|
||||||
memmove(ScreenLines2 + off,
|
memmove(ScreenLines2 + off,
|
||||||
screenline2 + r * Columns,
|
screenline2 + r * Columns,
|
||||||
(size_t)Columns * sizeof(schar_T));
|
(size_t)Columns * sizeof(schar_T));
|
||||||
@@ -322,12 +325,12 @@ int redraw_asap(int type)
|
|||||||
|
|
||||||
free(screenline);
|
free(screenline);
|
||||||
free(screenattr);
|
free(screenattr);
|
||||||
if (enc_utf8) {
|
if (l_enc_utf8) {
|
||||||
free(screenlineUC);
|
free(screenlineUC);
|
||||||
for (i = 0; i < p_mco; ++i)
|
for (i = 0; i < l_p_mco; ++i)
|
||||||
free(screenlineC[i]);
|
free(screenlineC[i]);
|
||||||
}
|
}
|
||||||
if (enc_dbcs == DBCS_JPNU)
|
if (l_enc_dbcs == DBCS_JPNU)
|
||||||
free(screenline2);
|
free(screenline2);
|
||||||
|
|
||||||
/* Show the intro message when appropriate. */
|
/* Show the intro message when appropriate. */
|
||||||
|
Reference in New Issue
Block a user