mirror of
https://github.com/sheumann/hush.git
synced 2024-12-23 05:29:58 +00:00
libbb: remove unnecessary argument to nonblock_immune_read
The loop_on_EINTR argument to nonblock_immune_read is always set to 1. function old new delta xmalloc_reads 200 195 -5 pgetc 488 483 -5 argstr 1313 1308 -5 nonblock_immune_read 123 86 -37 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-52) Total: -52 bytes Signed-off-by: Ron Yorston <rmy@tigress.co.uk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
ad795510d9
commit
61d6ae244a
@ -713,7 +713,7 @@ void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) F
|
|||||||
|
|
||||||
|
|
||||||
extern ssize_t safe_read(int fd, void *buf, size_t count) FAST_FUNC;
|
extern ssize_t safe_read(int fd, void *buf, size_t count) FAST_FUNC;
|
||||||
extern ssize_t nonblock_immune_read(int fd, void *buf, size_t count, int loop_on_EINTR) FAST_FUNC;
|
extern ssize_t nonblock_immune_read(int fd, void *buf, size_t count) FAST_FUNC;
|
||||||
// NB: will return short read on error, not -1,
|
// NB: will return short read on error, not -1,
|
||||||
// if some data was read before error occurred
|
// if some data was read before error occurred
|
||||||
extern ssize_t full_read(int fd, void *buf, size_t count) FAST_FUNC;
|
extern ssize_t full_read(int fd, void *buf, size_t count) FAST_FUNC;
|
||||||
|
@ -45,20 +45,20 @@
|
|||||||
* which detects EAGAIN and uses poll() to wait on the fd.
|
* which detects EAGAIN and uses poll() to wait on the fd.
|
||||||
* Thankfully, poll() doesn't care about O_NONBLOCK flag.
|
* Thankfully, poll() doesn't care about O_NONBLOCK flag.
|
||||||
*/
|
*/
|
||||||
ssize_t FAST_FUNC nonblock_immune_read(int fd, void *buf, size_t count, int loop_on_EINTR)
|
ssize_t FAST_FUNC nonblock_immune_read(int fd, void *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct pollfd pfd[1];
|
struct pollfd pfd[1];
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
n = loop_on_EINTR ? safe_read(fd, buf, count) : read(fd, buf, count);
|
n = safe_read(fd, buf, count);
|
||||||
if (n >= 0 || errno != EAGAIN)
|
if (n >= 0 || errno != EAGAIN)
|
||||||
return n;
|
return n;
|
||||||
/* fd is in O_NONBLOCK mode. Wait using poll and repeat */
|
/* fd is in O_NONBLOCK mode. Wait using poll and repeat */
|
||||||
pfd[0].fd = fd;
|
pfd[0].fd = fd;
|
||||||
pfd[0].events = POLLIN;
|
pfd[0].events = POLLIN;
|
||||||
/* note: safe_poll pulls in printf */
|
/* note: safe_poll pulls in printf */
|
||||||
loop_on_EINTR ? safe_poll(pfd, 1, -1) : poll(pfd, 1, -1);
|
safe_poll(pfd, 1, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ char* FAST_FUNC xmalloc_reads(int fd, size_t *maxsz_p)
|
|||||||
p = buf + sz;
|
p = buf + sz;
|
||||||
sz += 128;
|
sz += 128;
|
||||||
}
|
}
|
||||||
if (nonblock_immune_read(fd, p, 1, /*loop_on_EINTR:*/ 1) != 1) {
|
if (nonblock_immune_read(fd, p, 1) != 1) {
|
||||||
/* EOF/error */
|
/* EOF/error */
|
||||||
if (p == buf) { /* we read nothing */
|
if (p == buf) { /* we read nothing */
|
||||||
free(buf);
|
free(buf);
|
||||||
|
@ -5923,7 +5923,7 @@ expbackq(union node *cmd, int quoted, int quotes)
|
|||||||
read:
|
read:
|
||||||
if (in.fd < 0)
|
if (in.fd < 0)
|
||||||
break;
|
break;
|
||||||
i = nonblock_immune_read(in.fd, buf, sizeof(buf), /*loop_on_EINTR:*/ 1);
|
i = nonblock_immune_read(in.fd, buf, sizeof(buf));
|
||||||
TRACE(("expbackq: read returns %d\n", i));
|
TRACE(("expbackq: read returns %d\n", i));
|
||||||
if (i <= 0)
|
if (i <= 0)
|
||||||
break;
|
break;
|
||||||
@ -9696,7 +9696,7 @@ preadfd(void)
|
|||||||
#if ENABLE_FEATURE_EDITING
|
#if ENABLE_FEATURE_EDITING
|
||||||
retry:
|
retry:
|
||||||
if (!iflag || g_parsefile->pf_fd != STDIN_FILENO)
|
if (!iflag || g_parsefile->pf_fd != STDIN_FILENO)
|
||||||
nr = nonblock_immune_read(g_parsefile->pf_fd, buf, IBUFSIZ - 1, /*loop_on_EINTR:*/ 1);
|
nr = nonblock_immune_read(g_parsefile->pf_fd, buf, IBUFSIZ - 1);
|
||||||
else {
|
else {
|
||||||
int timeout = -1;
|
int timeout = -1;
|
||||||
# if ENABLE_ASH_IDLE_TIMEOUT
|
# if ENABLE_ASH_IDLE_TIMEOUT
|
||||||
@ -9738,7 +9738,7 @@ preadfd(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
nr = nonblock_immune_read(g_parsefile->pf_fd, buf, IBUFSIZ - 1, /*loop_on_EINTR:*/ 1);
|
nr = nonblock_immune_read(g_parsefile->pf_fd, buf, IBUFSIZ - 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0 /* disabled: nonblock_immune_read() handles this problem */
|
#if 0 /* disabled: nonblock_immune_read() handles this problem */
|
||||||
|
Loading…
Reference in New Issue
Block a user