From bbaa56f7378240fca3db9165dfd02a4504d95ff1 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 2 Jul 2025 21:55:42 +0200 Subject: use pollfd[1] array for poll() argument Signed-off-by: Denys Vlasenko --- libbb/read_key.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'libbb') diff --git a/libbb/read_key.c b/libbb/read_key.c index cf8ed411e..1bea75fcf 100644 --- a/libbb/read_key.c +++ b/libbb/read_key.c @@ -11,7 +11,7 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) { - struct pollfd pfd; + struct pollfd pfd[1]; const char *seq; int n; @@ -112,8 +112,8 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) 0 }; - pfd.fd = fd; - pfd.events = POLLIN; + pfd->fd = fd; + pfd->events = POLLIN; buffer++; /* saved chars counter is in buffer[-1] now */ @@ -135,6 +135,7 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) return -1; } } + /* It is tempting to read more than one byte here, * but it breaks pasting. Example: at shell prompt, * user presses "c","a","t" and then pastes "\nline\n". @@ -173,7 +174,7 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) * so if we block for long it's not really an escape sequence. * Timeout is needed to reconnect escape sequences * split up by transmission over a serial console. */ - if (safe_poll(&pfd, 1, 50) == 0) { + if (safe_poll(pfd, 1, 50) == 0) { /* No more data! * Array is sorted from shortest to longest, * we can't match anything later in array - @@ -222,7 +223,7 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) * n = bytes read. Try to read more until we time out. */ while (n < KEYCODE_BUFFER_SIZE-1) { /* 1 for count byte at buffer[-1] */ - if (safe_poll(&pfd, 1, 50) == 0) { + if (safe_poll(pfd, 1, 50) == 0) { /* No more data! */ break; } -- cgit v1.2.3-55-g6feb