lkml.org 
[lkml]   [2021]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] lib/bch:using swap() instead of tmp variable
Date
swap() was used instead of the tmp variable to swap values

Signed-off-by: Yihao Han <hanyihao@vivo.com>
---
lib/bch.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/lib/bch.c b/lib/bch.c
index c8095f30f254..1c4ddb2d845c 100644
--- a/lib/bch.c
+++ b/lib/bch.c
@@ -500,7 +500,7 @@ static int solve_linear_system(struct bch_control *bch, unsigned int *rows,
unsigned int *sol, int nsol)
{
const int m = GF_M(bch);
- unsigned int tmp, mask;
+ unsigned int mask;
int rem, c, r, p, k, param[BCH_MAX_M];

k = 0;
@@ -514,9 +514,7 @@ static int solve_linear_system(struct bch_control *bch, unsigned int *rows,
for (r = p; r < m; r++) {
if (rows[r] & mask) {
if (r != p) {
- tmp = rows[r];
- rows[r] = rows[p];
- rows[p] = tmp;
+ swap(rows[r], rows[p]);
}
rem = r+1;
break;
@@ -833,21 +831,15 @@ static void gf_poly_div(struct bch_control *bch, struct gf_poly *a,
static struct gf_poly *gf_poly_gcd(struct bch_control *bch, struct gf_poly *a,
struct gf_poly *b)
{
- struct gf_poly *tmp;
-
dbg("gcd(%s,%s)=", gf_poly_str(a), gf_poly_str(b));

if (a->deg < b->deg) {
- tmp = b;
- b = a;
- a = tmp;
+ swap(b, a);
}

while (b->deg > 0) {
gf_poly_mod(bch, a, b, NULL);
- tmp = b;
- b = a;
- a = tmp;
+ swap(b, a);
}

dbg("%s\n", gf_poly_str(a));
--
2.17.1
\
 
 \ /
  Last update: 2021-11-09 07:33    [W:0.035 / U:23.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site