aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-04-21 16:26:30 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-04-21 17:39:11 +0200
commite6a2f4cc5a47d3022bdf5ca2cacbaa5a8c5baf7a (patch)
tree0962142ac9830312cd3df52994db41e8ac47c73c /miscutils
parent5598bdf0d3d46a865a4d23785e2d09e6db9be420 (diff)
downloadbusybox-e6a2f4cc5a47d3022bdf5ca2cacbaa5a8c5baf7a.tar.gz
libbb: make bb_common_bufsiz1 1 kbyte, add capability to use bss tail for it
The config item is FEATURE_USE_BSS_TAIL. When it is off (default): function old new delta read_config 210 228 +18 doCommands 2279 2294 +15 ipneigh_list_or_flush 763 772 +9 ipaddr_list_or_flush 1256 1261 +5 display_process_list 1301 1306 +5 conspy_main 1378 1383 +5 do_lzo_compress 352 355 +3 do_lzo_decompress 565 567 +2 push 46 44 -2 inetd_main 2136 2134 -2 uevent_main 421 418 -3 addLines 97 92 -5 bb_common_bufsiz1 8193 1024 -7169 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 8/5 up/down: 62/-7181) Total: -7119 bytes text data bss dec hex filename 829850 4086 9080 843016 cdd08 busybox_old 829901 4086 1904 835891 cc133 busybox_unstripped FEATURE_USE_BSS_TAIL=y: read_config 210 228 +18 doCommands 2279 2294 +15 ipneigh_list_or_flush 763 772 +9 ipaddr_list_or_flush 1256 1261 +5 display_process_list 1301 1306 +5 conspy_main 1378 1383 +5 do_lzo_compress 352 355 +3 do_lzo_decompress 565 567 +2 inetd_main 2136 2134 -2 bb_common_bufsiz1 8193 - -8193 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 8/1 up/down: 62/-8195) Total: -8133 bytes text data bss dec hex filename 829850 4086 9080 843016 cdd08 busybox_old 829911 4086 880 834877 cbd3d busybox_unstripped FIXME: setup_common_bufsiz() calls are missing. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/chat.c1
-rw-r--r--miscutils/conspy.c6
-rw-r--r--miscutils/crond.c3
-rw-r--r--miscutils/dc.c3
-rw-r--r--miscutils/fbsplash.c6
-rw-r--r--miscutils/hdparm.c3
-rw-r--r--miscutils/i2c_tools.c1
-rw-r--r--miscutils/inotifyd.c6
-rw-r--r--miscutils/less.c6
-rw-r--r--miscutils/microcom.c6
10 files changed, 28 insertions, 13 deletions
diff --git a/miscutils/chat.c b/miscutils/chat.c
index bd2abc24a..25850dd20 100644
--- a/miscutils/chat.c
+++ b/miscutils/chat.c
@@ -17,6 +17,7 @@
//usage: "chat '' ATZ OK ATD123456 CONNECT '' ogin: pppuser word: ppppass '~'"
#include "libbb.h"
+#include "common_bufsiz.h"
// default timeout: 45 sec
#define DEFAULT_CHAT_TIMEOUT 45*1000
diff --git a/miscutils/conspy.c b/miscutils/conspy.c
index 1a46a4340..0d96a5f9a 100644
--- a/miscutils/conspy.c
+++ b/miscutils/conspy.c
@@ -42,6 +42,7 @@
//usage: "\n -y LINE Starting line"
#include "libbb.h"
+#include "common_bufsiz.h"
#include <sys/kd.h>
#define ESC "\033"
@@ -363,7 +364,8 @@ 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 keybuf bb_common_bufsiz1
+#define sizeof_keybuf COMMON_BUFSIZE
struct termios termbuf;
unsigned opts;
unsigned ttynum;
@@ -513,7 +515,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, sizeof_keybuf - G.key_count);
if (bytes_read < 0)
goto abort;
diff --git a/miscutils/crond.c b/miscutils/crond.c
index eb327f855..8536d43c5 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -60,6 +60,7 @@
//usage: "\n -c DIR Cron dir. Default:"CONFIG_FEATURE_CROND_DIR"/crontabs"
#include "libbb.h"
+#include "common_bufsiz.h"
#include <syslog.h>
/* glibc frees previous setenv'ed value when we do next setenv()
@@ -140,7 +141,7 @@ struct globals {
char *env_var_logname;
#endif
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \
G.log_level = 8; \
G.crontab_dir_name = CRONTABS; \
diff --git a/miscutils/dc.c b/miscutils/dc.c
index 9c74172ba..3fbb89f5b 100644
--- a/miscutils/dc.c
+++ b/miscutils/dc.c
@@ -4,6 +4,7 @@
*/
#include "libbb.h"
+#include "common_bufsiz.h"
#include <math.h>
//usage:#define dc_trivial_usage
@@ -47,7 +48,7 @@ struct globals {
double stack[1];
} FIX_ALIASING;
enum { STACK_SIZE = (COMMON_BUFSIZE - offsetof(struct globals, stack)) / sizeof(double) };
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define pointer (G.pointer )
#define base (G.base )
#define stack (G.stack )
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index 9557c41db..b26ad2c15 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -34,6 +34,7 @@
//usage: "\n commands: 'NN' (% for progress bar) or 'exit'"
#include "libbb.h"
+#include "common_bufsiz.h"
#include <linux/fb.h>
/* If you want logging messages on /tmp/fbsplash.log... */
@@ -372,11 +373,12 @@ 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 concat_buf bb_common_bufsiz1
+#define sizeof_concat_buf COMMON_BUFSIZE
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 + sizeof_concat_buf - read_ptr;
if (rem < 2
|| fgets(read_ptr, rem, theme_file) == NULL
) {
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index 8e201ac35..9e141de2f 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -63,6 +63,7 @@
//usage: "\n -z Reread partition table"
#include "libbb.h"
+#include "common_bufsiz.h"
/* must be _after_ libbb.h: */
#include <linux/hdreg.h>
#include <sys/mount.h>
@@ -367,7 +368,7 @@ struct globals {
unsigned char flushcache[4] = { WIN_FLUSHCACHE, 0, 0, 0 };
#endif
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define get_identity (G.get_identity )
#define get_geom (G.get_geom )
#define do_flush (G.do_flush )
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 @@
*/
#include "libbb.h"
+#include "common_bufsiz.h"
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
diff --git a/miscutils/inotifyd.c b/miscutils/inotifyd.c
index 908d657fd..1d28e8f99 100644
--- a/miscutils/inotifyd.c
+++ b/miscutils/inotifyd.c
@@ -56,6 +56,7 @@
//usage: "\nWhen x event happens for all FILEs, inotifyd exits."
#include "libbb.h"
+#include "common_bufsiz.h"
#include <sys/inotify.h>
static const char mask_names[] ALIGN1 =
@@ -162,8 +163,9 @@ int inotifyd_main(int argc, char **argv)
// read out all pending events
// (NB: len must be int, not ssize_t or long!)
xioctl(pfd.fd, FIONREAD, &len);
-#define eventbuf bb_common_bufsiz1
- ie = buf = (len <= sizeof(eventbuf)) ? eventbuf : xmalloc(len);
+#define eventbuf bb_common_bufsiz1
+#define sizeof_eventbuf COMMON_BUFSIZE
+ ie = buf = (len <= sizeof_eventbuf) ? 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 ccdb15fdc..94ecf1686 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -127,6 +127,7 @@
#include <sched.h> /* sched_yield() */
#include "libbb.h"
+#include "common_bufsiz.h"
#if ENABLE_FEATURE_LESS_REGEXP
#include "xregex.h"
#endif
@@ -439,7 +440,8 @@ static int at_end(void)
*/
static void read_lines(void)
{
-#define readbuf bb_common_bufsiz1
+#define readbuf bb_common_bufsiz1
+#define sizeof_readbuf COMMON_BUFSIZE
char *current_line, *p;
int w = width;
char last_terminated = terminated;
@@ -480,7 +482,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, sizeof_readbuf);
if (errno != EAGAIN)
break;
t = time(NULL);
diff --git a/miscutils/microcom.c b/miscutils/microcom.c
index 5e29a1acd..5eb2e6743 100644
--- a/miscutils/microcom.c
+++ b/miscutils/microcom.c
@@ -19,6 +19,7 @@
//usage: "\n -X Disable special meaning of NUL and Ctrl-X from stdin"
#include "libbb.h"
+#include "common_bufsiz.h"
// set raw tty mode
static void xget1(int fd, struct termios *t, struct termios *oldt)
@@ -155,10 +156,11 @@ int microcom_main(int argc UNUSED_PARAM, char **argv)
skip_write: ;
}
if (pfd[0].revents) {
-#define iobuf bb_common_bufsiz1
+#define iobuf bb_common_bufsiz1
+#define sizeof_iobuf COMMON_BUFSIZE
ssize_t len;
// read from device -> write to stdout
- len = safe_read(sfd, iobuf, sizeof(iobuf));
+ len = safe_read(sfd, iobuf, sizeof_iobuf);
if (len > 0)
full_write(STDOUT_FILENO, iobuf, len);
else {