aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorGravatar James Byrne <james.byrne@origamienergy.com>2019-07-02 11:35:03 +0200
committerGravatar Denys Vlasenko <vda.linux@googlemail.com>2019-07-02 11:35:03 +0200
commit6937487be73cd4563b876413277a295a5fe2f32c (patch)
treef16cc9999a7c827891e6ec8d99c699fc791008ee /util-linux
parentcaecfdc20d450686cd1f7e9b5f650322f894b3c2 (diff)
downloadbusybox-6937487be73cd4563b876413277a295a5fe2f32c.tar.gz
busybox-6937487be73cd4563b876413277a295a5fe2f32c.tar.bz2
libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower overhead call to bb_perror_msg() when only a string was being printed with no parameters. This saves space for some CPU architectures because it avoids the overhead of a call to a variadic function. However there has never been a simple version of bb_error_msg(), and since 2007 many new calls to bb_perror_msg() have been added that only take a single parameter and so could have been using bb_simple_perror_message(). This changeset introduces 'simple' versions of bb_info_msg(), bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and bb_herror_msg_and_die(), and replaces all calls that only take a single parameter, or use something like ("%s", arg), with calls to the corresponding 'simple' version. Since it is likely that single parameter calls to the variadic functions may be accidentally reintroduced in the future a new debugging config option WARN_SIMPLE_MSG has been introduced. This uses some macro magic which will cause any such calls to generate a warning, but this is turned off by default to avoid use of the unpleasant macros in normal circumstances. This is a large changeset due to the number of calls that have been replaced. The only files that contain changes other than simple substitution of function calls are libbb.h, libbb/herror_msg.c, libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c, networking/udhcp/common.h and util-linux/mdev.c additonal macros have been added for logging so that single parameter and multiple parameter logging variants exist. The amount of space saved varies considerably by architecture, and was found to be as follows (for 'defconfig' using GCC 7.4): Arm: -92 bytes MIPS: -52 bytes PPC: -1836 bytes x86_64: -938 bytes Note that for the MIPS architecture only an exception had to be made disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h) because it made these files larger on MIPS. Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/acpid.c2
-rw-r--r--util-linux/dmesg.c4
-rw-r--r--util-linux/eject.c2
-rw-r--r--util-linux/fdformat.c2
-rw-r--r--util-linux/fdisk.c2
-rw-r--r--util-linux/flock.c2
-rw-r--r--util-linux/fsck_minix.c2
-rw-r--r--util-linux/getopt.c6
-rw-r--r--util-linux/hwclock.c4
-rw-r--r--util-linux/ipcs.c8
-rw-r--r--util-linux/last.c2
-rw-r--r--util-linux/losetup.c4
-rw-r--r--util-linux/mdev.c10
-rw-r--r--util-linux/mesg.c2
-rw-r--r--util-linux/mkfs_ext2.c6
-rw-r--r--util-linux/mkfs_minix.c22
-rw-r--r--util-linux/mkfs_reiser.c2
-rw-r--r--util-linux/mkfs_vfat.c6
-rw-r--r--util-linux/mkswap.c2
-rw-r--r--util-linux/mount.c40
-rw-r--r--util-linux/nsenter.c2
-rw-r--r--util-linux/rdate.c6
-rw-r--r--util-linux/readprofile.c4
-rw-r--r--util-linux/rtcwake.c2
-rw-r--r--util-linux/setpriv.c8
-rw-r--r--util-linux/switch_root.c6
-rw-r--r--util-linux/uevent.c4
-rw-r--r--util-linux/unshare.c2
28 files changed, 85 insertions, 79 deletions
diff --git a/util-linux/acpid.c b/util-linux/acpid.c
index 7274b6866..95f8150e2 100644
--- a/util-linux/acpid.c
+++ b/util-linux/acpid.c
@@ -148,7 +148,7 @@ static void process_event(const char *event)
const char *args[] = { "run-parts", handler, NULL };
// log the event
- bb_error_msg("%s", event);
+ bb_simple_error_msg(event);
// spawn handler
// N.B. run-parts would require scripts to have #!/bin/sh
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index b797c7b2a..a1f269142 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -74,7 +74,7 @@ int dmesg_main(int argc UNUSED_PARAM, char **argv)
opts = getopt32(argv, "cs:+n:+r", &len, &level);
if (opts & OPT_n) {
if (klogctl(8, NULL, (long) level))
- bb_perror_msg_and_die("klogctl");
+ bb_simple_perror_msg_and_die("klogctl");
return EXIT_SUCCESS;
}
@@ -88,7 +88,7 @@ int dmesg_main(int argc UNUSED_PARAM, char **argv)
buf = xmalloc(len);
len = klogctl(3 + (opts & OPT_c), buf, len); /* read ring buffer */
if (len < 0)
- bb_perror_msg_and_die("klogctl");
+ bb_simple_perror_msg_and_die("klogctl");
if (len == 0)
return EXIT_SUCCESS;
diff --git a/util-linux/eject.c b/util-linux/eject.c
index 749e2c986..3ccb4ae89 100644
--- a/util-linux/eject.c
+++ b/util-linux/eject.c
@@ -70,7 +70,7 @@ static void eject_scsi(const char *dev)
sg_io_hdr_t io_hdr;
if ((ioctl(dev_fd, SG_GET_VERSION_NUM, &i) < 0) || (i < 30000))
- bb_error_msg_and_die("not a sg device or old sg driver");
+ bb_simple_error_msg_and_die("not a sg device or old sg driver");
memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
io_hdr.interface_id = 'S';
diff --git a/util-linux/fdformat.c b/util-linux/fdformat.c
index ff3bc4870..e1c8561d6 100644
--- a/util-linux/fdformat.c
+++ b/util-linux/fdformat.c
@@ -117,7 +117,7 @@ int fdformat_main(int argc UNUSED_PARAM, char **argv)
read_bytes = safe_read(fd, data, n);
if (read_bytes != n) {
if (read_bytes < 0) {
- bb_perror_msg(bb_msg_read_error);
+ bb_simple_perror_msg(bb_msg_read_error);
}
bb_error_msg_and_die("problem reading cylinder %d, "
"expected %d, read %d", cyl, n, read_bytes);
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index 58e93bb92..f28d4fdd2 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -511,7 +511,7 @@ static sector_t bb_BLKGETSIZE_sectors(int fd)
* we support can't record more than 32 bit
* sector counts or offsets
*/
- bb_error_msg("device has more than 2^32 sectors, can't use all of them");
+ bb_simple_error_msg("device has more than 2^32 sectors, can't use all of them");
v64 = (uint32_t)-1L;
}
return v64;
diff --git a/util-linux/flock.c b/util-linux/flock.c
index 130627e93..12c16013c 100644
--- a/util-linux/flock.c
+++ b/util-linux/flock.c
@@ -73,7 +73,7 @@ int flock_main(int argc UNUSED_PARAM, char **argv)
) {
argv++;
if (argv[1])
- bb_error_msg_and_die("-c takes only one argument");
+ bb_simple_error_msg_and_die("-c takes only one argument");
opt |= OPT_c;
}
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index f523da945..40b86d01b 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -321,7 +321,7 @@ static void die(const char *str)
{
if (termios_set)
tcsetattr_stdin_TCSANOW(&sv_termios);
- bb_error_msg_and_die("%s", str);
+ bb_simple_error_msg_and_die(str);
}
static void push_filename(const char *name)
diff --git a/util-linux/getopt.c b/util-linux/getopt.c
index 1666d3d30..db7db6ff8 100644
--- a/util-linux/getopt.c
+++ b/util-linux/getopt.c
@@ -308,7 +308,7 @@ static struct option *add_long_options(struct option *long_options, char *option
}
tokptr[tlen] = '\0';
if (tlen == 0)
- bb_error_msg_and_die("empty long option specified");
+ bb_simple_error_msg_and_die("empty long option specified");
}
long_options = xrealloc_vector(long_options, 4, long_nr);
long_options[long_nr].has_arg = arg_opt;
@@ -380,7 +380,7 @@ int getopt_main(int argc, char **argv)
puts(" --");
return 0;
}
- bb_error_msg_and_die("missing optstring argument");
+ bb_simple_error_msg_and_die("missing optstring argument");
}
if (argv[1][0] != '-' || compatible) {
@@ -416,7 +416,7 @@ int getopt_main(int argc, char **argv)
if (!optstr) {
optstr = argv[++n];
if (!optstr)
- bb_error_msg_and_die("missing optstring argument");
+ bb_simple_error_msg_and_die("missing optstring argument");
}
argv[n] = name ? name : argv[0];
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
index 29f51021e..dc97d8fb4 100644
--- a/util-linux/hwclock.c
+++ b/util-linux/hwclock.c
@@ -132,7 +132,7 @@ static void to_sys_clock(const char **pp_rtcname, int utc)
tv.tv_sec = read_rtc(pp_rtcname, NULL, utc);
tv.tv_usec = 0;
if (settimeofday(&tv, &tz))
- bb_perror_msg_and_die("settimeofday");
+ bb_simple_perror_msg_and_die("settimeofday");
}
static void from_sys_clock(const char **pp_rtcname, int utc)
@@ -284,7 +284,7 @@ static void set_system_clock_timezone(int utc)
if (!utc)
tv.tv_sec += tz.tz_minuteswest * 60;
if (settimeofday(&tv, &tz))
- bb_perror_msg_and_die("settimeofday");
+ bb_simple_perror_msg_and_die("settimeofday");
}
//usage:#define hwclock_trivial_usage
diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c
index 4863a5c29..df86cfb9d 100644
--- a/util-linux/ipcs.c
+++ b/util-linux/ipcs.c
@@ -467,7 +467,7 @@ static void print_shm(int shmid)
struct ipc_perm *ipcp = &shmds.shm_perm;
if (shmctl(shmid, IPC_STAT, &shmds) == -1) {
- bb_perror_msg("shmctl");
+ bb_simple_perror_msg("shmctl");
return;
}
@@ -493,7 +493,7 @@ static void print_msg(int msqid)
struct ipc_perm *ipcp = &buf.msg_perm;
if (msgctl(msqid, IPC_STAT, &buf) == -1) {
- bb_perror_msg("msgctl");
+ bb_simple_perror_msg("msgctl");
return;
}
@@ -527,7 +527,7 @@ static void print_sem(int semid)
arg.buf = &semds;
if (semctl(semid, 0, IPC_STAT, arg)) {
- bb_perror_msg("semctl");
+ bb_simple_perror_msg("semctl");
return;
}
@@ -555,7 +555,7 @@ static void print_sem(int semid)
zcnt = semctl(semid, i, GETZCNT, arg);
pid = semctl(semid, i, GETPID, arg);
if (val < 0 || ncnt < 0 || zcnt < 0 || pid < 0) {
- bb_perror_msg_and_die("semctl");
+ bb_simple_perror_msg_and_die("semctl");
}
printf("%-10u %-10d %-10d %-10d %-10d\n", i, val, ncnt, zcnt, pid);
}
diff --git a/util-linux/last.c b/util-linux/last.c
index 689aa7a34..24ce7a8d8 100644
--- a/util-linux/last.c
+++ b/util-linux/last.c
@@ -100,7 +100,7 @@ int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
pos = lseek(file, pos - sizeof(ut), SEEK_SET);
while ((n = full_read(file, &ut, sizeof(ut))) > 0) {
if (n != sizeof(ut)) {
- bb_perror_msg_and_die("short read");
+ bb_simple_perror_msg_and_die("short read");
}
n = index_in_strings(_ut_lin, ut.ut_line);
if (n == _TILDE) { /* '~' */
diff --git a/util-linux/losetup.c b/util-linux/losetup.c
index 5dc757074..cc6c2b1d5 100644
--- a/util-linux/losetup.c
+++ b/util-linux/losetup.c
@@ -118,13 +118,13 @@ int losetup_main(int argc UNUSED_PARAM, char **argv)
n = get_free_loop();
if (n == -1)
- bb_error_msg_and_die("no free loop devices");
+ bb_simple_error_msg_and_die("no free loop devices");
if (n < 0) /* n == -2: no /dev/loop-control, use legacy method */
n = 0;
/* or: n >= 0: the number of next free loopdev, just verify it */
do {
if (n > MAX_LOOP_NUM)
- bb_error_msg_and_die("no free loop devices");
+ bb_simple_error_msg_and_die("no free loop devices");
sprintf(dev, LOOP_FORMAT, n++);
s = query_loop(dev);
free(s);
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 9cb3586f1..207a112c1 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -250,18 +250,24 @@
#if DEBUG_LVL >= 1
# define dbg1(...) do { if (G.verbose) bb_error_msg(__VA_ARGS__); } while(0)
+# define dbg1s(msg) do { if (G.verbose) bb_simple_error_msg(msg); } while(0)
#else
# define dbg1(...) ((void)0)
+# define dbg1s(msg) ((void)0)
#endif
#if DEBUG_LVL >= 2
# define dbg2(...) do { if (G.verbose >= 2) bb_error_msg(__VA_ARGS__); } while(0)
+# define dbg2s(msg) do { if (G.verbose >= 2) bb_simple_error_msg(msg); } while(0)
#else
# define dbg2(...) ((void)0)
+# define dbg2s(msg) ((void)0)
#endif
#if DEBUG_LVL >= 3
# define dbg3(...) do { if (G.verbose >= 3) bb_error_msg(__VA_ARGS__); } while(0)
+# define dbg3s(msg) do { if (G.verbose >= 3) bb_simple_error_msg(msg); } while(0)
#else
# define dbg3(...) ((void)0)
+# define dbg3s(msg) ((void)0)
#endif
@@ -1021,7 +1027,7 @@ wait_for_seqfile(unsigned expected_seq)
/* seed file: write out seq ASAP */
xwrite_str(seq_fd, utoa(expected_seq));
xlseek(seq_fd, 0, SEEK_SET);
- dbg2("first seq written");
+ dbg2s("first seq written");
break;
}
seqbufnum = atoll(seqbuf);
@@ -1165,7 +1171,7 @@ static void daemon_loop(char *temp, int fd)
len = safe_read(fd, netbuf, sizeof(netbuf) - 1);
if (len < 0) {
- bb_perror_msg_and_die("read");
+ bb_simple_perror_msg_and_die("read");
}
end = netbuf + len;
*end = '\0';
diff --git a/util-linux/mesg.c b/util-linux/mesg.c
index c7b696853..8c032555b 100644
--- a/util-linux/mesg.c
+++ b/util-linux/mesg.c
@@ -65,7 +65,7 @@ int mesg_main(int argc UNUSED_PARAM, char **argv)
*/
if (!isatty(STDIN_FILENO))
- bb_error_msg_and_die("not a tty");
+ bb_simple_error_msg_and_die("not a tty");
xfstat(STDIN_FILENO, &sb, "stdin");
if (c == 0) {
diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c
index 845ba0a24..d568f4be5 100644
--- a/util-linux/mkfs_ext2.c
+++ b/util-linux/mkfs_ext2.c
@@ -266,7 +266,7 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv)
// N.B. what if we format a file? find_mount_point will return false negative since
// it is loop block device which is mounted!
if (find_mount_point(argv[0], 0))
- bb_error_msg_and_die("can't format mounted filesystem");
+ bb_simple_error_msg_and_die("can't format mounted filesystem");
// get size in kbytes
kilobytes = get_volume_size_in_bytes(fd, argv[1], 1024, /*extend:*/ !(option_mask32 & OPT_n)) / 1024;
@@ -326,11 +326,11 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv)
kilobytes >>= (blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE);
nblocks = kilobytes;
if (nblocks != kilobytes)
- bb_error_msg_and_die("block count doesn't fit in 32 bits");
+ bb_simple_error_msg_and_die("block count doesn't fit in 32 bits");
#define kilobytes kilobytes_unused_after_this
// Experimentally, standard mke2fs won't work on images smaller than 60k
if (nblocks < 60)
- bb_error_msg_and_die("need >= 60 blocks");
+ bb_simple_error_msg_and_die("need >= 60 blocks");
// How many reserved blocks?
if (reserved_percent > 50)
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index e191acbd0..8f791cf66 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -262,7 +262,7 @@ static int get_free_block(void)
int blk;
if (G.used_good_blocks + 1 >= MAX_GOOD_BLOCKS)
- bb_error_msg_and_die("too many bad blocks");
+ bb_simple_error_msg_and_die("too many bad blocks");
if (G.used_good_blocks)
blk = G.good_blocks_table[G.used_good_blocks - 1] + 1;
else
@@ -270,7 +270,7 @@ static int get_free_block(void)
while (blk < SB_ZONES && zone_in_use(blk))
blk++;
if (blk >= SB_ZONES)
- bb_error_msg_and_die("not enough good blocks");
+ bb_simple_error_msg_and_die("not enough good blocks");
G.good_blocks_table[G.used_good_blocks] = blk;
G.used_good_blocks++;
return blk;
@@ -342,7 +342,7 @@ static void make_bad_inode(void)
goto end_bad;
}
}
- bb_error_msg_and_die("too many bad blocks");
+ bb_simple_error_msg_and_die("too many bad blocks");
end_bad:
if (ind)
write_block(ind, (char *) ind_block);
@@ -398,7 +398,7 @@ static void make_bad_inode2(void)
}
}
/* Could make triple indirect block here */
- bb_error_msg_and_die("too many bad blocks");
+ bb_simple_error_msg_and_die("too many bad blocks");
end_bad:
if (ind)
write_block(ind, (char *) ind_block);
@@ -514,7 +514,7 @@ static void check_blocks(void)
if (got == try)
continue;
if (G.currently_testing < SB_FIRSTZONE)
- bb_error_msg_and_die("bad blocks before data-area: cannot make fs");
+ bb_simple_error_msg_and_die("bad blocks before data-area: cannot make fs");
mark_zone(G.currently_testing);
G.badblocks++;
G.currently_testing++;
@@ -588,7 +588,7 @@ static void setup_tables(void)
SB_ZMAPS = sb_zmaps;
/* new SB_ZMAPS, need to recalc NORM_FIRSTZONE */
} while (--i);
- bb_error_msg_and_die("incompatible size/inode count, try different -i N");
+ bb_simple_error_msg_and_die("incompatible size/inode count, try different -i N");
got_it:
SB_FIRSTZONE = norm_firstzone;
@@ -623,10 +623,10 @@ int mkfs_minix_main(int argc UNUSED_PARAM, char **argv)
G.magic = MINIX1_SUPER_MAGIC2;
if (INODE_SIZE1 * MINIX1_INODES_PER_BLOCK != BLOCK_SIZE)
- bb_error_msg_and_die("bad inode size");
+ bb_simple_error_msg_and_die("bad inode size");
#if ENABLE_FEATURE_MINIX2
if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE)
- bb_error_msg_and_die("bad inode size");
+ bb_simple_error_msg_and_die("bad inode size");
#endif
opt = getopt32(argv, "ci:l:n:+v", &str_i, &listfile, &G.namelen);
@@ -644,7 +644,7 @@ int mkfs_minix_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_FEATURE_MINIX2
version2 = 1;
#else
- bb_error_msg_and_die("not compiled with minix v2 support");
+ bb_simple_error_msg_and_die("not compiled with minix v2 support");
#endif
}
@@ -654,14 +654,14 @@ int mkfs_minix_main(int argc UNUSED_PARAM, char **argv)
/* Check if it is mounted */
if (find_mount_point(G.device_name, 0))
- bb_error_msg_and_die("can't format mounted filesystem");
+ bb_simple_error_msg_and_die("can't format mounted filesystem");
xmove_fd(xopen(G.device_name, O_RDWR), dev_fd);
G.total_blocks = get_volume_size_in_bytes(dev_fd, argv[1], 1024, /*extend:*/ 1) / 1024;
if (G.total_blocks < 10)
- bb_error_msg_and_die("must have at least 10 blocks");
+ bb_simple_error_msg_and_die("must have at least 10 blocks");
if (version2) {
G.magic = MINIX2_SUPER_MAGIC2;
diff --git a/util-linux/mkfs_reiser.c b/util-linux/mkfs_reiser.c
index b4c8dda6f..d2eaf5f94 100644
--- a/util-linux/mkfs_reiser.c
+++ b/util-linux/mkfs_reiser.c
@@ -178,7 +178,7 @@ int mkfs_reiser_main(int argc UNUSED_PARAM, char **argv)
// N.B. what if we format a file? find_mount_point will return false negative since
// it is loop block device which is mounted!
if (find_mount_point(argv[0], 0))
- bb_error_msg_and_die("can't format mounted filesystem");
+ bb_simple_error_msg_and_die("can't format mounted filesystem");
// open the device, get size in blocks
blocks = get_volume_size_in_bytes(fd, argv[1], blocksize, /*extend:*/ 1) / blocksize;
diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c
index b760fb2aa..16c1fac00 100644
--- a/util-linux/mkfs_vfat.c
+++ b/util-linux/mkfs_vfat.c
@@ -278,7 +278,7 @@ int mkfs_vfat_main(int argc UNUSED_PARAM, char **argv)
if (!S_ISBLK(st.st_mode)) {
if (!S_ISREG(st.st_mode)) {
if (!argv[1])
- bb_error_msg_and_die("image size must be specified");
+ bb_simple_error_msg_and_die("image size must be specified");
}
// not a block device, skip bad sectors check
opts &= ~OPT_c;
@@ -399,7 +399,7 @@ int mkfs_vfat_main(int argc UNUSED_PARAM, char **argv)
// "mkdosfs -v -F 32 image5k 5" is the minimum:
// 2 sectors for FATs and 2 data sectors
if ((off_t)(volume_size_sect - reserved_sect) < 4)
- bb_error_msg_and_die("the image is too small for FAT32");
+ bb_simple_error_msg_and_die("the image is too small for FAT32");
sect_per_fat = 1;
while (1) {
while (1) {
@@ -439,7 +439,7 @@ int mkfs_vfat_main(int argc UNUSED_PARAM, char **argv)
}
next:
if (sect_per_clust == 128)
- bb_error_msg_and_die("can't make FAT32 with >128 sectors/cluster");
+ bb_simple_error_msg_and_die("can't make FAT32 with >128 sectors/cluster");
sect_per_clust *= 2;
sect_per_fat = (sect_per_fat / 2) | 1;
}
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c
index 38413606d..9e51a1dcc 100644
--- a/util-linux/mkswap.c
+++ b/util-linux/mkswap.c
@@ -75,7 +75,7 @@ static void mkswap_selinux_setcontext(int fd, const char *path)
}
return;
error:
- bb_perror_msg_and_die("SELinux relabeling failed");
+ bb_simple_perror_msg_and_die("SELinux relabeling failed");
}
#else
# define mkswap_selinux_setcontext(fd, path) ((void)0)
diff --git a/util-linux/mount.c b/util-linux/mount.c
index e6bad7c2c..84c85c057 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -483,7 +483,7 @@ static void FAST_FUNC update_mtab_entry_on_move(const struct mntent *mp)
mountTable = setmntent(bb_path_mtab_file, "r");
if (!mountTable) {
- bb_perror_msg(bb_path_mtab_file);
+ bb_simple_perror_msg(bb_path_mtab_file);
return;
}
@@ -511,7 +511,7 @@ static void FAST_FUNC update_mtab_entry_on_move(const struct mntent *mp)
}
endmntent(mountTable);
} else if (errno != EROFS)
- bb_perror_msg(bb_path_mtab_file);
+ bb_simple_perror_msg(bb_path_mtab_file);
if (ENABLE_FEATURE_CLEAN_UP) {
for (i = 0; i < count; i++) {
@@ -739,7 +739,7 @@ static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filtero
// Abort entirely if permission denied.
if (rc && errno == EPERM)
- bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
+ bb_simple_error_msg_and_die(bb_msg_perm_denied_are_you_root);
// If the mount was successful, and we're maintaining an old-style
// mtab file by hand, add the new entry to it now.
@@ -751,7 +751,7 @@ static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filtero
int i;
if (!mountTable) {
- bb_perror_msg(bb_path_mtab_file);
+ bb_simple_perror_msg(bb_path_mtab_file);
goto ret;
}
@@ -1288,18 +1288,18 @@ static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *fi
s = strchr(hostname, ',');
if (s) {
*s = '\0';
- bb_error_msg("warning: multiple hostnames not supported");
+ bb_simple_error_msg("warning: multiple hostnames not supported");
}
server_addr.sin_family = AF_INET;
if (!inet_aton(hostname, &server_addr.sin_addr)) {
hp = gethostbyname(hostname);
if (hp == NULL) {
- bb_herror_msg("%s", hostname);
+ bb_simple_herror_msg(hostname);
goto fail;
}
if (hp->h_length != (int)sizeof(struct in_addr)) {
- bb_error_msg_and_die("only IPv4 is supported");
+ bb_simple_error_msg_and_die("only IPv4 is supported");
}
memcpy(&server_addr.sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));
}
@@ -1389,7 +1389,7 @@ static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *fi
else if (is_prefixed_with(opteq, "udp"))
tcp = 0;
else
- bb_error_msg("warning: unrecognized proto= option");
+ bb_simple_error_msg("warning: unrecognized proto= option");
continue;
case 20: // "addr" - ignore
continue;
@@ -1522,7 +1522,7 @@ static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *fi
if (nfs_mount_version >= 3)
nolock = !val;
else
- bb_error_msg("warning: option nolock is not supported");
+ bb_simple_error_msg("warning: option nolock is not supported");
break;
case 11: //rdirplus
nordirplus = !val;
@@ -1590,11 +1590,11 @@ static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *fi
} else {
hp = gethostbyname(mounthost);
if (hp == NULL) {
- bb_herror_msg("%s", mounthost);
+ bb_simple_herror_msg(mounthost);
goto fail;
}
if (hp->h_length != (int)sizeof(struct in_addr)) {
- bb_error_msg_and_die("only IPv4 is supported");
+ bb_simple_error_msg_and_die("only IPv4 is supported");
}
mount_server_addr.sin_family = AF_INET;
memcpy(&mount_server_addr.sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));
@@ -1767,18 +1767,18 @@ static NOINLINE int nfsmount(struct mntent *mp, unsigned long vfsflags, char *fi
/* Create nfs socket for kernel */
if (tcp) {
if (nfs_mount_version < 3) {
- bb_error_msg("NFS over TCP is not supported");
+ bb_simple_error_msg("NFS over TCP is not supported");
goto fail;
}
fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
} else
fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (fsock < 0) {
- bb_perror_msg("nfs socket");
+ bb_simple_perror_msg("nfs socket");
goto fail;
}
if (bindresvport(fsock, 0) < 0) {
- bb_perror_msg("nfs bindresvport");
+ bb_simple_perror_msg("nfs bindresvport");
goto fail;
}
if (port == 0) {
@@ -2047,9 +2047,9 @@ static int singlemount(struct mntent *mp, int ignore_busy)
);
if (loopfd < 0) {
if (errno == EPERM || errno == EACCES)
- bb_error_msg(bb_msg_perm_denied_are_you_root);
+ bb_simple_error_msg(bb_msg_perm_denied_are_you_root);
else
- bb_perror_msg("can't setup loop device");
+ bb_simple_perror_msg("can't setup loop device");
return errno;
}
@@ -2255,7 +2255,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
// argument when we get it.
if (argv[1]) {
if (nonroot)
- bb_error_msg_and_die(bb_msg_you_must_be_root);
+ bb_simple_error_msg_and_die(bb_msg_you_must_be_root);
mtpair->mnt_fsname = argv[0];
mtpair->mnt_dir = argv[1];
mtpair->mnt_type = fstype;
@@ -2272,7 +2272,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
cmdopt_flags = parse_mount_options(cmdopts, NULL);
if (nonroot && (cmdopt_flags & ~MS_SILENT)) // Non-root users cannot specify flags
- bb_error_msg_and_die(bb_msg_you_must_be_root);
+ bb_simple_error_msg_and_die(bb_msg_you_must_be_root);
// If we have a shared subtree flag, don't worry about fstab or mtab.
if (ENABLE_FEATURE_MOUNT_FLAGS
@@ -2337,7 +2337,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
// No, mount -a won't mount anything,
// even user mounts, for mere humans
if (nonroot)
- bb_error_msg_and_die(bb_msg_you_must_be_root);
+ bb_simple_error_msg_and_die(bb_msg_you_must_be_root);
// Does type match? (NULL matches always)
if (!fstype_matches(mtcur->mnt_type, fstype))
@@ -2417,7 +2417,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
// fstab must have "users" or "user"
l = parse_mount_options(mtcur->mnt_opts, NULL);
if (!(l & MOUNT_USERS))
- bb_error_msg_and_die(bb_msg_you_must_be_root);
+ bb_simple_error_msg_and_die(bb_msg_you_must_be_root);
}
//util-linux-2.12 does not do this check.
diff --git a/util-linux/nsenter.c b/util-linux/nsenter.c
index 4eeaa9f3e..304f2d748 100644
--- a/util-linux/nsenter.c
+++ b/util-linux/nsenter.c
@@ -257,7 +257,7 @@ int nsenter_main(int argc UNUSED_PARAM, char **argv)
if (opts & OPT_setgid) {
if (setgroups(0, NULL) < 0 && setgroups_failed)
- bb_perror_msg_and_die("setgroups");
+ bb_simple_perror_msg_and_die("setgroups");
xsetgid(gid);
}
if (opts & OPT_setuid)
diff --git a/util-linux/rdate.c b/util-linux/rdate.c
index 70f829e7f..41aade5ea 100644
--- a/util-linux/rdate.c
+++ b/util-linux/rdate.c
@@ -33,7 +33,7 @@ enum { RFC_868_BIAS = 2208988800UL };
static void socket_timeout(int sig UNUSED_PARAM)
{
- bb_error_msg_and_die("timeout connecting to time server");
+ bb_simple_error_msg_and_die("timeout connecting to time server");
}
static time_t askremotedate(const char *host)
@@ -94,10 +94,10 @@ int rdate_main(int argc UNUSED_PARAM, char **argv)
if (!(flags & 2)) { /* no -p (-s may be present) */
if (time(NULL) == remote_time)
- bb_error_msg("current time matches remote time");
+ bb_simple_error_msg("current time matches remote time");
else
if (stime(&remote_time) < 0)
- bb_perror_msg_and_die("can't set time of day");
+ bb_simple_perror_msg_and_die("can't set time of day");
}
if (flags != 1) /* not lone -s */
diff --git a/util-linux/readprofile.c b/util-linux/readprofile.c
index cab2c4319..c4ea374be 100644
--- a/util-linux/readprofile.c
+++ b/util-linux/readprofile.c
@@ -142,7 +142,7 @@ int readprofile_main(int argc UNUSED_PARAM, char **argv)
small++;
}
if (big > small) {
- bb_error_msg("assuming reversed byte order, "
+ bb_simple_error_msg("assuming reversed byte order, "
"use -n to force native byte order");
BUILD_BUG_ON(sizeof(*p) > 8);
for (p = buf; p < buf+len; p++) {
@@ -204,7 +204,7 @@ int readprofile_main(int argc UNUSED_PARAM, char **argv)
}
if (indx >= len)
- bb_error_msg_and_die("profile address out of range. "
+ bb_simple_error_msg_and_die("profile address out of range. "
"Wrong map file?");
this = 0;
diff --git a/util-linux/rtcwake.c b/util-linux/rtcwake.c
index 29c440b82..cad0f9d64 100644
--- a/util-linux/rtcwake.c
+++ b/util-linux/rtcwake.c
@@ -230,7 +230,7 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
do {
ssize_t ret = safe_read(fd, &data, sizeof(data));
if (ret < 0) {
- bb_perror_msg("rtc read");
+ bb_simple_perror_msg("rtc read");
break;
}
} while (!(data & RTC_AF));
diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c
index b69b8cbb6..e5cf96957 100644
--- a/util-linux/setpriv.c
+++ b/util-linux/setpriv.c
@@ -164,7 +164,7 @@ static void set_inh_caps(char *capstring)
}
if (capset(&caps.header, caps.data) != 0)
- bb_perror_msg_and_die("capset");
+ bb_simple_perror_msg_and_die("capset");
}
static void set_ambient_caps(char *string)
@@ -178,10 +178,10 @@ static void set_ambient_caps(char *string)
idx = parse_cap(cap);
if (cap[0] == '+') {
if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, idx, 0, 0) < 0)
- bb_perror_msg("cap_ambient_raise");
+ bb_simple_perror_msg("cap_ambient_raise");
} else {
if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_LOWER, idx, 0, 0) < 0)
- bb_perror_msg("cap_ambient_lower");
+ bb_simple_perror_msg("cap_ambient_lower");
}
cap = strtok(NULL, ",");
}
@@ -236,7 +236,7 @@ static int dump(void)
unsigned idx = CAP_TO_INDEX(i);
if (idx >= caps.u32s) {
printf("\nindex: %u u32s: %u capability: %u\n", idx, caps.u32s, i);
- bb_error_msg_and_die("unsupported capability");
+ bb_simple_error_msg_and_die("unsupported capability");
}
if (caps.data[idx].inheritable & CAP_TO_MASK(i)) {
printf_cap(fmt, i);
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c
index ae9d412d1..a483893ed 100644
--- a/util-linux/switch_root.c
+++ b/util-linux/switch_root.c
@@ -117,7 +117,7 @@ static void drop_capset(int cap_idx)
getcaps(&caps);
caps.data[CAP_TO_INDEX(cap_idx)].inheritable &= ~CAP_TO_MASK(cap_idx);
if (capset(&caps.header, caps.data) != 0)
- bb_perror_msg_and_die("capset");
+ bb_simple_perror_msg_and_die("capset");
}
static void drop_bounding_set(int cap_idx)
@@ -253,7 +253,7 @@ int switch_root_main(int argc UNUSED_PARAM, char **argv)
if ((unsigned)stfs.f_type != RAMFS_MAGIC
&& (unsigned)stfs.f_type != TMPFS_MAGIC
) {
- bb_error_msg_and_die("root filesystem is not ramfs/tmpfs");
+ bb_simple_error_msg_and_die("root filesystem is not ramfs/tmpfs");
}
if (!dry_run) {
@@ -263,7 +263,7 @@ int switch_root_main(int argc UNUSED_PARAM, char **argv)
// Overmount / with newdir and chroot into it
if (mount(".", "/", NULL, MS_MOVE, NULL)) {
// For example, fails when newroot is not a mountpoint
- bb_perror_msg_and_die("error moving root");
+ bb_simple_perror_msg_and_die("error moving root");
}
}
xchroot(".");
diff --git a/util-linux/uevent.c b/util-linux/uevent.c
index 2f8990ed9..7a1d7d4a7 100644
--- a/util-linux/uevent.c
+++ b/util-linux/uevent.c
@@ -75,12 +75,12 @@ int uevent_main(int argc UNUSED_PARAM, char **argv)
MAP_PRIVATE | MAP_ANON,
/* ignored: */ -1, 0);
if (netbuf == MAP_FAILED)
- bb_perror_msg_and_die("mmap");
+ bb_simple_perror_msg_and_die("mmap");
// Here we block, possibly for a very long time
len = safe_read(fd, netbuf, BUFFER_SIZE - 1);
if (len < 0)
- bb_perror_msg_and_die("read");
+ bb_simple_perror_msg_and_die("read");
end = netbuf + len;
*end = '\0';
diff --git a/util-linux/unshare.c b/util-linux/unshare.c
index 61fc71197..a943e7b03 100644
--- a/util-linux/unshare.c
+++ b/util-linux/unshare.c
@@ -239,7 +239,7 @@ int unshare_main(int argc UNUSED_PARAM, char **argv)
if (setgrp_str) {
if (strcmp(setgrp_str, "allow") == 0) {
if (opts & OPT_map_root) {
- bb_error_msg_and_die(
+ bb_simple_error_msg_and_die(
"--setgroups=allow and --map-root-user "
"are mutually exclusive"
);