aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2022-01-04 23:31:58 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2022-01-04 23:31:58 +0100
commit31f45c1b369bee73843f7d791313423997618448 (patch)
treefa9f646727563392e34c9065d2cb3a46c5c731d0
parent286b33721d5f6afd615f752ea83bbd72658c6bb9 (diff)
downloadbusybox-w32-31f45c1b369bee73843f7d791313423997618448.tar.gz
busybox-w32-31f45c1b369bee73843f7d791313423997618448.tar.bz2
busybox-w32-31f45c1b369bee73843f7d791313423997618448.zip
libbb: factor out fflush_stdout_and_exit(EXIT_SUCCESS)
function old new delta fflush_stdout_and_exit_SUCCESS - 7 +7 xxd_main 890 888 -2 vlock_main 353 351 -2 uuencode_main 318 316 -2 uniq_main 427 425 -2 uname_main 250 248 -2 sort_main 853 851 -2 shuf_main 500 498 -2 route_main 238 236 -2 readlink_main 113 111 -2 nice_main 156 154 -2 last_main 957 955 -2 ipcs_main 960 958 -2 env_main 209 207 -2 chrt_main 464 462 -2 cal_main 921 919 -2 baseNUM_main 650 648 -2 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/16 up/down: 7/-32) Total: -25 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/env.c2
-rw-r--r--coreutils/nice.c2
-rw-r--r--coreutils/readlink.c2
-rw-r--r--coreutils/shuf.c2
-rw-r--r--coreutils/sort.c2
-rw-r--r--coreutils/uname.c2
-rw-r--r--coreutils/uniq.c2
-rw-r--r--coreutils/uudecode.c2
-rw-r--r--coreutils/uuencode.c2
-rw-r--r--include/libbb.h1
-rw-r--r--libbb/fflush_stdout_and_exit.c5
-rw-r--r--loginutils/vlock.c2
-rw-r--r--networking/route.c2
-rw-r--r--sysklogd/logread.c2
-rw-r--r--util-linux/cal.c2
-rw-r--r--util-linux/chrt.c2
-rw-r--r--util-linux/hexdump_xxd.c2
-rw-r--r--util-linux/ipcs.c8
-rw-r--r--util-linux/last.c2
-rw-r--r--util-linux/last_fancy.c2
20 files changed, 27 insertions, 21 deletions
diff --git a/coreutils/env.c b/coreutils/env.c
index a0ea4dd27..6eafd06ef 100644
--- a/coreutils/env.c
+++ b/coreutils/env.c
@@ -100,7 +100,7 @@ int env_main(int argc UNUSED_PARAM, char **argv)
100 } 100 }
101 } 101 }
102 102
103 fflush_stdout_and_exit(EXIT_SUCCESS); 103 fflush_stdout_and_exit_SUCCESS();
104} 104}
105 105
106/* 106/*
diff --git a/coreutils/nice.c b/coreutils/nice.c
index 28591ac61..e70da5d2b 100644
--- a/coreutils/nice.c
+++ b/coreutils/nice.c
@@ -33,7 +33,7 @@ int nice_main(int argc UNUSED_PARAM, char **argv)
33 33
34 if (!*++argv) { /* No args, so (GNU) output current nice value. */ 34 if (!*++argv) { /* No args, so (GNU) output current nice value. */
35 printf("%d\n", old_priority); 35 printf("%d\n", old_priority);
36 fflush_stdout_and_exit(EXIT_SUCCESS); 36 fflush_stdout_and_exit_SUCCESS();
37 } 37 }
38 38
39 adjustment = 10; /* Set default adjustment. */ 39 adjustment = 10; /* Set default adjustment. */
diff --git a/coreutils/readlink.c b/coreutils/readlink.c
index 09d69df2b..b2e867883 100644
--- a/coreutils/readlink.c
+++ b/coreutils/readlink.c
@@ -96,5 +96,5 @@ int readlink_main(int argc UNUSED_PARAM, char **argv)
96 printf((opt & 2) ? "%s" : "%s\n", buf); 96 printf((opt & 2) ? "%s" : "%s\n", buf);
97 free(buf); 97 free(buf);
98 98
99 fflush_stdout_and_exit(EXIT_SUCCESS); 99 fflush_stdout_and_exit_SUCCESS();
100} 100}
diff --git a/coreutils/shuf.c b/coreutils/shuf.c
index 3def3d80f..337366b45 100644
--- a/coreutils/shuf.c
+++ b/coreutils/shuf.c
@@ -171,5 +171,5 @@ int shuf_main(int argc, char **argv)
171 printf("%s%c", lines[i], eol); 171 printf("%s%c", lines[i], eol);
172 } 172 }
173 173
174 fflush_stdout_and_exit(EXIT_SUCCESS); 174 fflush_stdout_and_exit_SUCCESS();
175} 175}
diff --git a/coreutils/sort.c b/coreutils/sort.c
index 32a06e40a..0cbb6f597 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -644,5 +644,5 @@ int sort_main(int argc UNUSED_PARAM, char **argv)
644 printf("%s%c", lines[i], ch); 644 printf("%s%c", lines[i], ch);
645 } 645 }
646 646
647 fflush_stdout_and_exit(EXIT_SUCCESS); 647 fflush_stdout_and_exit_SUCCESS();
648} 648}
diff --git a/coreutils/uname.c b/coreutils/uname.c
index da785ab4c..6c0bdf096 100644
--- a/coreutils/uname.c
+++ b/coreutils/uname.c
@@ -209,5 +209,5 @@ int uname_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
209#endif 209#endif
210 } 210 }
211 211
212 fflush_stdout_and_exit(EXIT_SUCCESS); /* coreutils-6.9 compat */ 212 fflush_stdout_and_exit_SUCCESS(); /* coreutils-6.9 compat */
213} 213}
diff --git a/coreutils/uniq.c b/coreutils/uniq.c
index a3058ac07..06c57f750 100644
--- a/coreutils/uniq.c
+++ b/coreutils/uniq.c
@@ -139,5 +139,5 @@ int uniq_main(int argc UNUSED_PARAM, char **argv)
139 139
140 die_if_ferror(stdin, input_filename); 140 die_if_ferror(stdin, input_filename);
141 141
142 fflush_stdout_and_exit(EXIT_SUCCESS); 142 fflush_stdout_and_exit_SUCCESS();
143} 143}
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c
index e90902f52..63a8d4d48 100644
--- a/coreutils/uudecode.c
+++ b/coreutils/uudecode.c
@@ -352,7 +352,7 @@ int baseNUM_main(int argc UNUSED_PARAM, char **argv)
352#undef src_buf 352#undef src_buf
353 } 353 }
354 354
355 fflush_stdout_and_exit(EXIT_SUCCESS); 355 fflush_stdout_and_exit_SUCCESS();
356} 356}
357#endif 357#endif
358 358
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c
index db49ec80a..f096e3122 100644
--- a/coreutils/uuencode.c
+++ b/coreutils/uuencode.c
@@ -78,5 +78,5 @@ int uuencode_main(int argc UNUSED_PARAM, char **argv)
78 } 78 }
79 printf(tbl == bb_uuenc_tbl_std ? "\n`\nend\n" : "\n====\n"); 79 printf(tbl == bb_uuenc_tbl_std ? "\n`\nend\n" : "\n====\n");
80 80
81 fflush_stdout_and_exit(EXIT_SUCCESS); 81 fflush_stdout_and_exit_SUCCESS();
82} 82}
diff --git a/include/libbb.h b/include/libbb.h
index a48782832..8308d6259 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1054,6 +1054,7 @@ void die_if_ferror(FILE *file, const char *msg) FAST_FUNC;
1054void die_if_ferror_stdout(void) FAST_FUNC; 1054void die_if_ferror_stdout(void) FAST_FUNC;
1055int fflush_all(void) FAST_FUNC; 1055int fflush_all(void) FAST_FUNC;
1056void fflush_stdout_and_exit(int retval) NORETURN FAST_FUNC; 1056void fflush_stdout_and_exit(int retval) NORETURN FAST_FUNC;
1057void fflush_stdout_and_exit_SUCCESS(void) NORETURN FAST_FUNC;
1057int fclose_if_not_stdin(FILE *file) FAST_FUNC; 1058int fclose_if_not_stdin(FILE *file) FAST_FUNC;
1058FILE* xfopen(const char *filename, const char *mode) FAST_FUNC; 1059FILE* xfopen(const char *filename, const char *mode) FAST_FUNC;
1059/* Prints warning to stderr and returns NULL on failure: */ 1060/* Prints warning to stderr and returns NULL on failure: */
diff --git a/libbb/fflush_stdout_and_exit.c b/libbb/fflush_stdout_and_exit.c
index 5df74170e..5a13ebcf8 100644
--- a/libbb/fflush_stdout_and_exit.c
+++ b/libbb/fflush_stdout_and_exit.c
@@ -20,3 +20,8 @@ void FAST_FUNC fflush_stdout_and_exit(int retval)
20 * but use xfunc_die() */ 20 * but use xfunc_die() */
21 xfunc_die(); 21 xfunc_die();
22} 22}
23
24void FAST_FUNC fflush_stdout_and_exit_SUCCESS(void)
25{
26 fflush_stdout_and_exit(EXIT_SUCCESS);
27}
diff --git a/loginutils/vlock.c b/loginutils/vlock.c
index 334b7d2ad..720835c4b 100644
--- a/loginutils/vlock.c
+++ b/loginutils/vlock.c
@@ -128,5 +128,5 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
128 ioctl(STDIN_FILENO, VT_SETMODE, &ovtm); 128 ioctl(STDIN_FILENO, VT_SETMODE, &ovtm);
129#endif 129#endif
130 tcsetattr_stdin_TCSANOW(&oterm); 130 tcsetattr_stdin_TCSANOW(&oterm);
131 fflush_stdout_and_exit(EXIT_SUCCESS); 131 fflush_stdout_and_exit_SUCCESS();
132} 132}
diff --git a/networking/route.c b/networking/route.c
index ff5daa8a7..26146f8e9 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -702,7 +702,7 @@ int route_main(int argc UNUSED_PARAM, char **argv)
702#endif 702#endif
703 bb_displayroutes(noresolve, opt & ROUTE_OPT_e); 703 bb_displayroutes(noresolve, opt & ROUTE_OPT_e);
704 704
705 fflush_stdout_and_exit(EXIT_SUCCESS); 705 fflush_stdout_and_exit_SUCCESS();
706 } 706 }
707 707
708 /* Check verb. At the moment, must be add, del, or delete. */ 708 /* Check verb. At the moment, must be add, del, or delete. */
diff --git a/sysklogd/logread.c b/sysklogd/logread.c
index d5f8ca0a2..e6cfcf4a7 100644
--- a/sysklogd/logread.c
+++ b/sysklogd/logread.c
@@ -226,5 +226,5 @@ int logread_main(int argc UNUSED_PARAM, char **argv)
226 226
227 /* shmdt(shbuf); - on Linux, shmdt is not mandatory on exit */ 227 /* shmdt(shbuf); - on Linux, shmdt is not mandatory on exit */
228 228
229 fflush_stdout_and_exit(EXIT_SUCCESS); 229 fflush_stdout_and_exit_SUCCESS();
230} 230}
diff --git a/util-linux/cal.c b/util-linux/cal.c
index 6ba6ebf98..522ab3476 100644
--- a/util-linux/cal.c
+++ b/util-linux/cal.c
@@ -233,7 +233,7 @@ int cal_main(int argc UNUSED_PARAM, char **argv)
233 } 233 }
234 } 234 }
235 235
236 fflush_stdout_and_exit(EXIT_SUCCESS); 236 fflush_stdout_and_exit_SUCCESS();
237} 237}
238 238
239/* 239/*
diff --git a/util-linux/chrt.c b/util-linux/chrt.c
index 6799abb2d..be96fa426 100644
--- a/util-linux/chrt.c
+++ b/util-linux/chrt.c
@@ -110,7 +110,7 @@ int chrt_main(int argc UNUSED_PARAM, char **argv)
110 show_min_max(SCHED_RR); 110 show_min_max(SCHED_RR);
111 show_min_max(SCHED_BATCH); 111 show_min_max(SCHED_BATCH);
112 show_min_max(SCHED_IDLE); 112 show_min_max(SCHED_IDLE);
113 fflush_stdout_and_exit(EXIT_SUCCESS); 113 fflush_stdout_and_exit_SUCCESS();
114 } 114 }
115 //if (opt & OPT_r) 115 //if (opt & OPT_r)
116 // policy = SCHED_RR; - default, already set 116 // policy = SCHED_RR; - default, already set
diff --git a/util-linux/hexdump_xxd.c b/util-linux/hexdump_xxd.c
index 76dada983..4372ac770 100644
--- a/util-linux/hexdump_xxd.c
+++ b/util-linux/hexdump_xxd.c
@@ -150,7 +150,7 @@ static void reverse(unsigned opt, const char *filename)
150 free(buf); 150 free(buf);
151 } 151 }
152 //fclose(fp); 152 //fclose(fp);
153 fflush_stdout_and_exit(EXIT_SUCCESS); 153 fflush_stdout_and_exit_SUCCESS();
154} 154}
155 155
156static void print_C_style(const char *p, const char *hdr) 156static void print_C_style(const char *p, const char *hdr)
diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c
index ef2529c05..5973cbf57 100644
--- a/util-linux/ipcs.c
+++ b/util-linux/ipcs.c
@@ -600,15 +600,15 @@ int ipcs_main(int argc UNUSED_PARAM, char **argv)
600 id = xatoi(opt_i); 600 id = xatoi(opt_i);
601 if (opt & flag_shm) { 601 if (opt & flag_shm) {
602 print_shm(id); 602 print_shm(id);
603 fflush_stdout_and_exit(EXIT_SUCCESS); 603 fflush_stdout_and_exit_SUCCESS();
604 } 604 }
605 if (opt & flag_sem) { 605 if (opt & flag_sem) {
606 print_sem(id); 606 print_sem(id);
607 fflush_stdout_and_exit(EXIT_SUCCESS); 607 fflush_stdout_and_exit_SUCCESS();
608 } 608 }
609 if (opt & flag_msg) { 609 if (opt & flag_msg) {
610 print_msg(id); 610 print_msg(id);
611 fflush_stdout_and_exit(EXIT_SUCCESS); 611 fflush_stdout_and_exit_SUCCESS();
612 } 612 }
613 bb_show_usage(); 613 bb_show_usage();
614 } 614 }
@@ -633,5 +633,5 @@ int ipcs_main(int argc UNUSED_PARAM, char **argv)
633 do_sem(format); 633 do_sem(format);
634 bb_putchar('\n'); 634 bb_putchar('\n');
635 } 635 }
636 fflush_stdout_and_exit(EXIT_SUCCESS); 636 fflush_stdout_and_exit_SUCCESS();
637} 637}
diff --git a/util-linux/last.c b/util-linux/last.c
index 24ce7a8d8..63751ca45 100644
--- a/util-linux/last.c
+++ b/util-linux/last.c
@@ -162,5 +162,5 @@ int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
162 xlseek(file, pos, SEEK_SET); 162 xlseek(file, pos, SEEK_SET);
163 } 163 }
164 164
165 fflush_stdout_and_exit(EXIT_SUCCESS); 165 fflush_stdout_and_exit_SUCCESS();
166} 166}
diff --git a/util-linux/last_fancy.c b/util-linux/last_fancy.c
index e56e0ba85..648236229 100644
--- a/util-linux/last_fancy.c
+++ b/util-linux/last_fancy.c
@@ -296,5 +296,5 @@ int last_main(int argc UNUSED_PARAM, char **argv)
296 296
297 if (ENABLE_FEATURE_CLEAN_UP) 297 if (ENABLE_FEATURE_CLEAN_UP)
298 close(file); 298 close(file);
299 fflush_stdout_and_exit(EXIT_SUCCESS); 299 fflush_stdout_and_exit_SUCCESS();
300} 300}