diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2025-07-02 21:55:42 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2025-07-02 21:55:42 +0200 |
| commit | bbaa56f7378240fca3db9165dfd02a4504d95ff1 (patch) | |
| tree | 565e7a149385f5a678d3d69ac2e92959b0f4b8f8 /libbb | |
| parent | 8c835540efb88f46a66ee28c74f031b74ad07b26 (diff) | |
| download | busybox-w32-bbaa56f7378240fca3db9165dfd02a4504d95ff1.tar.gz busybox-w32-bbaa56f7378240fca3db9165dfd02a4504d95ff1.tar.bz2 busybox-w32-bbaa56f7378240fca3db9165dfd02a4504d95ff1.zip | |
use pollfd[1] array for poll() argument
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
| -rw-r--r-- | libbb/read_key.c | 11 |
1 files changed, 6 insertions, 5 deletions
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 @@ | |||
| 11 | 11 | ||
| 12 | int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) | 12 | int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) |
| 13 | { | 13 | { |
| 14 | struct pollfd pfd; | 14 | struct pollfd pfd[1]; |
| 15 | const char *seq; | 15 | const char *seq; |
| 16 | int n; | 16 | int n; |
| 17 | 17 | ||
| @@ -112,8 +112,8 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) | |||
| 112 | 0 | 112 | 0 |
| 113 | }; | 113 | }; |
| 114 | 114 | ||
| 115 | pfd.fd = fd; | 115 | pfd->fd = fd; |
| 116 | pfd.events = POLLIN; | 116 | pfd->events = POLLIN; |
| 117 | 117 | ||
| 118 | buffer++; /* saved chars counter is in buffer[-1] now */ | 118 | buffer++; /* saved chars counter is in buffer[-1] now */ |
| 119 | 119 | ||
| @@ -135,6 +135,7 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) | |||
| 135 | return -1; | 135 | return -1; |
| 136 | } | 136 | } |
| 137 | } | 137 | } |
| 138 | |||
| 138 | /* It is tempting to read more than one byte here, | 139 | /* It is tempting to read more than one byte here, |
| 139 | * but it breaks pasting. Example: at shell prompt, | 140 | * but it breaks pasting. Example: at shell prompt, |
| 140 | * user presses "c","a","t" and then pastes "\nline\n". | 141 | * 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) | |||
| 173 | * so if we block for long it's not really an escape sequence. | 174 | * so if we block for long it's not really an escape sequence. |
| 174 | * Timeout is needed to reconnect escape sequences | 175 | * Timeout is needed to reconnect escape sequences |
| 175 | * split up by transmission over a serial console. */ | 176 | * split up by transmission over a serial console. */ |
| 176 | if (safe_poll(&pfd, 1, 50) == 0) { | 177 | if (safe_poll(pfd, 1, 50) == 0) { |
| 177 | /* No more data! | 178 | /* No more data! |
| 178 | * Array is sorted from shortest to longest, | 179 | * Array is sorted from shortest to longest, |
| 179 | * we can't match anything later in array - | 180 | * we can't match anything later in array - |
| @@ -222,7 +223,7 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) | |||
| 222 | * n = bytes read. Try to read more until we time out. | 223 | * n = bytes read. Try to read more until we time out. |
| 223 | */ | 224 | */ |
| 224 | while (n < KEYCODE_BUFFER_SIZE-1) { /* 1 for count byte at buffer[-1] */ | 225 | while (n < KEYCODE_BUFFER_SIZE-1) { /* 1 for count byte at buffer[-1] */ |
| 225 | if (safe_poll(&pfd, 1, 50) == 0) { | 226 | if (safe_poll(pfd, 1, 50) == 0) { |
| 226 | /* No more data! */ | 227 | /* No more data! */ |
| 227 | break; | 228 | break; |
| 228 | } | 229 | } |
