aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-10 19:46:53 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-10 19:46:53 +0100
commit86e63cdeca93afae43c7d59a863bedccc3ea0c55 (patch)
treeca9dc27dd29726de65761e223d0c1df24ea152f3
parent3a4d5a73a876b0922afed095bc9f83dbdf07148e (diff)
downloadbusybox-w32-86e63cdeca93afae43c7d59a863bedccc3ea0c55.tar.gz
busybox-w32-86e63cdeca93afae43c7d59a863bedccc3ea0c55.tar.bz2
busybox-w32-86e63cdeca93afae43c7d59a863bedccc3ea0c55.zip
bc: in non-interactive config, let compiler know that error funcs do not return
function old new delta bc_num_s 235 239 +4 bc_lex_next 92 91 -1 dc_parse_register 53 51 -2 dc_parse_parse 46 44 -2 bc_vm_run 624 622 -2 bc_program_assignStr 146 144 -2 bc_parse_else 135 133 -2 bc_parse_body 116 114 -2 bc_num_a 445 443 -2 bc_func_insert 97 95 -2 bc_program_pushVar 203 200 -3 bc_parse_text 133 130 -3 bc_error_bad_character 17 14 -3 bc_error 14 11 -3 bc_program_printStream 157 153 -4 bc_program_prep 91 87 -4 bc_program_copyToVar 311 307 -4 bc_num_ulong 95 90 -5 bc_num_p 445 440 -5 bc_program_print 711 704 -7 bc_parse_endBody 365 358 -7 bc_num_r 237 230 -7 bc_num_d 550 543 -7 dc_lex_token 682 674 -8 bc_program_pushArray 147 139 -8 bc_program_assign 485 475 -10 bc_program_read 333 322 -11 bc_lex_token 1278 1266 -12 bc_parse_stmt 1780 1767 -13 bc_program_modexp 723 707 -16 dc_parse_expr 762 744 -18 bc_program_execStr 496 478 -18 bc_program_call 347 329 -18 bc_vm_file 219 197 -22 bc_program_binOpPrep 311 289 -22 bc_parse_name 539 513 -26 bc_parse_parse 451 423 -28 bc_program_num 912 880 -32 bc_read_line 172 139 -33 bc_program_exec 4048 4010 -38 bc_parse_auto 313 275 -38 bc_parse_expr_empty_ok 2095 2036 -59 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/41 up/down: 4/-509) Total: -505 bytes text data bss dec hex filename 983707 485 7296 991488 f2100 busybox_old 983202 485 7296 990983 f1f07 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c65
1 files changed, 39 insertions, 26 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 26ab94cbd..aa478e461 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -976,7 +976,20 @@ static void bc_verror_msg(const char *fmt, va_list p)
976 } 976 }
977} 977}
978 978
979static NOINLINE int bc_error_fmt(const char *fmt, ...) 979#if ENABLE_FEATURE_BC_SIGNALS
980# define ERRORFUNC /*nothing*/
981# define ERROR_RETURN(a) a
982#else
983# if ENABLE_FEATURE_CLEAN_UP
984# define ERRORFUNC /*nothing*/
985# define ERROR_RETURN(a) a
986# else
987# define ERRORFUNC NORETURN
988# define ERROR_RETURN(a) /*nothing*/
989# endif
990#endif
991
992static NOINLINE ERRORFUNC int bc_error_fmt(const char *fmt, ...)
980{ 993{
981 va_list p; 994 va_list p;
982 995
@@ -986,7 +999,7 @@ static NOINLINE int bc_error_fmt(const char *fmt, ...)
986 999
987 if (!ENABLE_FEATURE_CLEAN_UP && !G_ttyin) 1000 if (!ENABLE_FEATURE_CLEAN_UP && !G_ttyin)
988 exit(1); 1001 exit(1);
989 return BC_STATUS_FAILURE; 1002 ERROR_RETURN(return BC_STATUS_FAILURE;)
990} 1003}
991 1004
992#if ENABLE_BC 1005#if ENABLE_BC
@@ -1016,52 +1029,52 @@ static NOINLINE int bc_posix_error_fmt(const char *fmt, ...)
1016// function must not have caller-cleaned parameters on stack. 1029// function must not have caller-cleaned parameters on stack.
1017// Unfortunately, vararg function API does exactly that on most arches. 1030// Unfortunately, vararg function API does exactly that on most arches.
1018// Thus, use these shims for the cases when we have no vararg PARAMS: 1031// Thus, use these shims for the cases when we have no vararg PARAMS:
1019static int bc_error(const char *msg) 1032static ERRORFUNC int bc_error(const char *msg)
1020{ 1033{
1021 return bc_error_fmt("%s", msg); 1034 ERROR_RETURN(return) bc_error_fmt("%s", msg);
1022} 1035}
1023#if ENABLE_BC 1036static ERRORFUNC int bc_error_bad_character(char c)
1024static int bc_POSIX_requires(const char *msg)
1025{ 1037{
1026 return bc_posix_error_fmt("POSIX requires %s", msg); 1038 ERROR_RETURN(return) bc_error_fmt("bad character '%c'", c);
1027} 1039}
1028static int bc_POSIX_does_not_allow(const char *msg) 1040static ERRORFUNC int bc_error_bad_expression(void)
1029{ 1041{
1030 return bc_posix_error_fmt("%s%s", "POSIX does not allow ", msg); 1042 ERROR_RETURN(return) bc_error("bad expression");
1031} 1043}
1032static int bc_POSIX_does_not_allow_bool_ops_this_is_bad(const char *msg) 1044static ERRORFUNC int bc_error_bad_token(void)
1033{ 1045{
1034 return bc_posix_error_fmt("%s%s %s", "POSIX does not allow ", "boolean operators; the following is bad:", msg); 1046 ERROR_RETURN(return) bc_error("bad token");
1035} 1047}
1036static int bc_POSIX_does_not_allow_empty_X_expression_in_for(const char *msg) 1048static ERRORFUNC int bc_error_stack_has_too_few_elements(void)
1037{ 1049{
1038 return bc_posix_error_fmt("%san empty %s expression in a for loop", "POSIX does not allow ", msg); 1050 ERROR_RETURN(return) bc_error("stack has too few elements");
1039} 1051}
1040#endif 1052static ERRORFUNC int bc_error_variable_is_wrong_type(void)
1041static int bc_error_bad_character(char c)
1042{ 1053{
1043 return bc_error_fmt("bad character '%c'", c); 1054 ERROR_RETURN(return) bc_error("variable is wrong type");
1044} 1055}
1045static int bc_error_bad_expression(void) 1056static ERRORFUNC int bc_error_nested_read_call(void)
1046{ 1057{
1047 return bc_error("bad expression"); 1058 ERROR_RETURN(return) bc_error("read() call inside of a read() call");
1048} 1059}
1049static int bc_error_bad_token(void) 1060#if ENABLE_BC
1061static int bc_POSIX_requires(const char *msg)
1050{ 1062{
1051 return bc_error("bad token"); 1063 return bc_posix_error_fmt("POSIX requires %s", msg);
1052} 1064}
1053static int bc_error_stack_has_too_few_elements(void) 1065static int bc_POSIX_does_not_allow(const char *msg)
1054{ 1066{
1055 return bc_error("stack has too few elements"); 1067 return bc_posix_error_fmt("%s%s", "POSIX does not allow ", msg);
1056} 1068}
1057static int bc_error_variable_is_wrong_type(void) 1069static int bc_POSIX_does_not_allow_bool_ops_this_is_bad(const char *msg)
1058{ 1070{
1059 return bc_error("variable is wrong type"); 1071 return bc_posix_error_fmt("%s%s %s", "POSIX does not allow ", "boolean operators; the following is bad:", msg);
1060} 1072}
1061static int bc_error_nested_read_call(void) 1073static int bc_POSIX_does_not_allow_empty_X_expression_in_for(const char *msg)
1062{ 1074{
1063 return bc_error("read() call inside of a read() call"); 1075 return bc_posix_error_fmt("%san empty %s expression in a for loop", "POSIX does not allow ", msg);
1064} 1076}
1077#endif
1065 1078
1066static void bc_vec_grow(BcVec *v, size_t n) 1079static void bc_vec_grow(BcVec *v, size_t n)
1067{ 1080{