vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 2da512858bec1f4b5b4fe93466c8e6b3604d2485
parent 7ff12acee6fc4d7931d18208dee2a2689c17995b
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sun,  8 Nov 2015 17:10:47 +0100

Fix warnings found by static analyzer

Diffstat:
Mui-curses.c | 4++--
Mui.h | 2+-
Mview.c | 3+--
Mvis.h | 2+-
4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/ui-curses.c b/ui-curses.c @@ -672,7 +672,7 @@ static void ui_window_draw(UiWin *w) { } short selection_bg = win->styles[UI_STYLE_SELECTION].bg; short cursor_line_bg = win->styles[UI_STYLE_CURSOR_LINE].bg; - attr_t attr; + attr_t attr = A_NORMAL; for (const Line *l = view_lines_get(win->view); l; l = l->next) { bool cursor_line = l->lineno == cursor_lineno; for (int x = 0; x < width; x++) { @@ -919,7 +919,7 @@ static UiWin *ui_window_new(Ui *ui, View *view, File *file) { return &win->uiwin; } -static void ui_die(Ui *ui, const char *msg, va_list ap) { +__attribute__((noreturn)) static void ui_die(Ui *ui, const char *msg, va_list ap) { UiCurses *uic = (UiCurses*)ui; endwin(); if (uic->termkey) diff --git a/ui.h b/ui.h @@ -50,7 +50,7 @@ struct Ui { void (*prompt)(Ui*, const char *title, const char *value); char* (*prompt_input)(Ui*); void (*prompt_hide)(Ui*); - void (*die)(Ui*, const char *msg, va_list ap); + void (*die)(Ui*, const char *msg, va_list ap) __attribute__((noreturn)); void (*info)(Ui*, const char *msg, va_list ap); void (*info_hide)(Ui*); void (*arrange)(Ui*, enum UiLayout); diff --git a/view.c b/view.c @@ -599,8 +599,7 @@ bool view_resize(View *view, int width, int height) { } view->width = width; view->height = height; - if (view->lines) - memset(view->lines, 0, view->lines_size); + memset(view->lines, 0, view->lines_size); view_draw(view); return true; } diff --git a/vis.h b/vis.h @@ -104,7 +104,7 @@ int vis_run(Vis*, int argc, char *argv[]); /* terminate editing session, given status will be the return value of vis_run */ void vis_exit(Vis*, int status); /* emergency exit, print given message, perform minimal ui cleanup and exit process */ -void vis_die(Vis*, const char *msg, ...); +void vis_die(Vis*, const char *msg, ...) __attribute__((noreturn)); /* user facing modes are: NORMAL, VISUAL, VISUAL_LINE, PROMPT, INSERT, REPLACE. * the others should be considered as implementation details (TODO: do not expose them?) */