mirror of
https://git.busybox.net/busybox
synced 2026-01-31 16:43:21 +00:00
use pollfd[1] array for poll() argument
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
8c835540ef
commit
bbaa56f737
2 changed files with 8 additions and 7 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ const char* FAST_FUNC
|
|||
shell_builtin_read(struct builtin_read_params *params)
|
||||
{
|
||||
struct pollfd pfd[1];
|
||||
#define fd (pfd[0].fd) /* -u FD */
|
||||
#define fd (pfd->fd) /* -u FD */
|
||||
unsigned err;
|
||||
unsigned end_ms; /* -t TIMEOUT */
|
||||
int nchars; /* -n NUM */
|
||||
|
|
@ -142,7 +142,7 @@ shell_builtin_read(struct builtin_read_params *params)
|
|||
* bash seems to ignore -p PROMPT for this use case.
|
||||
*/
|
||||
int r;
|
||||
pfd[0].events = POLLIN;
|
||||
pfd->events = POLLIN;
|
||||
r = poll(pfd, 1, /*timeout:*/ 0);
|
||||
/* Return 0 only if poll returns 1 ("one fd ready"), else return 1: */
|
||||
return (const char *)(uintptr_t)(r <= 0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue