Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-06-15 12:55:56 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2023-06-15 12:55:56 +0300
commit648f506949ded749e28186d0092b6e42085c897b (patch)
tree049c72bc8149f41fc617d00f7d32f1d6384f8e2f
parent61a4959251667751e424e600c6cb75de39d6b1c3 (diff)
libbb: code shrink: introduce and use [_]exit_FAILURE()
function old new delta exit_FAILURE - 7 +7 _exit_FAILURE - 7 +7 run 198 199 +1 restore_state_and_exit 114 115 +1 xbsd_write_bootstrap 399 397 -2 vfork_compressor 209 207 -2 sig_handler 12 10 -2 serial_ctl 154 152 -2 parse_args 1169 1167 -2 onintr 21 19 -2 make_new_session 493 491 -2 login_main 988 986 -2 gotsig 35 33 -2 do_iplink 1315 1313 -2 addgroup_main 397 395 -2 inetd_main 1911 1908 -3 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 2/12 up/down: 16/-25) Total: -9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--applets/individual.c2
-rw-r--r--archival/tar.c2
-rw-r--r--console-tools/resize.c2
-rw-r--r--findutils/xargs.c2
-rw-r--r--include/libbb.h2
-rw-r--r--init/init.c2
-rw-r--r--libbb/xfuncs.c10
-rw-r--r--loginutils/addgroup.c2
-rw-r--r--loginutils/login.c10
-rw-r--r--miscutils/devfsd.c6
-rw-r--r--miscutils/setserial.c2
-rw-r--r--networking/inetd.c4
-rw-r--r--networking/libiproute/iplink.c2
-rw-r--r--networking/libiproute/iptunnel.c2
-rw-r--r--networking/ping.c2
-rw-r--r--networking/slattach.c2
-rw-r--r--networking/telnetd.c2
-rw-r--r--procps/powertop.c2
-rw-r--r--selinux/setfiles.c2
-rw-r--r--util-linux/fdisk_osf.c5
-rw-r--r--util-linux/more.c2
21 files changed, 40 insertions, 27 deletions
diff --git a/applets/individual.c b/applets/individual.c
index e94f26c93..2f743d906 100644
--- a/applets/individual.c
+++ b/applets/individual.c
@@ -20,5 +20,5 @@ int main(int argc, char **argv)
void bb_show_usage(void)
{
fputs_stdout(APPLET_full_usage "\n");
- exit(EXIT_FAILURE);
+ exit_FAILURE();
}
diff --git a/archival/tar.c b/archival/tar.c
index 9de37592e..d6ca6c1e0 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -621,7 +621,7 @@ static void NOINLINE vfork_compressor(int tar_fd, const char *gzip)
execlp(gzip, gzip, "-f", (char *)0);
vfork_exec_errno = errno;
- _exit(EXIT_FAILURE);
+ _exit_FAILURE();
}
/* parent */
diff --git a/console-tools/resize.c b/console-tools/resize.c
index 056e33750..95e0c7bf9 100644
--- a/console-tools/resize.c
+++ b/console-tools/resize.c
@@ -45,7 +45,7 @@ static void
onintr(int sig UNUSED_PARAM)
{
tcsetattr(STDERR_FILENO, TCSANOW, old_termios_p);
- _exit(EXIT_FAILURE);
+ _exit_FAILURE();
}
int resize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/findutils/xargs.c b/findutils/xargs.c
index 067ef41c5..c6000e066 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -800,7 +800,7 @@ void bb_show_usage(void)
{
fprintf(stderr, "Usage: %s [-p] [-r] [-t] -[x] [-n max_arg] [-s max_chars]\n",
applet_name);
- exit(EXIT_FAILURE);
+ exit_FAILURE();
}
int main(int argc, char **argv)
diff --git a/include/libbb.h b/include/libbb.h
index 6191debb1..18336da23 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1281,6 +1281,8 @@ void set_task_comm(const char *comm) FAST_FUNC;
#endif
void exit_SUCCESS(void) NORETURN FAST_FUNC;
void _exit_SUCCESS(void) NORETURN FAST_FUNC;
+void exit_FAILURE(void) NORETURN FAST_FUNC;
+void _exit_FAILURE(void) NORETURN FAST_FUNC;
/* Helpers for daemonization.
*
diff --git a/init/init.c b/init/init.c
index 1e1ce833d..2ee1e4cde 100644
--- a/init/init.c
+++ b/init/init.c
@@ -500,7 +500,7 @@ static pid_t run(const struct init_action *a)
/* Open the new terminal device */
if (!open_stdio_to_tty(a->terminal))
- _exit(EXIT_FAILURE);
+ _exit_FAILURE();
/* NB: on NOMMU we can't wait for input in child, so
* "askfirst" will work the same as "respawn". */
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 465e5366c..b03af8542 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -433,3 +433,13 @@ void FAST_FUNC _exit_SUCCESS(void)
{
_exit(EXIT_SUCCESS);
}
+
+void FAST_FUNC exit_FAILURE(void)
+{
+ exit(EXIT_FAILURE);
+}
+
+void FAST_FUNC _exit_FAILURE(void)
+{
+ _exit(EXIT_FAILURE);
+}
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index 2a83c8a15..71d3a8db9 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -102,7 +102,7 @@ static void new_group(char *group, gid_t gid)
/* add entry to group */
p = xasprintf("x:%u:", (unsigned) gr.gr_gid);
if (update_passwd(bb_path_group_file, group, p, NULL) < 0)
- exit(EXIT_FAILURE);
+ exit_FAILURE();
if (ENABLE_FEATURE_CLEAN_UP)
free(p);
#if ENABLE_FEATURE_SHADOWPASSWDS
diff --git a/loginutils/login.c b/loginutils/login.c
index 332238181..b02be2176 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -173,7 +173,7 @@ static void die_if_nologin(void)
fflush_all();
/* Users say that they do need this prior to exit: */
tcdrain(STDOUT_FILENO);
- exit(EXIT_FAILURE);
+ exit_FAILURE();
}
#else
# define die_if_nologin() ((void)0)
@@ -265,19 +265,19 @@ static void get_username_or_die(char *buf, int size_buf)
do {
c = getchar();
if (c == EOF)
- exit(EXIT_FAILURE);
+ exit_FAILURE();
if (c == '\n') {
if (!--cntdown)
- exit(EXIT_FAILURE);
+ exit_FAILURE();
goto prompt;
}
} while (isspace(c)); /* maybe isblank? */
*buf++ = c;
if (!fgets(buf, size_buf-2, stdin))
- exit(EXIT_FAILURE);
+ exit_FAILURE();
if (!strchr(buf, '\n'))
- exit(EXIT_FAILURE);
+ exit_FAILURE();
while ((unsigned char)*buf > ' ')
buf++;
*buf = '\0';
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index 297693f8c..36b491595 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -354,10 +354,10 @@ static const char bb_msg_variable_not_found[] ALIGN1 = "variable: %s not found";
#define simple_info_logger(p, msg)
#define msg_logger(p, fmt, args...)
#define simple_msg_logger(p, msg)
-#define msg_logger_and_die(p, fmt, args...) exit(EXIT_FAILURE)
-#define simple_msg_logger_and_die(p, msg) exit(EXIT_FAILURE)
+#define msg_logger_and_die(p, fmt, args...) exit_FAILURE()
+#define simple_msg_logger_and_die(p, msg) exit_FAILURE()
#define error_logger(p, fmt, args...)
-#define error_logger_and_die(p, fmt, args...) exit(EXIT_FAILURE)
+#define error_logger_and_die(p, fmt, args...) exit_FAILURE()
#endif
static void safe_memcpy(char *dest, const char *src, int len)
diff --git a/miscutils/setserial.c b/miscutils/setserial.c
index 2006861e2..175c788fc 100644
--- a/miscutils/setserial.c
+++ b/miscutils/setserial.c
@@ -535,7 +535,7 @@ static int serial_ctl(int fd, int ops, struct serial_struct *serinfo)
bb_simple_perror_msg(err);
if (ops & CTL_NODIE)
goto nodie;
- exit(EXIT_FAILURE);
+ exit_FAILURE();
}
static void print_flag(const char **prefix, const char *flag)
diff --git a/networking/inetd.c b/networking/inetd.c
index fb2fbe323..e63edcd9d 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1449,7 +1449,7 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
else
sep->se_builtin->bi_dgram_fn(ctrl, sep);
if (pid) /* we did fork */
- _exit(EXIT_FAILURE);
+ _exit_FAILURE();
maybe_close(accepted_fd);
continue; /* -> check next fd in fd set */
}
@@ -1530,7 +1530,7 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
/* eat packet in udp case */
if (sep->se_socktype != SOCK_STREAM)
recv(0, line, LINE_SIZE, MSG_DONTWAIT);
- _exit(EXIT_FAILURE);
+ _exit_FAILURE();
} /* for (sep = servtab...) */
} /* for (;;) */
}
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c
index 68d199044..9eb0b4f5f 100644
--- a/networking/libiproute/iplink.c
+++ b/networking/libiproute/iplink.c
@@ -215,7 +215,7 @@ static void parse_address(char *dev, int hatype, int halen, char *lla, struct if
alen = hatype == 1/*ARPHRD_ETHER*/ ? 14/*ETH_HLEN*/ : 19/*INFINIBAND_HLEN*/;
alen = ll_addr_a2n((unsigned char *)(ifr->ifr_hwaddr.sa_data), alen, lla);
if (alen < 0)
- exit(EXIT_FAILURE);
+ exit_FAILURE();
if (alen != halen) {
bb_error_msg_and_die("wrong address (%s) length: expected %d bytes", lla, halen);
}
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c
index c9fa632f3..1ec81c635 100644
--- a/networking/libiproute/iptunnel.c
+++ b/networking/libiproute/iptunnel.c
@@ -319,7 +319,7 @@ static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p)
struct ip_tunnel_parm old_p;
memset(&old_p, 0, sizeof(old_p));
if (do_get_ioctl(*argv, &old_p))
- exit(EXIT_FAILURE);
+ exit_FAILURE();
*p = old_p;
}
}
diff --git a/networking/ping.c b/networking/ping.c
index 9805695a1..b7e6955a9 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -247,7 +247,7 @@ struct globals {
static void noresp(int ign UNUSED_PARAM)
{
printf("No response from %s\n", G.hostname);
- exit(EXIT_FAILURE);
+ exit_FAILURE();
}
static void ping4(len_and_sockaddr *lsa)
diff --git a/networking/slattach.c b/networking/slattach.c
index 6d2a252fc..16b4c9158 100644
--- a/networking/slattach.c
+++ b/networking/slattach.c
@@ -80,7 +80,7 @@ static void restore_state_and_exit(int exitcode)
/* Restore line status */
if (tcsetattr_serial_or_warn(&G.saved_state))
- exit(EXIT_FAILURE);
+ exit_FAILURE();
if (ENABLE_FEATURE_CLEAN_UP)
close(serial_fd);
diff --git a/networking/telnetd.c b/networking/telnetd.c
index 0805e464f..fb90e7f11 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -571,7 +571,7 @@ make_new_session(
BB_EXECVP(G.loginpath, (char **)login_argv);
/* _exit is safer with vfork, and we shouldn't send message
* to remote clients anyway */
- _exit(EXIT_FAILURE); /*bb_perror_msg_and_die("execv %s", G.loginpath);*/
+ _exit_FAILURE(); /*bb_perror_msg_and_die("execv %s", G.loginpath);*/
}
#if ENABLE_FEATURE_TELNETD_STANDALONE
diff --git a/procps/powertop.c b/procps/powertop.c
index 18ddaa3ec..8d5d9295d 100644
--- a/procps/powertop.c
+++ b/procps/powertop.c
@@ -109,7 +109,7 @@ static void reset_term(void)
static void sig_handler(int signo UNUSED_PARAM)
{
reset_term();
- _exit(EXIT_FAILURE);
+ _exit_FAILURE();
}
#endif
diff --git a/selinux/setfiles.c b/selinux/setfiles.c
index a617b95d8..70e68a666 100644
--- a/selinux/setfiles.c
+++ b/selinux/setfiles.c
@@ -687,7 +687,7 @@ int setfiles_main(int argc UNUSED_PARAM, char **argv)
bb_simple_perror_msg_and_die(argv[0]);
}
if (nerr)
- exit(EXIT_FAILURE);
+ exit_FAILURE();
argv++;
}
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c
index 6c66c130d..049f0b169 100644
--- a/util-linux/fdisk_osf.c
+++ b/util-linux/fdisk_osf.c
@@ -746,11 +746,12 @@ xbsd_write_bootstrap(void)
return;
e = d + sizeof(struct xbsd_disklabel);
- for (p = d; p < e; p++)
+ for (p = d; p < e; p++) {
if (*p) {
printf("Bootstrap overlaps with disk label!\n");
- exit(EXIT_FAILURE);
+ exit_FAILURE();
}
+ }
memmove(d, &dl, sizeof(struct xbsd_disklabel));
diff --git a/util-linux/more.c b/util-linux/more.c
index a830dcbc1..352a3b6cf 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -65,7 +65,7 @@ static void gotsig(int sig UNUSED_PARAM)
* therefore it is safe in signal handler */
bb_putchar_stderr('\n');
tcsetattr_tty_TCSANOW(&G.initial_settings);
- _exit(EXIT_FAILURE);
+ _exit_FAILURE();
}
#define CONVERTED_TAB_SIZE 8