aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2016-05-16 09:33:03 +0100
committerRon Yorston <rmy@pobox.com>2016-05-16 09:33:03 +0100
commit35d2f5bccb0f3dde600702ebcdb5424d4d50be4a (patch)
tree6e0ff0341c69839e268459a199682628bae734ed /miscutils
parent248a2600a2f4b442101ad568d1994b908bb28d4b (diff)
parentf2559e5c2b7bd2c5fa0dd8e88d0a931da92a23af (diff)
downloadbusybox-w32-35d2f5bccb0f3dde600702ebcdb5424d4d50be4a.tar.gz
busybox-w32-35d2f5bccb0f3dde600702ebcdb5424d4d50be4a.tar.bz2
busybox-w32-35d2f5bccb0f3dde600702ebcdb5424d4d50be4a.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/adjtimex.c6
-rw-r--r--miscutils/chat.c4
-rw-r--r--miscutils/conspy.c7
-rw-r--r--miscutils/crond.c4
-rw-r--r--miscutils/dc.c4
-rw-r--r--miscutils/eject.c2
-rw-r--r--miscutils/fbsplash.c5
-rw-r--r--miscutils/hdparm.c4
-rw-r--r--miscutils/i2c_tools.c1
-rw-r--r--miscutils/inotifyd.c6
-rw-r--r--miscutils/ionice.c2
-rw-r--r--miscutils/less.c7
-rw-r--r--miscutils/microcom.c6
-rw-r--r--miscutils/setserial.c8
14 files changed, 44 insertions, 22 deletions
diff --git a/miscutils/adjtimex.c b/miscutils/adjtimex.c
index 534364a69..058aa9a5c 100644
--- a/miscutils/adjtimex.c
+++ b/miscutils/adjtimex.c
@@ -29,7 +29,7 @@
29# include <sys/timex.h> 29# include <sys/timex.h>
30#endif 30#endif
31 31
32static const uint16_t statlist_bit[] = { 32static const uint16_t statlist_bit[] ALIGN2 = {
33 STA_PLL, 33 STA_PLL,
34 STA_PPSFREQ, 34 STA_PPSFREQ,
35 STA_PPSTIME, 35 STA_PPSTIME,
@@ -45,7 +45,7 @@ static const uint16_t statlist_bit[] = {
45 STA_CLOCKERR, 45 STA_CLOCKERR,
46 0 46 0
47}; 47};
48static const char statlist_name[] = 48static const char statlist_name[] ALIGN1 =
49 "PLL" "\0" 49 "PLL" "\0"
50 "PPSFREQ" "\0" 50 "PPSFREQ" "\0"
51 "PPSTIME" "\0" 51 "PPSTIME" "\0"
@@ -61,7 +61,7 @@ static const char statlist_name[] =
61 "CLOCKERR" 61 "CLOCKERR"
62; 62;
63 63
64static const char ret_code_descript[] = 64static const char ret_code_descript[] ALIGN1 =
65 "clock synchronized" "\0" 65 "clock synchronized" "\0"
66 "insert leap second" "\0" 66 "insert leap second" "\0"
67 "delete leap second" "\0" 67 "delete leap second" "\0"
diff --git a/miscutils/chat.c b/miscutils/chat.c
index bd2abc24a..6b429f2a6 100644
--- a/miscutils/chat.c
+++ b/miscutils/chat.c
@@ -17,6 +17,7 @@
17//usage: "chat '' ATZ OK ATD123456 CONNECT '' ogin: pppuser word: ppppass '~'" 17//usage: "chat '' ATZ OK ATD123456 CONNECT '' ogin: pppuser word: ppppass '~'"
18 18
19#include "libbb.h" 19#include "libbb.h"
20#include "common_bufsiz.h"
20 21
21// default timeout: 45 sec 22// default timeout: 45 sec
22#define DEFAULT_CHAT_TIMEOUT 45*1000 23#define DEFAULT_CHAT_TIMEOUT 45*1000
@@ -285,9 +286,10 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
285 && poll(&pfd, 1, timeout) > 0 286 && poll(&pfd, 1, timeout) > 0
286 && (pfd.revents & POLLIN) 287 && (pfd.revents & POLLIN)
287 ) { 288 ) {
288#define buf bb_common_bufsiz1
289 llist_t *l; 289 llist_t *l;
290 ssize_t delta; 290 ssize_t delta;
291#define buf bb_common_bufsiz1
292 setup_common_bufsiz();
291 293
292 // read next char from device 294 // read next char from device
293 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 1a46a4340..f6468c116 100644
--- a/miscutils/conspy.c
+++ b/miscutils/conspy.c
@@ -42,6 +42,7 @@
42//usage: "\n -y LINE Starting line" 42//usage: "\n -y LINE Starting line"
43 43
44#include "libbb.h" 44#include "libbb.h"
45#include "common_bufsiz.h"
45#include <sys/kd.h> 46#include <sys/kd.h>
46 47
47#define ESC "\033" 48#define ESC "\033"
@@ -363,7 +364,6 @@ int conspy_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
363int conspy_main(int argc UNUSED_PARAM, char **argv) 364int conspy_main(int argc UNUSED_PARAM, char **argv)
364{ 365{
365 char tty_name[sizeof(DEV_TTY "NN")]; 366 char tty_name[sizeof(DEV_TTY "NN")];
366#define keybuf bb_common_bufsiz1
367 struct termios termbuf; 367 struct termios termbuf;
368 unsigned opts; 368 unsigned opts;
369 unsigned ttynum; 369 unsigned ttynum;
@@ -382,6 +382,9 @@ int conspy_main(int argc UNUSED_PARAM, char **argv)
382 382
383 applet_long_options = getopt_longopts; 383 applet_long_options = getopt_longopts;
384#endif 384#endif
385#define keybuf bb_common_bufsiz1
386 setup_common_bufsiz();
387
385 INIT_G(); 388 INIT_G();
386 strcpy(G.vcsa_name, DEV_VCSA); 389 strcpy(G.vcsa_name, DEV_VCSA);
387 390
@@ -513,7 +516,7 @@ int conspy_main(int argc UNUSED_PARAM, char **argv)
513 default: 516 default:
514 // Read the keys pressed 517 // Read the keys pressed
515 k = keybuf + G.key_count; 518 k = keybuf + G.key_count;
516 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);
517 if (bytes_read < 0) 520 if (bytes_read < 0)
518 goto abort; 521 goto abort;
519 522
diff --git a/miscutils/crond.c b/miscutils/crond.c
index eb327f855..f96c96ee7 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -60,6 +60,7 @@
60//usage: "\n -c DIR Cron dir. Default:"CONFIG_FEATURE_CROND_DIR"/crontabs" 60//usage: "\n -c DIR Cron dir. Default:"CONFIG_FEATURE_CROND_DIR"/crontabs"
61 61
62#include "libbb.h" 62#include "libbb.h"
63#include "common_bufsiz.h"
63#include <syslog.h> 64#include <syslog.h>
64 65
65/* glibc frees previous setenv'ed value when we do next setenv() 66/* glibc frees previous setenv'ed value when we do next setenv()
@@ -140,8 +141,9 @@ struct globals {
140 char *env_var_logname; 141 char *env_var_logname;
141#endif 142#endif
142} FIX_ALIASING; 143} FIX_ALIASING;
143#define G (*(struct globals*)&bb_common_bufsiz1) 144#define G (*(struct globals*)bb_common_bufsiz1)
144#define INIT_G() do { \ 145#define INIT_G() do { \
146 setup_common_bufsiz(); \
145 G.log_level = 8; \ 147 G.log_level = 8; \
146 G.crontab_dir_name = CRONTABS; \ 148 G.crontab_dir_name = CRONTABS; \
147} while (0) 149} while (0)
diff --git a/miscutils/dc.c b/miscutils/dc.c
index 9c74172ba..4d92bc3d0 100644
--- a/miscutils/dc.c
+++ b/miscutils/dc.c
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "common_bufsiz.h"
7#include <math.h> 8#include <math.h>
8 9
9//usage:#define dc_trivial_usage 10//usage:#define dc_trivial_usage
@@ -47,11 +48,12 @@ struct globals {
47 double stack[1]; 48 double stack[1];
48} FIX_ALIASING; 49} FIX_ALIASING;
49enum { STACK_SIZE = (COMMON_BUFSIZE - offsetof(struct globals, stack)) / sizeof(double) }; 50enum { STACK_SIZE = (COMMON_BUFSIZE - offsetof(struct globals, stack)) / sizeof(double) };
50#define G (*(struct globals*)&bb_common_bufsiz1) 51#define G (*(struct globals*)bb_common_bufsiz1)
51#define pointer (G.pointer ) 52#define pointer (G.pointer )
52#define base (G.base ) 53#define base (G.base )
53#define stack (G.stack ) 54#define stack (G.stack )
54#define INIT_G() do { \ 55#define INIT_G() do { \
56 setup_common_bufsiz(); \
55 base = 10; \ 57 base = 10; \
56} while (0) 58} while (0)
57 59
diff --git a/miscutils/eject.c b/miscutils/eject.c
index e33d79127..16ae250ff 100644
--- a/miscutils/eject.c
+++ b/miscutils/eject.c
@@ -40,7 +40,7 @@
40#if ENABLE_FEATURE_EJECT_SCSI 40#if ENABLE_FEATURE_EJECT_SCSI
41static void eject_scsi(const char *dev) 41static void eject_scsi(const char *dev)
42{ 42{
43 static const char sg_commands[3][6] = { 43 static const char sg_commands[3][6] ALIGN1 = {
44 { ALLOW_MEDIUM_REMOVAL, 0, 0, 0, 0, 0 }, 44 { ALLOW_MEDIUM_REMOVAL, 0, 0, 0, 0, 0 },
45 { START_STOP, 0, 0, 0, 1, 0 }, 45 { START_STOP, 0, 0, 0, 1, 0 },
46 { START_STOP, 0, 0, 0, 2, 0 } 46 { START_STOP, 0, 0, 0, 2, 0 }
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index 9557c41db..3ddf8a242 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -34,6 +34,7 @@
34//usage: "\n commands: 'NN' (% for progress bar) or 'exit'" 34//usage: "\n commands: 'NN' (% for progress bar) or 'exit'"
35 35
36#include "libbb.h" 36#include "libbb.h"
37#include "common_bufsiz.h"
37#include <linux/fb.h> 38#include <linux/fb.h>
38 39
39/* If you want logging messages on /tmp/fbsplash.log... */ 40/* If you want logging messages on /tmp/fbsplash.log... */
@@ -373,10 +374,12 @@ static void fb_drawimage(void)
373 * 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)
374 */ 375 */
375#define concat_buf bb_common_bufsiz1 376#define concat_buf bb_common_bufsiz1
377 setup_common_bufsiz();
378
376 read_ptr = concat_buf; 379 read_ptr = concat_buf;
377 while (1) { 380 while (1) {
378 int w, h, max_color_val; 381 int w, h, max_color_val;
379 int rem = concat_buf + sizeof(concat_buf) - read_ptr; 382 int rem = concat_buf + COMMON_BUFSIZE - read_ptr;
380 if (rem < 2 383 if (rem < 2
381 || fgets(read_ptr, rem, theme_file) == NULL 384 || fgets(read_ptr, rem, theme_file) == NULL
382 ) { 385 ) {
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index 8e201ac35..b4c5876d4 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -63,6 +63,7 @@
63//usage: "\n -z Reread partition table" 63//usage: "\n -z Reread partition table"
64 64
65#include "libbb.h" 65#include "libbb.h"
66#include "common_bufsiz.h"
66/* must be _after_ libbb.h: */ 67/* must be _after_ libbb.h: */
67#include <linux/hdreg.h> 68#include <linux/hdreg.h>
68#include <sys/mount.h> 69#include <sys/mount.h>
@@ -367,7 +368,7 @@ struct globals {
367 unsigned char flushcache[4] = { WIN_FLUSHCACHE, 0, 0, 0 }; 368 unsigned char flushcache[4] = { WIN_FLUSHCACHE, 0, 0, 0 };
368#endif 369#endif
369} FIX_ALIASING; 370} FIX_ALIASING;
370#define G (*(struct globals*)&bb_common_bufsiz1) 371#define G (*(struct globals*)bb_common_bufsiz1)
371#define get_identity (G.get_identity ) 372#define get_identity (G.get_identity )
372#define get_geom (G.get_geom ) 373#define get_geom (G.get_geom )
373#define do_flush (G.do_flush ) 374#define do_flush (G.do_flush )
@@ -431,6 +432,7 @@ struct globals {
431#define hwif_ctrl (G.hwif_ctrl ) 432#define hwif_ctrl (G.hwif_ctrl )
432#define hwif_irq (G.hwif_irq ) 433#define hwif_irq (G.hwif_irq )
433#define INIT_G() do { \ 434#define INIT_G() do { \
435 setup_common_bufsiz(); \
434 BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ 436 BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
435} while (0) 437} while (0)
436 438
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
index aa1c7c5cc..57bb72ae7 100644
--- a/miscutils/i2c_tools.c
+++ b/miscutils/i2c_tools.c
@@ -60,6 +60,7 @@
60 */ 60 */
61 61
62#include "libbb.h" 62#include "libbb.h"
63#include "common_bufsiz.h"
63 64
64#include <linux/i2c.h> 65#include <linux/i2c.h>
65#include <linux/i2c-dev.h> 66#include <linux/i2c-dev.h>
diff --git a/miscutils/inotifyd.c b/miscutils/inotifyd.c
index 908d657fd..52db08ada 100644
--- a/miscutils/inotifyd.c
+++ b/miscutils/inotifyd.c
@@ -56,6 +56,7 @@
56//usage: "\nWhen x event happens for all FILEs, inotifyd exits." 56//usage: "\nWhen x event happens for all FILEs, inotifyd exits."
57 57
58#include "libbb.h" 58#include "libbb.h"
59#include "common_bufsiz.h"
59#include <sys/inotify.h> 60#include <sys/inotify.h>
60 61
61static const char mask_names[] ALIGN1 = 62static const char mask_names[] ALIGN1 =
@@ -161,9 +162,10 @@ int inotifyd_main(int argc, char **argv)
161 162
162 // read out all pending events 163 // read out all pending events
163 // (NB: len must be int, not ssize_t or long!) 164 // (NB: len must be int, not ssize_t or long!)
164 xioctl(pfd.fd, FIONREAD, &len);
165#define eventbuf bb_common_bufsiz1 165#define eventbuf bb_common_bufsiz1
166 ie = buf = (len <= sizeof(eventbuf)) ? eventbuf : xmalloc(len); 166 setup_common_bufsiz();
167 xioctl(pfd.fd, FIONREAD, &len);
168 ie = buf = (len <= COMMON_BUFSIZE) ? eventbuf : xmalloc(len);
167 len = full_read(pfd.fd, buf, len); 169 len = full_read(pfd.fd, buf, len);
168 // process events. N.B. events may vary in length 170 // process events. N.B. events may vary in length
169 while (len > 0) { 171 while (len > 0) {
diff --git a/miscutils/ionice.c b/miscutils/ionice.c
index bd300605f..0c14256ab 100644
--- a/miscutils/ionice.c
+++ b/miscutils/ionice.c
@@ -41,7 +41,7 @@ enum {
41 IOPRIO_CLASS_IDLE 41 IOPRIO_CLASS_IDLE
42}; 42};
43 43
44static const char to_prio[] = "none\0realtime\0best-effort\0idle"; 44static const char to_prio[] ALIGN1 = "none\0realtime\0best-effort\0idle";
45 45
46#define IOPRIO_CLASS_SHIFT 13 46#define IOPRIO_CLASS_SHIFT 13
47 47
diff --git a/miscutils/less.c b/miscutils/less.c
index cc0e20bc7..248f3e3f5 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -131,6 +131,7 @@
131#endif 131#endif
132 132
133#include "libbb.h" 133#include "libbb.h"
134#include "common_bufsiz.h"
134#if ENABLE_FEATURE_LESS_REGEXP 135#if ENABLE_FEATURE_LESS_REGEXP
135#include "xregex.h" 136#include "xregex.h"
136#endif 137#endif
@@ -445,7 +446,6 @@ static int at_end(void)
445 */ 446 */
446static void read_lines(void) 447static void read_lines(void)
447{ 448{
448#define readbuf bb_common_bufsiz1
449 char *current_line, *p; 449 char *current_line, *p;
450 int w = width; 450 int w = width;
451 char last_terminated = terminated; 451 char last_terminated = terminated;
@@ -455,6 +455,9 @@ static void read_lines(void)
455 unsigned old_max_fline = max_fline; 455 unsigned old_max_fline = max_fline;
456#endif 456#endif
457 457
458#define readbuf bb_common_bufsiz1
459 setup_common_bufsiz();
460
458 /* (careful: max_fline can be -1) */ 461 /* (careful: max_fline can be -1) */
459 if (max_fline + 1 > MAXLINES) 462 if (max_fline + 1 > MAXLINES)
460 return; 463 return;
@@ -486,7 +489,7 @@ static void read_lines(void)
486 time_t t; 489 time_t t;
487 490
488 errno = 0; 491 errno = 0;
489 eof_error = safe_read(STDIN_FILENO, readbuf, sizeof(readbuf)); 492 eof_error = safe_read(STDIN_FILENO, readbuf, COMMON_BUFSIZE);
490 if (errno != EAGAIN) 493 if (errno != EAGAIN)
491 break; 494 break;
492 t = time(NULL); 495 t = time(NULL);
diff --git a/miscutils/microcom.c b/miscutils/microcom.c
index 5e29a1acd..d9e8f9187 100644
--- a/miscutils/microcom.c
+++ b/miscutils/microcom.c
@@ -19,6 +19,7 @@
19//usage: "\n -X Disable special meaning of NUL and Ctrl-X from stdin" 19//usage: "\n -X Disable special meaning of NUL and Ctrl-X from stdin"
20 20
21#include "libbb.h" 21#include "libbb.h"
22#include "common_bufsiz.h"
22 23
23// set raw tty mode 24// set raw tty mode
24static void xget1(int fd, struct termios *t, struct termios *oldt) 25static void xget1(int fd, struct termios *t, struct termios *oldt)
@@ -155,10 +156,11 @@ int microcom_main(int argc UNUSED_PARAM, char **argv)
155skip_write: ; 156skip_write: ;
156 } 157 }
157 if (pfd[0].revents) { 158 if (pfd[0].revents) {
158#define iobuf bb_common_bufsiz1
159 ssize_t len; 159 ssize_t len;
160#define iobuf bb_common_bufsiz1
161 setup_common_bufsiz();
160 // read from device -> write to stdout 162 // read from device -> write to stdout
161 len = safe_read(sfd, iobuf, sizeof(iobuf)); 163 len = safe_read(sfd, iobuf, COMMON_BUFSIZE);
162 if (len > 0) 164 if (len > 0)
163 full_write(STDOUT_FILENO, iobuf, len); 165 full_write(STDOUT_FILENO, iobuf, len);
164 else { 166 else {
diff --git a/miscutils/setserial.c b/miscutils/setserial.c
index dfed3306e..8b5c4a9c7 100644
--- a/miscutils/setserial.c
+++ b/miscutils/setserial.c
@@ -257,7 +257,7 @@ enum print_mode
257#define CTL_CLOSE (1 << 3) 257#define CTL_CLOSE (1 << 3)
258#define CTL_NODIE (1 << 4) 258#define CTL_NODIE (1 << 4)
259 259
260static const char serial_types[] = 260static const char serial_types[] ALIGN1 =
261 "unknown\0" /* 0 */ 261 "unknown\0" /* 0 */
262 "8250\0" /* 1 */ 262 "8250\0" /* 1 */
263 "16450\0" /* 2 */ 263 "16450\0" /* 2 */
@@ -288,7 +288,7 @@ static const char serial_types[] =
288# define MAX_SERIAL_TYPE 13 288# define MAX_SERIAL_TYPE 13
289#endif 289#endif
290 290
291static const char commands[] = 291static const char commands[] ALIGN1 =
292 "spd_normal\0" 292 "spd_normal\0"
293 "spd_hi\0" 293 "spd_hi\0"
294 "spd_vhi\0" 294 "spd_vhi\0"
@@ -404,8 +404,8 @@ static const uint16_t setbits[CMD_FLAG_LAST + 1] =
404 ASYNC_LOW_LATENCY 404 ASYNC_LOW_LATENCY
405}; 405};
406 406
407static const char STR_INFINITE[] = "infinite"; 407#define STR_INFINITE "infinite"
408static const char STR_NONE[] = "none"; 408#define STR_NONE "none"
409 409
410static const char *uart_type(int type) 410static const char *uart_type(int type)
411{ 411{