mirror of
https://github.com/sheumann/hush.git
synced 2024-12-21 08:29:45 +00:00
*: 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>
This commit is contained in:
parent
8837c5dec4
commit
ea8b252cb3
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
14
shell/ash.c
14
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"
|
||||
);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user