src: Merge assignment with return
PATCH 1/1 src: Merge assignment with return
Merge assignment with return statement to directly return the value. Done using following coccinelle semantic patch
@@
local idexpression ret;
expression e;
@@
-ret =
+return
e;
-return ret;
--- src/mini-gmp.c | 3 +-- src/statement.c | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-)
src/mini-gmp.c +1 -2
@@ -1297,8 +1297,7 @@ mpn_set_str_bits (mp_ptr rp, const unsigned char *sp, size_t sn, } } } - rn =mpn_normalized_size (rp, rn); -return rn; +return mpn_normalized_size (rp, rn); } static mp_size_t
src/statement.c +1 -4
@@ -208,10 +208,7 @@ static const struct stmt_ops objref_stmt_ops = {struct stmt *objref_stmt_alloc (const struct location *loc) { -struct stmt *stmt; - - stmt =stmt_alloc (loc, &objref_stmt_ops); -return stmt; +return stmt_alloc (loc, &objref_stmt_ops); }static const char *syslog_level[LOG_DEBUG +1 ] = {
--
2.11.0
Pablo Neira Ayuso
maintainerHi Harsha,
Quoted 24 lines · Harsha Sharma
Merge assignment with return statement to directly return the value. Done using following coccinelle semantic patch
@@
local idexpression ret;
expression e;
@@(quoted diff) +1
-2-ret = +return e; -return ret;Signed-off-by Harsha Sharma <[email protected]>--- src/mini-gmp.c | 3 +-- src/statement.c | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-)src/mini-gmp.c +0
-0
src/mini-gmp.c mpn_set_str_bits (mp_ptr rp, const unsigned char *sp, size_t sn, · line 1300
Quoted 6 lines
src/mini-gmp.c +1
-2@@ -1297,8 +1297,7 @@ mpn_set_str_bits (mp_ptr rp, const unsigned char *sp, size_t sn, } } } - rn =mpn_normalized_size (rp, rn); -return rn; +return mpn_normalized_size (rp, rn);
mini-gmp.c has been extracted from libgmp sources [1], so either you submit this chunk to them, or you leave this part as is. I would like we just cache a copy of the mini-gmp.c original file.
Probably you can just check if latest stable release of libgmp contains updates for mini-gmp.{c,h} and send us a patch to get in sync with them.
Thanks.