fix(ctx): coverity CHECKED_RETURN

CID 649145:         Error handling issues  CHECKED_RETURN
    /src/nvim/api/window.c: 138             in nvim_win_set_cursor()
    132       // Make sure we stick in this column.
    133       w->w_set_curswant = true;
    134
    135       // make sure cursor is in visible range and
    136       // cursorcolumn and cursorline are updated even if w != curwin
    137       CtxSwitch switchwin;
    >>>     CID 649145:         Error handling issues  (CHECKED_RETURN)
    >>>     Calling "ctx_switch" without checking return value (as is done elsewhere 5 out of 6 times).
    138       ctx_switch(&switchwin, w, NULL, NULL, kCtxNoEvents | kCtxNoDisplay);
    139       update_topline(curwin);
    140       validate_cursor(curwin);
    141       ctx_restore(&switchwin);
    142
    143       redraw_later(w, UPD_VALID);
This commit is contained in:
Justin M. Keyes
2026-07-12 14:36:18 +02:00
parent d25ae8b8c2
commit 83ced05984

View File

@@ -135,9 +135,10 @@ void nvim_win_set_cursor(Window win, ArrayOf(Integer, 2) pos, Error *err)
// make sure cursor is in visible range and
// cursorcolumn and cursorline are updated even if w != curwin
CtxSwitch switchwin;
ctx_switch(&switchwin, w, NULL, NULL, kCtxNoEvents | kCtxNoDisplay);
update_topline(curwin);
validate_cursor(curwin);
if (ctx_switch(&switchwin, w, NULL, NULL, kCtxNoEvents | kCtxNoDisplay)) {
update_topline(curwin);
validate_cursor(curwin);
}
ctx_restore(&switchwin);
redraw_later(w, UPD_VALID);