summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2018-12-10 19:46:53 +0100
committerDenys Vlasenko2018-12-10 19:46:53 +0100
commit86e63cdeca93afae43c7d59a863bedccc3ea0c55 (patch)
treeca9dc27dd29726de65761e223d0c1df24ea152f3
parent3a4d5a73a876b0922afed095bc9f83dbdf07148e (diff)
downloadbusybox-86e63cdeca93afae43c7d59a863bedccc3ea0c55.zip
busybox-86e63cdeca93afae43c7d59a863bedccc3ea0c55.tar.gz
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 26ab94c..aa478e4 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -976,7 +976,20 @@ static void bc_verror_msg(const char *fmt, va_list p)
}
}
-static NOINLINE int bc_error_fmt(const char *fmt, ...)
+#if ENABLE_FEATURE_BC_SIGNALS
+# define ERRORFUNC /*nothing*/
+# define ERROR_RETURN(a) a
+#else
+# if ENABLE_FEATURE_CLEAN_UP
+# define ERRORFUNC /*nothing*/
+# define ERROR_RETURN(a) a
+# else
+# define ERRORFUNC NORETURN
+# define ERROR_RETURN(a) /*nothing*/
+# endif
+#endif
+
+static NOINLINE ERRORFUNC int bc_error_fmt(const char *fmt, ...)
{
va_list p;
@@ -986,7 +999,7 @@ static NOINLINE int bc_error_fmt(const char *fmt, ...)
if (!ENABLE_FEATURE_CLEAN_UP && !G_ttyin)
exit(1);
- return BC_STATUS_FAILURE;
+ ERROR_RETURN(return BC_STATUS_FAILURE;)
}
#if ENABLE_BC
@@ -1016,52 +1029,52 @@ static NOINLINE int bc_posix_error_fmt(const char *fmt, ...)
// function must not have caller-cleaned parameters on stack.
// Unfortunately, vararg function API does exactly that on most arches.
// Thus, use these shims for the cases when we have no vararg PARAMS:
-static int bc_error(const char *msg)
+static ERRORFUNC int bc_error(const char *msg)
{
- return bc_error_fmt("%s", msg);
+ ERROR_RETURN(return) bc_error_fmt("%s", msg);
}
-#if ENABLE_BC
-static int bc_POSIX_requires(const char *msg)
+static ERRORFUNC int bc_error_bad_character(char c)
{
- return bc_posix_error_fmt("POSIX requires %s", msg);
+ ERROR_RETURN(return) bc_error_fmt("bad character '%c'", c);
}
-static int bc_POSIX_does_not_allow(const char *msg)
+static ERRORFUNC int bc_error_bad_expression(void)
{
- return bc_posix_error_fmt("%s%s", "POSIX does not allow ", msg);
+ ERROR_RETURN(return) bc_error("bad expression");
}
-static int bc_POSIX_does_not_allow_bool_ops_this_is_bad(const char *msg)
+static ERRORFUNC int bc_error_bad_token(void)
{
- return bc_posix_error_fmt("%s%s %s", "POSIX does not allow ", "boolean operators; the following is bad:", msg);
+ ERROR_RETURN(return) bc_error("bad token");
}
-static int bc_POSIX_does_not_allow_empty_X_expression_in_for(const char *msg)
+static ERRORFUNC int bc_error_stack_has_too_few_elements(void)
{
- return bc_posix_error_fmt("%san empty %s expression in a for loop", "POSIX does not allow ", msg);
+ ERROR_RETURN(return) bc_error("stack has too few elements");
}
-#endif
-static int bc_error_bad_character(char c)
+static ERRORFUNC int bc_error_variable_is_wrong_type(void)
{
- return bc_error_fmt("bad character '%c'", c);
+ ERROR_RETURN(return) bc_error("variable is wrong type");
}
-static int bc_error_bad_expression(void)
+static ERRORFUNC int bc_error_nested_read_call(void)
{
- return bc_error("bad expression");
+ ERROR_RETURN(return) bc_error("read() call inside of a read() call");
}
-static int bc_error_bad_token(void)
+#if ENABLE_BC
+static int bc_POSIX_requires(const char *msg)
{
- return bc_error("bad token");
+ return bc_posix_error_fmt("POSIX requires %s", msg);
}
-static int bc_error_stack_has_too_few_elements(void)
+static int bc_POSIX_does_not_allow(const char *msg)
{
- return bc_error("stack has too few elements");
+ return bc_posix_error_fmt("%s%s", "POSIX does not allow ", msg);
}
-static int bc_error_variable_is_wrong_type(void)
+static int bc_POSIX_does_not_allow_bool_ops_this_is_bad(const char *msg)
{
- return bc_error("variable is wrong type");
+ return bc_posix_error_fmt("%s%s %s", "POSIX does not allow ", "boolean operators; the following is bad:", msg);
}
-static int bc_error_nested_read_call(void)
+static int bc_POSIX_does_not_allow_empty_X_expression_in_for(const char *msg)
{
- return bc_error("read() call inside of a read() call");
+ return bc_posix_error_fmt("%san empty %s expression in a for loop", "POSIX does not allow ", msg);
}
+#endif
static void bc_vec_grow(BcVec *v, size_t n)
{