aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-04-21 18:38:51 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-04-21 18:38:51 +0200
commit9de2e5a22213842da5b116723392de88de9ed419 (patch)
treedff999a566382174e084d377dc3b4c03de1d4c62 /miscutils
parent47cfbf32fd66563f8c4e09ad6cced6abfbe2fad5 (diff)
downloadbusybox-w32-9de2e5a22213842da5b116723392de88de9ed419.tar.gz
busybox-w32-9de2e5a22213842da5b116723392de88de9ed419.tar.bz2
busybox-w32-9de2e5a22213842da5b116723392de88de9ed419.zip
*: 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.c3
-rw-r--r--miscutils/conspy.c7
-rw-r--r--miscutils/fbsplash.c7
-rw-r--r--miscutils/inotifyd.c6
-rw-r--r--miscutils/less.c7
-rw-r--r--miscutils/microcom.c6
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)
286 && poll(&pfd, 1, timeout) > 0 286 && poll(&pfd, 1, timeout) > 0
287 && (pfd.revents & POLLIN) 287 && (pfd.revents & POLLIN)
288 ) { 288 ) {
289#define buf bb_common_bufsiz1
290 llist_t *l; 289 llist_t *l;
291 ssize_t delta; 290 ssize_t delta;
291#define buf bb_common_bufsiz1
292 setup_common_bufsiz();
292 293
293 // read next char from device 294 // read next char from device
294 if (safe_read(STDIN_FILENO, buf+buf_len, 1) > 0) { 295 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;
364int conspy_main(int argc UNUSED_PARAM, char **argv) 364int conspy_main(int argc UNUSED_PARAM, char **argv)
365{ 365{
366 char tty_name[sizeof(DEV_TTY "NN")]; 366 char tty_name[sizeof(DEV_TTY "NN")];
367#define keybuf bb_common_bufsiz1
368#define sizeof_keybuf COMMON_BUFSIZE
369 struct termios termbuf; 367 struct termios termbuf;
370 unsigned opts; 368 unsigned opts;
371 unsigned ttynum; 369 unsigned ttynum;
@@ -384,6 +382,9 @@ int conspy_main(int argc UNUSED_PARAM, char **argv)
384 382
385 applet_long_options = getopt_longopts; 383 applet_long_options = getopt_longopts;
386#endif 384#endif
385#define keybuf bb_common_bufsiz1
386 setup_common_bufsiz();
387
387 INIT_G(); 388 INIT_G();
388 strcpy(G.vcsa_name, DEV_VCSA); 389 strcpy(G.vcsa_name, DEV_VCSA);
389 390
@@ -515,7 +516,7 @@ int conspy_main(int argc UNUSED_PARAM, char **argv)
515 default: 516 default:
516 // Read the keys pressed 517 // Read the keys pressed
517 k = keybuf + G.key_count; 518 k = keybuf + G.key_count;
518 bytes_read = read(G.kbd_fd, k, sizeof_keybuf - G.key_count); 519 bytes_read = read(G.kbd_fd, k, COMMON_BUFSIZE - G.key_count);
519 if (bytes_read < 0) 520 if (bytes_read < 0)
520 goto abort; 521 goto abort;
521 522
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)
373 * - A raster of Width * Height pixels in triplets of rgb 373 * - A raster of Width * Height pixels in triplets of rgb
374 * in pure binary by 1 or 2 bytes. (we support only 1 byte) 374 * in pure binary by 1 or 2 bytes. (we support only 1 byte)
375 */ 375 */
376#define concat_buf bb_common_bufsiz1 376#define concat_buf bb_common_bufsiz1
377#define sizeof_concat_buf COMMON_BUFSIZE 377 setup_common_bufsiz();
378
378 read_ptr = concat_buf; 379 read_ptr = concat_buf;
379 while (1) { 380 while (1) {
380 int w, h, max_color_val; 381 int w, h, max_color_val;
381 int rem = concat_buf + sizeof_concat_buf - read_ptr; 382 int rem = concat_buf + COMMON_BUFSIZE - read_ptr;
382 if (rem < 2 383 if (rem < 2
383 || fgets(read_ptr, rem, theme_file) == NULL 384 || fgets(read_ptr, rem, theme_file) == NULL
384 ) { 385 ) {
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)
162 162
163 // read out all pending events 163 // read out all pending events
164 // (NB: len must be int, not ssize_t or long!) 164 // (NB: len must be int, not ssize_t or long!)
165#define eventbuf bb_common_bufsiz1
166 setup_common_bufsiz();
165 xioctl(pfd.fd, FIONREAD, &len); 167 xioctl(pfd.fd, FIONREAD, &len);
166#define eventbuf bb_common_bufsiz1 168 ie = buf = (len <= COMMON_BUFSIZE) ? eventbuf : xmalloc(len);
167#define sizeof_eventbuf COMMON_BUFSIZE
168 ie = buf = (len <= sizeof_eventbuf) ? eventbuf : xmalloc(len);
169 len = full_read(pfd.fd, buf, len); 169 len = full_read(pfd.fd, buf, len);
170 // process events. N.B. events may vary in length 170 // process events. N.B. events may vary in length
171 while (len > 0) { 171 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)
440 */ 440 */
441static void read_lines(void) 441static void read_lines(void)
442{ 442{
443#define readbuf bb_common_bufsiz1
444#define sizeof_readbuf COMMON_BUFSIZE
445 char *current_line, *p; 443 char *current_line, *p;
446 int w = width; 444 int w = width;
447 char last_terminated = terminated; 445 char last_terminated = terminated;
@@ -451,6 +449,9 @@ static void read_lines(void)
451 unsigned old_max_fline = max_fline; 449 unsigned old_max_fline = max_fline;
452#endif 450#endif
453 451
452#define readbuf bb_common_bufsiz1
453 setup_common_bufsiz();
454
454 /* (careful: max_fline can be -1) */ 455 /* (careful: max_fline can be -1) */
455 if (max_fline + 1 > MAXLINES) 456 if (max_fline + 1 > MAXLINES)
456 return; 457 return;
@@ -482,7 +483,7 @@ static void read_lines(void)
482 time_t t; 483 time_t t;
483 484
484 errno = 0; 485 errno = 0;
485 eof_error = safe_read(STDIN_FILENO, readbuf, sizeof_readbuf); 486 eof_error = safe_read(STDIN_FILENO, readbuf, COMMON_BUFSIZE);
486 if (errno != EAGAIN) 487 if (errno != EAGAIN)
487 break; 488 break;
488 t = time(NULL); 489 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)
156skip_write: ; 156skip_write: ;
157 } 157 }
158 if (pfd[0].revents) { 158 if (pfd[0].revents) {
159#define iobuf bb_common_bufsiz1
160#define sizeof_iobuf COMMON_BUFSIZE
161 ssize_t len; 159 ssize_t len;
160#define iobuf bb_common_bufsiz1
161 setup_common_bufsiz();
162 // read from device -> write to stdout 162 // read from device -> write to stdout
163 len = safe_read(sfd, iobuf, sizeof_iobuf); 163 len = safe_read(sfd, iobuf, COMMON_BUFSIZE);
164 if (len > 0) 164 if (len > 0)
165 full_write(STDOUT_FILENO, iobuf, len); 165 full_write(STDOUT_FILENO, iobuf, len);
166 else { 166 else {