diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-04-21 19:38:51 +0300 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-04-21 19:38:51 +0300 |
commit | 9de2e5a22213842da5b116723392de88de9ed419 (patch) | |
tree | dff999a566382174e084d377dc3b4c03de1d4c62 /miscutils | |
parent | 47cfbf32fd66563f8c4e09ad6cced6abfbe2fad5 (diff) |
*: hopefully all setup_common_bufsiz() are in place
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/chat.c | 3 | ||||
-rw-r--r-- | miscutils/conspy.c | 7 | ||||
-rw-r--r-- | miscutils/fbsplash.c | 7 | ||||
-rw-r--r-- | miscutils/inotifyd.c | 6 | ||||
-rw-r--r-- | miscutils/less.c | 7 | ||||
-rw-r--r-- | miscutils/microcom.c | 6 |
6 files changed, 20 insertions, 16 deletions
diff --git a/miscutils/chat.c b/miscutils/chat.c index 25850dd20..6b429f2a6 100644 --- a/miscutils/chat.c +++ b/miscutils/chat.c @@ -286,9 +286,10 @@ int chat_main(int argc UNUSED_PARAM, char **argv) && poll(&pfd, 1, timeout) > 0 && (pfd.revents & POLLIN) ) { -#define buf bb_common_bufsiz1 llist_t *l; ssize_t delta; +#define buf bb_common_bufsiz1 + setup_common_bufsiz(); // read next char from device if (safe_read(STDIN_FILENO, buf+buf_len, 1) > 0) { diff --git a/miscutils/conspy.c b/miscutils/conspy.c index 0d96a5f9a..f6468c116 100644 --- a/miscutils/conspy.c +++ b/miscutils/conspy.c @@ -364,8 +364,6 @@ int conspy_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int conspy_main(int argc UNUSED_PARAM, char **argv) { char tty_name[sizeof(DEV_TTY "NN")]; -#define keybuf bb_common_bufsiz1 -#define sizeof_keybuf COMMON_BUFSIZE struct termios termbuf; unsigned opts; unsigned ttynum; @@ -384,6 +382,9 @@ int conspy_main(int argc UNUSED_PARAM, char **argv) applet_long_options = getopt_longopts; #endif +#define keybuf bb_common_bufsiz1 + setup_common_bufsiz(); + INIT_G(); strcpy(G.vcsa_name, DEV_VCSA); @@ -515,7 +516,7 @@ int conspy_main(int argc UNUSED_PARAM, char **argv) default: // Read the keys pressed k = keybuf + G.key_count; - bytes_read = read(G.kbd_fd, k, sizeof_keybuf - G.key_count); + bytes_read = read(G.kbd_fd, k, COMMON_BUFSIZE - G.key_count); if (bytes_read < 0) goto abort; diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c index b26ad2c15..3ddf8a242 100644 --- a/miscutils/fbsplash.c +++ b/miscutils/fbsplash.c @@ -373,12 +373,13 @@ static void fb_drawimage(void) * - A raster of Width * Height pixels in triplets of rgb * in pure binary by 1 or 2 bytes. (we support only 1 byte) */ -#define concat_buf bb_common_bufsiz1 -#define sizeof_concat_buf COMMON_BUFSIZE +#define concat_buf bb_common_bufsiz1 + setup_common_bufsiz(); + read_ptr = concat_buf; while (1) { int w, h, max_color_val; - int rem = concat_buf + sizeof_concat_buf - read_ptr; + int rem = concat_buf + COMMON_BUFSIZE - read_ptr; if (rem < 2 || fgets(read_ptr, rem, theme_file) == NULL ) { diff --git a/miscutils/inotifyd.c b/miscutils/inotifyd.c index 1d28e8f99..52db08ada 100644 --- a/miscutils/inotifyd.c +++ b/miscutils/inotifyd.c @@ -162,10 +162,10 @@ int inotifyd_main(int argc, char **argv) // read out all pending events // (NB: len must be int, not ssize_t or long!) +#define eventbuf bb_common_bufsiz1 + setup_common_bufsiz(); xioctl(pfd.fd, FIONREAD, &len); -#define eventbuf bb_common_bufsiz1 -#define sizeof_eventbuf COMMON_BUFSIZE - ie = buf = (len <= sizeof_eventbuf) ? eventbuf : xmalloc(len); + ie = buf = (len <= COMMON_BUFSIZE) ? eventbuf : xmalloc(len); len = full_read(pfd.fd, buf, len); // process events. N.B. events may vary in length while (len > 0) { diff --git a/miscutils/less.c b/miscutils/less.c index 94ecf1686..d7076dbbc 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -440,8 +440,6 @@ static int at_end(void) */ static void read_lines(void) { -#define readbuf bb_common_bufsiz1 -#define sizeof_readbuf COMMON_BUFSIZE char *current_line, *p; int w = width; char last_terminated = terminated; @@ -451,6 +449,9 @@ static void read_lines(void) unsigned old_max_fline = max_fline; #endif +#define readbuf bb_common_bufsiz1 + setup_common_bufsiz(); + /* (careful: max_fline can be -1) */ if (max_fline + 1 > MAXLINES) return; @@ -482,7 +483,7 @@ static void read_lines(void) time_t t; errno = 0; - eof_error = safe_read(STDIN_FILENO, readbuf, sizeof_readbuf); + eof_error = safe_read(STDIN_FILENO, readbuf, COMMON_BUFSIZE); if (errno != EAGAIN) break; t = time(NULL); diff --git a/miscutils/microcom.c b/miscutils/microcom.c index 5eb2e6743..d9e8f9187 100644 --- a/miscutils/microcom.c +++ b/miscutils/microcom.c @@ -156,11 +156,11 @@ int microcom_main(int argc UNUSED_PARAM, char **argv) skip_write: ; } if (pfd[0].revents) { -#define iobuf bb_common_bufsiz1 -#define sizeof_iobuf COMMON_BUFSIZE ssize_t len; +#define iobuf bb_common_bufsiz1 + setup_common_bufsiz(); // read from device -> write to stdout - len = safe_read(sfd, iobuf, sizeof_iobuf); + len = safe_read(sfd, iobuf, COMMON_BUFSIZE); if (len > 0) full_write(STDOUT_FILENO, iobuf, len); else { |