From deac7df80a1491ae65b68a1a1047902bcd775adc Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 12 Sep 2024 09:16:57 -0700 Subject: [PATCH] refactor(stream.c): unused params in stream_close #30356 --- src/nvim/event/stream.c | 16 ++++++---------- src/nvim/os/shell.c | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c index bc1b503f4c..d9c44e06be 100644 --- a/src/nvim/event/stream.c +++ b/src/nvim/event/stream.c @@ -94,14 +94,17 @@ void stream_init(Loop *loop, Stream *stream, int fd, uv_stream_t *uvstream) stream->events = NULL; } -void stream_close(Stream *stream, stream_close_cb on_stream_close, void *data, bool rstream) +void stream_may_close(Stream *stream, bool rstream) FUNC_ATTR_NONNULL_ARG(1) { + if (stream->closed) { + return; + } assert(!stream->closed); DLOG("closing Stream: %p", (void *)stream); stream->closed = true; - stream->close_cb = on_stream_close; - stream->close_cb_data = data; + stream->close_cb = NULL; + stream->close_cb_data = NULL; #ifdef MSWIN if (UV_TTY == uv_guess_handle(stream->fd)) { @@ -115,13 +118,6 @@ void stream_close(Stream *stream, stream_close_cb on_stream_close, void *data, b } } -void stream_may_close(Stream *stream, bool rstream) -{ - if (!stream->closed) { - stream_close(stream, NULL, NULL, rstream); - } -} - void stream_close_handle(Stream *stream, bool rstream) FUNC_ATTR_NONNULL_ALL { diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 4b34ed1c4e..0b082c164d 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -1292,7 +1292,7 @@ static void shell_write_cb(Stream *stream, void *data, int status) msg_schedule_semsg(_("E5677: Error writing input to shell-command: %s"), uv_err_name(status)); } - stream_close(stream, NULL, NULL, false); + stream_may_close(stream, false); } /// Applies 'shellxescape' (p_sxe) and 'shellxquote' (p_sxq) to a command.