From 80e5ccdd44ffb9ab09e130c4a535849febca8126 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 30 Mar 2026 14:50:12 +0800 Subject: [PATCH] refactor(buffer.c): fix coverity warning (#38589) The NULL checks added in #35679 are no longer needed after #38473. _____________________________________________________________________________________________ *** CID 645258: (REVERSE_INULL) /src/nvim/buffer.c: 645 in close_buffer() 639 // Autocommands deleted the buffer. 640 emsg(_(e_auabort)); 641 return false; 642 } 643 buf->b_locked--; 644 buf->b_locked_split--; >>> CID 645258: (REVERSE_INULL) >>> Null-checking "win" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 645 if (abort_if_last && win != NULL && one_window(win, NULL)) { 646 // Autocommands made this the only window. 647 emsg(_(e_auabort)); 648 return false; 649 } 650 } /src/nvim/buffer.c: 626 in close_buffer() 620 // Autocommands deleted the buffer. 621 emsg(_(e_auabort)); 622 return false; 623 } 624 buf->b_locked--; 625 buf->b_locked_split--; >>> CID 645258: (REVERSE_INULL) >>> Null-checking "win" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 626 if (abort_if_last && win != NULL && one_window(win, NULL)) { 627 // Autocommands made this the only window. 628 emsg(_(e_auabort)); 629 return false; 630 } 631 --- src/nvim/buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 53cc7815d3..c22d9356f4 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -623,7 +623,7 @@ bool close_buffer(win_T *win, buf_T *buf, int action, bool abort_if_last, bool i } buf->b_locked--; buf->b_locked_split--; - if (abort_if_last && win != NULL && one_window(win, NULL)) { + if (abort_if_last && one_window(win, NULL)) { // Autocommands made this the only window. emsg(_(e_auabort)); return false; @@ -642,7 +642,7 @@ bool close_buffer(win_T *win, buf_T *buf, int action, bool abort_if_last, bool i } buf->b_locked--; buf->b_locked_split--; - if (abort_if_last && win != NULL && one_window(win, NULL)) { + if (abort_if_last && one_window(win, NULL)) { // Autocommands made this the only window. emsg(_(e_auabort)); return false;