summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2010-06-02 12:57:26 +0200
committerDenys Vlasenko2010-06-02 12:57:26 +0200
commitea8b252cb30c4b4463df43a5342af95931920f09 (patch)
treeb32f4cfd202c9b98cbb2a59bb5a629275e1b4119
parent8837c5dec402fd6782589c0a676bc7f90dea4061 (diff)
downloadbusybox-ea8b252cb30c4b4463df43a5342af95931920f09.zip
busybox-ea8b252cb30c4b4463df43a5342af95931920f09.tar.gz
*: better string sharing
text data bss dec hex filename 849427 441 7556 857424 d1550 busybox_old 849355 441 7556 857352 d1508 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--archival/bzip2.c4
-rw-r--r--archival/libunarchive/decompress_unxz.c2
-rw-r--r--archival/libunarchive/decompress_unzip.c2
-rw-r--r--coreutils/head.c2
-rw-r--r--coreutils/od_bloaty.c2
-rw-r--r--coreutils/tail.c8
-rw-r--r--miscutils/less.c2
-rw-r--r--modutils/modutils-24.c6
-rw-r--r--shell/ash.c14
-rw-r--r--util-linux/fdisk.c6
10 files changed, 22 insertions, 26 deletions
diff --git a/archival/bzip2.c b/archival/bzip2.c
index f1c84d6..fdb8b93 100644
--- a/archival/bzip2.c
+++ b/archival/bzip2.c
@@ -88,7 +88,7 @@ IF_DESKTOP(long long) int bz_write(bz_stream *strm, void* rbuf, ssize_t rlen, vo
if (n2 != n) {
if (n2 >= 0)
errno = 0; /* prevent bogus error message */
- bb_perror_msg(n2 >= 0 ? "short write" : "write error");
+ bb_perror_msg(n2 >= 0 ? "short write" : bb_msg_write_error);
return -1;
}
}
@@ -118,7 +118,7 @@ IF_DESKTOP(long long) int FAST_FUNC compressStream(unpack_info_t *info UNUSED_PA
while (1) {
count = full_read(STDIN_FILENO, rbuf, IOBUF_SIZE);
if (count < 0) {
- bb_perror_msg("read error");
+ bb_perror_msg(bb_msg_read_error);
total = -1;
break;
}
diff --git a/archival/libunarchive/decompress_unxz.c b/archival/libunarchive/decompress_unxz.c
index 3f93929..1302e29 100644
--- a/archival/libunarchive/decompress_unxz.c
+++ b/archival/libunarchive/decompress_unxz.c
@@ -86,7 +86,7 @@ unpack_xz_stream(int src_fd, int dst_fd)
if (rd) {
rd = safe_read(src_fd, membuf + insz, rd);
if (rd < 0) {
- bb_error_msg("read error");
+ bb_error_msg(bb_msg_read_error);
total = -1;
break;
}
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c
index 33e877e..bccd026 100644
--- a/archival/libunarchive/decompress_unzip.c
+++ b/archival/libunarchive/decompress_unzip.c
@@ -1072,7 +1072,7 @@ static int top_up(STATE_PARAM unsigned n)
bytebuffer_offset = 0;
bytebuffer_size = full_read(gunzip_src_fd, &bytebuffer[count], bytebuffer_max - count);
if ((int)bytebuffer_size < 0) {
- bb_error_msg("read error");
+ bb_error_msg(bb_msg_read_error);
return 0;
}
bytebuffer_size += count;
diff --git a/coreutils/head.c b/coreutils/head.c
index 75189ed..cc28374 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -27,7 +27,7 @@ static const struct suffix_mult head_suffixes[] = {
{ "", 0 }
};
-static const char header_fmt_str[] ALIGN1 = "\n==> %s <==\n";
+#define header_fmt_str "\n==> %s <==\n"
int head_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int head_main(int argc, char **argv)
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index 6aba0f6..a9a45c8 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -502,7 +502,7 @@ check_and_close(void)
}
if (ferror(stdout)) {
- bb_error_msg("write error");
+ bb_error_msg(bb_msg_write_error);
ioerror = 1;
}
}
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 8fc22f5..6397702 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -66,7 +66,7 @@ static ssize_t tail_read(int fd, char *buf, size_t count)
return r;
}
-static const char header_fmt[] ALIGN1 = "\n==> %s <==\n";
+#define header_fmt_str "\n==> %s <==\n"
static unsigned eat_num(const char *p)
{
@@ -166,7 +166,7 @@ int tail_main(int argc, char **argv)
tailbuf = xmalloc(tailbufsize);
/* tail the files */
- fmt = header_fmt + 1; /* skip header leading newline on first output */
+ fmt = header_fmt_str + 1; /* skip header leading newline on first output */
i = 0;
do {
char *buf;
@@ -181,7 +181,7 @@ int tail_main(int argc, char **argv)
if (nfiles > header_threshhold) {
tail_xprint_header(fmt, argv[i]);
- fmt = header_fmt;
+ fmt = header_fmt_str;
}
if (!from_top) {
@@ -333,7 +333,7 @@ int tail_main(int argc, char **argv)
if (ENABLE_FEATURE_FANCY_TAIL && fd < 0)
continue;
if (nfiles > header_threshhold) {
- fmt = header_fmt;
+ fmt = header_fmt_str;
}
while ((nread = tail_read(fd, tailbuf, BUFSIZ)) > 0) {
if (fmt) {
diff --git a/miscutils/less.c b/miscutils/less.c
index 8482662..da2cd07 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -430,7 +430,7 @@ static void read_lines(void)
* immediately */
eof_error = 1;
} else {
- print_statusline("read error");
+ print_statusline(bb_msg_read_error);
}
}
#if !ENABLE_FEATURE_LESS_REGEXP
diff --git a/modutils/modutils-24.c b/modutils/modutils-24.c
index 5c1611c..7f39e25 100644
--- a/modutils/modutils-24.c
+++ b/modutils/modutils-24.c
@@ -3529,20 +3529,18 @@ static void set_tainted(int fd, const char *m_name,
/* Check if loading this module will taint the kernel. */
static void check_tainted_module(struct obj_file *f, const char *m_name)
{
- static const char tainted_file[] ALIGN1 = TAINT_FILENAME;
-
int fd, kernel_has_tainted;
const char *ptr;
kernel_has_tainted = 1;
- fd = open(tainted_file, O_RDWR);
+ fd = open(TAINT_FILENAME, O_RDWR);
if (fd < 0) {
if (errno == ENOENT)
kernel_has_tainted = 0;
else if (errno == EACCES)
kernel_has_tainted = 1;
else {
- perror(tainted_file);
+ perror(TAINT_FILENAME);
kernel_has_tainted = 0;
}
}
diff --git a/shell/ash.c b/shell/ash.c
index d77d9d3..08ad0f4 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -119,9 +119,7 @@ enum { NOPTS = ARRAY_SIZE(optletters_optnames) };
/* ============ Misc data */
-static const char homestr[] ALIGN1 = "HOME";
-static const char snlfmt[] ALIGN1 = "%s\n";
-static const char msg_illnum[] ALIGN1 = "Illegal number: %s";
+#define msg_illnum "Illegal number: %s"
/*
* We enclose jmp_buf in a structure so that we can declare pointers to
@@ -2520,7 +2518,7 @@ cdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
flags = cdopt();
dest = *argptr;
if (!dest)
- dest = bltinlookup(homestr);
+ dest = bltinlookup("HOME");
else if (LONE_DASH(dest)) {
dest = bltinlookup("OLDPWD");
flags |= CD_PRINT;
@@ -2567,7 +2565,7 @@ cdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
/* NOTREACHED */
out:
if (flags & CD_PRINT)
- out1fmt(snlfmt, curdir);
+ out1fmt("%s\n", curdir);
return 0;
}
@@ -2583,7 +2581,7 @@ pwdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
setpwd(dir, 0);
dir = physdir;
}
- out1fmt(snlfmt, dir);
+ out1fmt("%s\n", dir);
return 0;
}
@@ -5625,7 +5623,7 @@ exptilde(char *startp, char *p, int flags)
done:
*p = '\0';
if (*name == '\0') {
- home = lookupvar(homestr);
+ home = lookupvar("HOME");
} else {
pw = getpwnam(name);
if (pw == NULL)
@@ -9857,7 +9855,7 @@ chkmail(void)
}
if (!mail_var_path_changed && statb.st_mtime != *mtp) {
fprintf(
- stderr, snlfmt,
+ stderr, "%s\n",
pathopt ? pathopt : "you have mail"
);
}
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index 8e13317..7227a82 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -107,9 +107,9 @@ struct partition {
unsigned char size4[4]; /* nr of sectors in partition */
} PACKED;
-static const char unable_to_open[] ALIGN1 = "can't open '%s'";
-static const char unable_to_read[] ALIGN1 = "can't read from %s";
-static const char unable_to_seek[] ALIGN1 = "can't seek on %s";
+#define unable_to_open "can't open '%s'"
+#define unable_to_read "can't read from %s"
+#define unable_to_seek "can't seek on %s"
enum label_type {
LABEL_DOS, LABEL_SUN, LABEL_SGI, LABEL_AIX, LABEL_OSF