mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] lib/bch:using swap() instead of tmp variable
@ 2021-11-09  6:32 Yihao Han
  2021-11-10 11:32 ` kernel test robot
  0 siblings, 1 reply; 3+ messages in thread
From: Yihao Han @ 2021-11-09  6:32 UTC (permalink / raw)
  To: Yihao Han, Randy Dunlap, Andrew Morton, Bhaskar Chowdhury, linux-kernel
  Cc: kernel

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


^ permalink raw reply	[flat|nested] 3+ messages in thread
* [PATCH] lib/bch:using swap() instead of tmp variable
@ 2021-11-09  6:18 Yihao Han
  0 siblings, 0 replies; 3+ messages in thread
From: Yihao Han @ 2021-11-09  6:18 UTC (permalink / raw)
  To: Yihao Han, Bhaskar Chowdhury, Randy Dunlap, Andrew Morton, linux-kernel
  Cc: kernel

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..0d6a2942ad20 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-10 11:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-09  6:32 [PATCH] lib/bch:using swap() instead of tmp variable Yihao Han
2021-11-10 11:32 ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2021-11-09  6:18 Yihao Han

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®