libbb: code shrink: introduce and use [_]exit_SUCCESS()
function old new delta exit_SUCCESS - 7 +7 _exit_SUCCESS - 7 +7 run_pipe 1562 1567 +5 pseudo_exec_argv 399 400 +1 finish 86 87 +1 start_stop_daemon_main 1109 1107 -2 shutdown_on_signal 38 36 -2 runsv_main 1662 1660 -2 redirect 1070 1068 -2 read_line 79 77 -2 pause_and_low_level_reboot 54 52 -2 list_i2c_busses_and_exit 483 481 -2 less_exit 12 10 -2 identify 4123 4121 -2 grep_file 1161 1159 -2 getty_main 1519 1517 -2 fsck_minix_main 2681 2679 -2 free_session 132 130 -2 fdisk_main 4739 4737 -2 clean_up_and_exit 53 51 -2 bsd_select 1566 1564 -2 bb_daemonize_or_rexec 198 196 -2 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 3/17 up/down: 21/-34) Total: -13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
076f5e064f
commit
db5546ca10
@ -519,7 +519,7 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
/* why _exit? the child may have changed the stack,
|
/* why _exit? the child may have changed the stack,
|
||||||
* so "return 0" may do bad things
|
* so "return 0" may do bad things
|
||||||
*/
|
*/
|
||||||
_exit(EXIT_SUCCESS);
|
_exit_SUCCESS();
|
||||||
}
|
}
|
||||||
/* Child */
|
/* Child */
|
||||||
setsid(); /* detach from controlling tty */
|
setsid(); /* detach from controlling tty */
|
||||||
@ -531,7 +531,7 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
*/
|
*/
|
||||||
pid = xvfork();
|
pid = xvfork();
|
||||||
if (pid != 0)
|
if (pid != 0)
|
||||||
_exit(EXIT_SUCCESS); /* Parent */
|
_exit_SUCCESS(); /* Parent */
|
||||||
}
|
}
|
||||||
if (opt & OPT_MAKEPID) {
|
if (opt & OPT_MAKEPID) {
|
||||||
/* User wants _us_ to make the pidfile */
|
/* User wants _us_ to make the pidfile */
|
||||||
|
@ -470,7 +470,7 @@ static int grep_file(FILE *file)
|
|||||||
* "exit immediately with zero status
|
* "exit immediately with zero status
|
||||||
* if any match is found,
|
* if any match is found,
|
||||||
* even if errors were detected" */
|
* even if errors were detected" */
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
}
|
}
|
||||||
/* -l "print filenames with matches": stop after the first match */
|
/* -l "print filenames with matches": stop after the first match */
|
||||||
if (option_mask32 & OPT_l) {
|
if (option_mask32 & OPT_l) {
|
||||||
|
@ -1278,6 +1278,8 @@ void set_task_comm(const char *comm) FAST_FUNC;
|
|||||||
# define re_execed_comm() 0
|
# define re_execed_comm() 0
|
||||||
# define set_task_comm(name) ((void)0)
|
# define set_task_comm(name) ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
void exit_SUCCESS(void) NORETURN FAST_FUNC;
|
||||||
|
void _exit_SUCCESS(void) NORETURN FAST_FUNC;
|
||||||
|
|
||||||
/* Helpers for daemonization.
|
/* Helpers for daemonization.
|
||||||
*
|
*
|
||||||
|
@ -744,7 +744,7 @@ static void pause_and_low_level_reboot(unsigned magic)
|
|||||||
pid = vfork();
|
pid = vfork();
|
||||||
if (pid == 0) { /* child */
|
if (pid == 0) { /* child */
|
||||||
reboot(magic);
|
reboot(magic);
|
||||||
_exit(EXIT_SUCCESS);
|
_exit_SUCCESS();
|
||||||
}
|
}
|
||||||
/* Used to have "while (1) sleep(1)" here.
|
/* Used to have "while (1) sleep(1)" here.
|
||||||
* However, in containers reboot() call is ignored, and with that loop
|
* However, in containers reboot() call is ignored, and with that loop
|
||||||
@ -752,7 +752,7 @@ static void pause_and_low_level_reboot(unsigned magic)
|
|||||||
*/
|
*/
|
||||||
waitpid(pid, NULL, 0);
|
waitpid(pid, NULL, 0);
|
||||||
sleep1(); /* paranoia */
|
sleep1(); /* paranoia */
|
||||||
_exit(EXIT_SUCCESS);
|
_exit_SUCCESS();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_shutdown_and_kill_processes(void)
|
static void run_shutdown_and_kill_processes(void)
|
||||||
@ -942,7 +942,7 @@ static void reload_inittab(void)
|
|||||||
for (a = G.init_action_list; a; a = a->next)
|
for (a = G.init_action_list; a; a = a->next)
|
||||||
if (a->action_type == 0 && a->pid != 0)
|
if (a->action_type == 0 && a->pid != 0)
|
||||||
kill(a->pid, SIGKILL);
|
kill(a->pid, SIGKILL);
|
||||||
_exit(EXIT_SUCCESS);
|
_exit_SUCCESS();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -308,7 +308,7 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv)
|
|||||||
/* fflush_all(); - add it in fork_or_rexec() if necessary */
|
/* fflush_all(); - add it in fork_or_rexec() if necessary */
|
||||||
|
|
||||||
if (fork_or_rexec(argv))
|
if (fork_or_rexec(argv))
|
||||||
_exit(EXIT_SUCCESS); /* parent */
|
_exit_SUCCESS(); /* parent */
|
||||||
/* if daemonizing, detach from stdio & ctty */
|
/* if daemonizing, detach from stdio & ctty */
|
||||||
setsid();
|
setsid();
|
||||||
dup2(fd, 0);
|
dup2(fd, 0);
|
||||||
@ -320,7 +320,7 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv)
|
|||||||
// * Prevent this: stop being a session leader.
|
// * Prevent this: stop being a session leader.
|
||||||
// */
|
// */
|
||||||
// if (fork_or_rexec(argv))
|
// if (fork_or_rexec(argv))
|
||||||
// _exit(EXIT_SUCCESS); /* parent */
|
// _exit_SUCCESS(); /* parent */
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
while (fd > 2) {
|
while (fd > 2) {
|
||||||
|
@ -423,3 +423,13 @@ int FAST_FUNC wait4pid(pid_t pid)
|
|||||||
return WTERMSIG(status) + 0x180;
|
return WTERMSIG(status) + 0x180;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FAST_FUNC exit_SUCCESS(void)
|
||||||
|
{
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FAST_FUNC _exit_SUCCESS(void)
|
||||||
|
{
|
||||||
|
_exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
@ -484,7 +484,7 @@ static char *get_logname(void)
|
|||||||
if (read(STDIN_FILENO, &c, 1) < 1) {
|
if (read(STDIN_FILENO, &c, 1) < 1) {
|
||||||
finalize_tty_attrs();
|
finalize_tty_attrs();
|
||||||
if (errno == EINTR || errno == EIO)
|
if (errno == EINTR || errno == EIO)
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
bb_simple_perror_msg_and_die(bb_msg_read_error);
|
bb_simple_perror_msg_and_die(bb_msg_read_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,7 +511,7 @@ static char *get_logname(void)
|
|||||||
case CTL('C'):
|
case CTL('C'):
|
||||||
case CTL('D'):
|
case CTL('D'):
|
||||||
finalize_tty_attrs();
|
finalize_tty_attrs();
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
case '\0':
|
case '\0':
|
||||||
/* BREAK. If we have speeds to try,
|
/* BREAK. If we have speeds to try,
|
||||||
* return NULL (will switch speeds and return here) */
|
* return NULL (will switch speeds and return here) */
|
||||||
@ -538,7 +538,7 @@ static char *get_logname(void)
|
|||||||
static void alarm_handler(int sig UNUSED_PARAM)
|
static void alarm_handler(int sig UNUSED_PARAM)
|
||||||
{
|
{
|
||||||
finalize_tty_attrs();
|
finalize_tty_attrs();
|
||||||
_exit(EXIT_SUCCESS);
|
_exit_SUCCESS();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sleep10(void)
|
static void sleep10(void)
|
||||||
|
@ -312,7 +312,7 @@ static void alarm_handler(int sig UNUSED_PARAM)
|
|||||||
/* unix API is brain damaged regarding O_NONBLOCK,
|
/* unix API is brain damaged regarding O_NONBLOCK,
|
||||||
* we should undo it, or else we can affect other processes */
|
* we should undo it, or else we can affect other processes */
|
||||||
ndelay_off(STDOUT_FILENO);
|
ndelay_off(STDOUT_FILENO);
|
||||||
_exit(EXIT_SUCCESS);
|
_exit_SUCCESS();
|
||||||
}
|
}
|
||||||
|
|
||||||
int login_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int login_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
|
@ -453,7 +453,7 @@ int devfsd_main(int argc, char **argv)
|
|||||||
DEVFSD_PROTOCOL_REVISION_DAEMON, bb_msg_proto_rev, proto_rev);
|
DEVFSD_PROTOCOL_REVISION_DAEMON, bb_msg_proto_rev, proto_rev);
|
||||||
if (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev)
|
if (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev)
|
||||||
bb_error_msg_and_die("%s mismatch!", bb_msg_proto_rev);
|
bb_error_msg_and_die("%s mismatch!", bb_msg_proto_rev);
|
||||||
exit(EXIT_SUCCESS); /* -v */
|
exit_SUCCESS(); /* -v */
|
||||||
}
|
}
|
||||||
/* Tell kernel we are special(i.e. we get to see hidden entries) */
|
/* Tell kernel we are special(i.e. we get to see hidden entries) */
|
||||||
xioctl(fd, DEVFSDIOC_SET_EVENT_MASK, 0);
|
xioctl(fd, DEVFSDIOC_SET_EVENT_MASK, 0);
|
||||||
@ -474,7 +474,7 @@ int devfsd_main(int argc, char **argv)
|
|||||||
dir_operation(SERVICE, mount_point, 0, NULL);
|
dir_operation(SERVICE, mount_point, 0, NULL);
|
||||||
|
|
||||||
if (ENABLE_DEVFSD_FG_NP && no_polling)
|
if (ENABLE_DEVFSD_FG_NP && no_polling)
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
|
|
||||||
if (ENABLE_DEVFSD_VERBOSE || ENABLE_DEBUG)
|
if (ENABLE_DEVFSD_VERBOSE || ENABLE_DEBUG)
|
||||||
logmode = LOGMODE_BOTH;
|
logmode = LOGMODE_BOTH;
|
||||||
|
@ -1271,7 +1271,7 @@ static void identify(uint16_t *val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1212,7 +1212,7 @@ static void NORETURN list_i2c_busses_and_exit(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void NORETURN no_support(const char *cmd)
|
static void NORETURN no_support(const char *cmd)
|
||||||
|
@ -333,10 +333,10 @@ static void restore_tty(void)
|
|||||||
clear_line();
|
clear_line();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void less_exit(void)
|
static NOINLINE void less_exit(void)
|
||||||
{
|
{
|
||||||
restore_tty();
|
restore_tty();
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (ENABLE_FEATURE_LESS_DASHCMD && ENABLE_FEATURE_LESS_LINENUMS) \
|
#if (ENABLE_FEATURE_LESS_DASHCMD && ENABLE_FEATURE_LESS_LINENUMS) \
|
||||||
|
@ -76,7 +76,7 @@ static void shutdown_on_signal(int sig UNUSED_PARAM)
|
|||||||
{
|
{
|
||||||
remove_pidfile_std_path_and_ext("watchdog");
|
remove_pidfile_std_path_and_ext("watchdog");
|
||||||
shutdown_watchdog();
|
shutdown_watchdog();
|
||||||
_exit(EXIT_SUCCESS);
|
_exit_SUCCESS();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void watchdog_open(const char* device)
|
static void watchdog_open(const char* device)
|
||||||
|
@ -415,7 +415,7 @@ static FAST_FUNC int fileAction(struct recursive_state *state,
|
|||||||
/* Load was successful, there is nothing else to do.
|
/* Load was successful, there is nothing else to do.
|
||||||
* This can happen ONLY for "top-level" module load,
|
* This can happen ONLY for "top-level" module load,
|
||||||
* not a dep, because deps don't do dirscan. */
|
* not a dep, because deps don't do dirscan. */
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ static void finish(void)
|
|||||||
if (option_mask32 & DAD)
|
if (option_mask32 & DAD)
|
||||||
exit(!!received);
|
exit(!!received);
|
||||||
if (option_mask32 & UNSOLICITED)
|
if (option_mask32 & UNSOLICITED)
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
exit(!received);
|
exit(!received);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1208,7 +1208,7 @@ static void clean_up_and_exit(int sig UNUSED_PARAM)
|
|||||||
close(sep->se_fd);
|
close(sep->se_fd);
|
||||||
}
|
}
|
||||||
remove_pidfile_std_path_and_ext("inetd");
|
remove_pidfile_std_path_and_ext("inetd");
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
}
|
}
|
||||||
|
|
||||||
int inetd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int inetd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
|
@ -268,7 +268,7 @@ int nc_main(int argc, char **argv)
|
|||||||
nread = safe_read(pfds[fdidx].fd, iobuf, COMMON_BUFSIZE);
|
nread = safe_read(pfds[fdidx].fd, iobuf, COMMON_BUFSIZE);
|
||||||
if (fdidx != 0) {
|
if (fdidx != 0) {
|
||||||
if (nread < 1)
|
if (nread < 1)
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
ofd = STDOUT_FILENO;
|
ofd = STDOUT_FILENO;
|
||||||
} else {
|
} else {
|
||||||
if (nread < 1) {
|
if (nread < 1) {
|
||||||
|
@ -582,7 +582,7 @@ free_session(struct tsession *ts)
|
|||||||
struct tsession *t;
|
struct tsession *t;
|
||||||
|
|
||||||
if (option_mask32 & OPT_INETD)
|
if (option_mask32 & OPT_INETD)
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
|
|
||||||
/* Unlink this telnet session from the session list */
|
/* Unlink this telnet session from the session list */
|
||||||
t = G.sessions;
|
t = G.sessions;
|
||||||
|
@ -700,7 +700,7 @@ int runsv_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
if (svd[0].sd_want == W_EXIT && svd[0].state == S_DOWN) {
|
if (svd[0].sd_want == W_EXIT && svd[0].state == S_DOWN) {
|
||||||
if (svd[1].pid == 0)
|
if (svd[1].pid == 0)
|
||||||
_exit(EXIT_SUCCESS);
|
_exit_SUCCESS();
|
||||||
if (svd[1].sd_want != W_EXIT) {
|
if (svd[1].sd_want != W_EXIT) {
|
||||||
svd[1].sd_want = W_EXIT;
|
svd[1].sd_want = W_EXIT;
|
||||||
/* stopservice(&svd[1]); */
|
/* stopservice(&svd[1]); */
|
||||||
|
@ -5505,7 +5505,7 @@ openhere(union node *redir)
|
|||||||
ignoresig(SIGTSTP); //signal(SIGTSTP, SIG_IGN);
|
ignoresig(SIGTSTP); //signal(SIGTSTP, SIG_IGN);
|
||||||
signal(SIGPIPE, SIG_DFL);
|
signal(SIGPIPE, SIG_DFL);
|
||||||
xwrite(pip[1], p, len);
|
xwrite(pip[1], p, len);
|
||||||
_exit(EXIT_SUCCESS);
|
_exit_SUCCESS();
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
close(pip[1]);
|
close(pip[1]);
|
||||||
|
@ -8587,7 +8587,7 @@ static NOINLINE void pseudo_exec_argv(nommu_save_t *nommu_save,
|
|||||||
* expand_assignments(): think about ... | var=`sleep 1` | ...
|
* expand_assignments(): think about ... | var=`sleep 1` | ...
|
||||||
*/
|
*/
|
||||||
free_strings(new_env);
|
free_strings(new_env);
|
||||||
_exit(EXIT_SUCCESS);
|
_exit_SUCCESS();
|
||||||
}
|
}
|
||||||
|
|
||||||
sv_shadowed = G.shadowed_vars_pp;
|
sv_shadowed = G.shadowed_vars_pp;
|
||||||
@ -8768,7 +8768,7 @@ static void pseudo_exec(nommu_save_t *nommu_save,
|
|||||||
|
|
||||||
/* Case when we are here: ... | >file */
|
/* Case when we are here: ... | >file */
|
||||||
debug_printf_exec("pseudo_exec'ed null command\n");
|
debug_printf_exec("pseudo_exec'ed null command\n");
|
||||||
_exit(EXIT_SUCCESS);
|
_exit_SUCCESS();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_HUSH_JOB
|
#if ENABLE_HUSH_JOB
|
||||||
|
@ -665,7 +665,7 @@ read_line(const char *prompt)
|
|||||||
|
|
||||||
sz = read_line_input(NULL, prompt, line_buffer, sizeof(line_buffer));
|
sz = read_line_input(NULL, prompt, line_buffer, sizeof(line_buffer));
|
||||||
if (sz <= 0)
|
if (sz <= 0)
|
||||||
exit(EXIT_SUCCESS); /* Ctrl-D or Ctrl-C */
|
exit_SUCCESS(); /* Ctrl-D or Ctrl-C */
|
||||||
|
|
||||||
if (line_buffer[sz-1] == '\n')
|
if (line_buffer[sz-1] == '\n')
|
||||||
line_buffer[--sz] = '\0';
|
line_buffer[--sz] = '\0';
|
||||||
@ -2855,7 +2855,7 @@ xselect(void)
|
|||||||
if (ENABLE_FEATURE_CLEAN_UP)
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
close_dev_fd();
|
close_dev_fd();
|
||||||
bb_putchar('\n');
|
bb_putchar('\n');
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
case 'r':
|
case 'r':
|
||||||
return;
|
return;
|
||||||
case 's':
|
case 's':
|
||||||
|
@ -383,7 +383,7 @@ bsd_select(void)
|
|||||||
|
|
||||||
if (xbsd_readlabel(NULL) == 0)
|
if (xbsd_readlabel(NULL) == 0)
|
||||||
if (xbsd_create_disklabel() == 0)
|
if (xbsd_create_disklabel() == 0)
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -411,7 +411,7 @@ bsd_select(void)
|
|||||||
case 'q':
|
case 'q':
|
||||||
if (ENABLE_FEATURE_CLEAN_UP)
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
close_dev_fd();
|
close_dev_fd();
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
case 'r':
|
case 'r':
|
||||||
return;
|
return;
|
||||||
case 's':
|
case 's':
|
||||||
|
@ -423,7 +423,7 @@ static void check_mount(void)
|
|||||||
cont = ask("Do you really want to continue", 0);
|
cont = ask("Do you really want to continue", 0);
|
||||||
if (!cont) {
|
if (!cont) {
|
||||||
puts("Check aborted");
|
puts("Check aborted");
|
||||||
exit(EXIT_SUCCESS);
|
exit_SUCCESS();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user