diff options
Diffstat (limited to 'scripts/kwboot.c')
-rw-r--r-- | scripts/kwboot.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/scripts/kwboot.c b/scripts/kwboot.c index 43b8b8cbcd..2a4f6bc5fc 100644 --- a/scripts/kwboot.c +++ b/scripts/kwboot.c @@ -22,6 +22,7 @@ #include <termios.h> #include <sys/mman.h> #include <sys/stat.h> +#include <sys/select.h> /* * Marvell BootROM UART Sensing @@ -147,12 +148,11 @@ kwboot_tty_recv(int fd, void *buf, size_t len, int timeo) FD_ZERO(&rfds); FD_SET(fd, &rfds); - tv.tv_sec = 0; tv.tv_usec = timeo * 1000; - if (tv.tv_usec > 1000000) { - tv.tv_sec += tv.tv_usec / 1000000; - tv.tv_usec %= 1000000; - } + + /* normalize timeval */ + tv.tv_sec = tv.tv_usec / 1000000; + tv.tv_usec %= 1000000; do { nfds = select(fd + 1, &rfds, NULL, NULL, &tv); @@ -504,7 +504,7 @@ kwboot_term_pipe(int in, int out, char *quit, int *s) ssize_t nin, nout; char _buf[128], *buf = _buf; - nin = read(in, buf, sizeof(buf)); + nin = read(in, _buf, sizeof(_buf)); if (nin < 0) return -1; |