aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/buffer.c7
-rw-r--r--src/nvim/cursor.c3
-rw-r--r--src/nvim/cursor_shape.c7
-rw-r--r--src/nvim/ex_docmd.c1
-rw-r--r--src/nvim/ex_getln.c5
-rw-r--r--src/nvim/fileio.c2
-rw-r--r--src/nvim/if_cscope.c2
-rw-r--r--src/nvim/mouse.c2
-rw-r--r--src/nvim/normal.c1
-rw-r--r--src/nvim/path.c7
-rw-r--r--src/nvim/screen.c5
-rw-r--r--src/nvim/shada.c1
12 files changed, 25 insertions, 18 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 22c8a2bf05..c15a6f1330 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -447,7 +447,8 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last)
return;
}
- if (win_valid_any_tab(win)) {
+ if (win != NULL // Avoid bogus clang warning.
+ && win_valid_any_tab(win)) {
// Set b_last_cursor when closing the last window for the buffer.
// Remember the last cursor position and window options of the buffer.
// This used to be only for the current window, but then options like
@@ -575,7 +576,9 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last)
if (buf == curbuf && !is_curbuf)
return;
- if (win_valid_any_tab(win) && win->w_buffer == buf) {
+ if (win != NULL // Avoid bogus clang warning.
+ && win_valid_any_tab(win)
+ && win->w_buffer == buf) {
win->w_buffer = NULL; // make sure we don't use the buffer now
}
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c
index 409eb653a0..6c1bd01ff5 100644
--- a/src/nvim/cursor.c
+++ b/src/nvim/cursor.c
@@ -394,7 +394,8 @@ void check_cursor_col_win(win_T *win)
// Make sure that coladd is not more than the char width.
// Not for the last character, coladd is then used when the cursor
// is actually after the last character.
- if (win->w_cursor.col + 1 < len && win->w_cursor.coladd > 0) {
+ if (win->w_cursor.col + 1 < len) {
+ assert(win->w_cursor.coladd > 0);
int cs, ce;
getvcol(win, &win->w_cursor, &cs, NULL, &ce);
diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c
index 5551576c6d..0377cb97e5 100644
--- a/src/nvim/cursor_shape.c
+++ b/src/nvim/cursor_shape.c
@@ -88,12 +88,13 @@ char_u *parse_shape_opt(int what)
char_u *colonp;
char_u *commap;
char_u *slashp;
- char_u *p, *endp;
- int idx = 0; /* init for GCC */
+ char_u *p = NULL;
+ char_u *endp;
+ int idx = 0; // init for GCC
int all_idx;
int len;
int i;
- int found_ve = false; /* found "ve" flag */
+ int found_ve = false; // found "ve" flag
int round;
// First round: check for errors; second round: do it for real.
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index ffa913efcf..f5c16d883a 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -10103,6 +10103,7 @@ Dictionary commands_array(buf_T *buf)
{
Dictionary rv = ARRAY_DICT_INIT;
Object obj = NIL;
+ (void)obj; // Avoid "dead assignment" warning.
char str[10];
garray_T *gap = (buf == NULL) ? &ucmds : &buf->b_ucmds;
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 4ea25117d9..8efb027575 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -1808,7 +1808,6 @@ static int command_line_changed(CommandLineState *s)
if (has_event(EVENT_CMDLINECHANGED)) {
TryState tstate;
Error err = ERROR_INIT;
- bool tl_ret = true;
dict_T *dict = get_vim_var_dict(VV_EVENT);
char firstcbuf[2];
@@ -1825,14 +1824,13 @@ static int command_line_changed(CommandLineState *s)
(char_u *)firstcbuf, false, curbuf);
tv_dict_clear(dict);
- tl_ret = try_leave(&tstate, &err);
+ bool tl_ret = try_leave(&tstate, &err);
if (!tl_ret && ERROR_SET(&err)) {
msg_putchar('\n');
msg_printf_attr(HL_ATTR(HLF_E)|MSG_HIST, (char *)e_autocmd_err, err.msg);
api_clear_error(&err);
redrawcmd();
}
- tl_ret = true;
}
// 'incsearch' highlighting.
@@ -5933,6 +5931,7 @@ void ex_history(exarg_T *eap)
for (; !got_int && histype1 <= histype2; ++histype1) {
STRCPY(IObuff, "\n # ");
+ assert(history_names[histype1] != NULL);
STRCAT(STRCAT(IObuff, history_names[histype1]), " history");
MSG_PUTS_TITLE(IObuff);
idx = hisidx[histype1];
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index c631057e81..ba154ea36a 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -760,8 +760,6 @@ readfile (
fenc = (char_u *)"utf-8";
fenc_alloced = false;
-
- c = 1;
} else if (*p_fencs == NUL) {
fenc = curbuf->b_p_fenc; /* use format from buffer */
fenc_alloced = FALSE;
diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c
index ab33cf7863..625d6baa17 100644
--- a/src/nvim/if_cscope.c
+++ b/src/nvim/if_cscope.c
@@ -1371,6 +1371,8 @@ static char *cs_manage_matches(char **matches, char **contexts,
next = 0;
break;
case Print:
+ assert(mp != NULL);
+ assert(cp != NULL);
cs_print_tags_priv(mp, cp, cnt);
break;
default: // should not reach here
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
index bf71e6a479..887cbde921 100644
--- a/src/nvim/mouse.c
+++ b/src/nvim/mouse.c
@@ -641,7 +641,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col)
linenr_T lnum = wp->w_cursor.lnum;
char_u *line = ml_get(lnum);
char_u *ptr = line;
- char_u *ptr_end = line;
+ char_u *ptr_end;
char_u *ptr_row_offset = line; // Where we begin adjusting `ptr_end`
// Find the offset where scanning should begin.
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 32fa502940..0e3946740a 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -3770,6 +3770,7 @@ find_decl (
clearpos(&found_pos);
for (;; ) {
valid = false;
+ (void)valid; // Avoid "dead assignment" warning.
t = searchit(curwin, curbuf, &curwin->w_cursor, FORWARD,
pat, 1L, searchflags, RE_LAST, (linenr_T)0, NULL);
if (curwin->w_cursor.lnum >= old_pos.lnum)
diff --git a/src/nvim/path.c b/src/nvim/path.c
index eeb374cf44..de697642c7 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -2038,12 +2038,11 @@ int expand_wildcards(int num_pat, char_u **pat, int *num_files, char_u ***files,
if (*p_wig) {
char_u *ffname;
- // check all filess in (*files)[]
+ // check all files in (*files)[]
for (i = 0; i < *num_files; i++) {
ffname = (char_u *)FullName_save((char *)(*files)[i], false);
- if (ffname == NULL) { // out of memory
- break;
- }
+ assert((*files)[i] != NULL);
+ assert(ffname != NULL);
if (match_file_list(p_wig, (*files)[i], ffname)) {
// remove this matching file from the list
xfree((*files)[i]);
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index a3f1f00db2..da29522b1b 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -4820,8 +4820,9 @@ static void win_redr_status(win_T *wp, int ignore_pum)
if (wp->w_buffer->b_help
|| wp->w_p_pvw
|| bufIsChanged(wp->w_buffer)
- || wp->w_buffer->b_p_ro)
+ || wp->w_buffer->b_p_ro) {
*(p + len++) = ' ';
+ }
if (wp->w_buffer->b_help) {
STRCPY(p + len, _("[Help]"));
len += (int)STRLEN(p + len);
@@ -4836,7 +4837,7 @@ static void win_redr_status(win_T *wp, int ignore_pum)
}
if (wp->w_buffer->b_p_ro) {
STRCPY(p + len, _("[RO]"));
- len += (int)STRLEN(p + len);
+ // len += (int)STRLEN(p + len); // dead assignment
}
this_ru_col = ru_col - (Columns - wp->w_width);
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 36570e0ded..8864301e4c 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -599,6 +599,7 @@ static inline void hmll_insert(HMLList *const hmll,
if (hmll_entry == hmll->first) {
hmll_entry = NULL;
}
+ assert(hmll->first != NULL);
hmll_remove(hmll, hmll->first);
}
HMLListEntry *target_entry;