lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211109063251.11215-1-hanyihao@vivo.com>
Date:   Mon,  8 Nov 2021 22:32:49 -0800
From:   Yihao Han <hanyihao@...o.com>
To:     Yihao Han <hanyihao@...o.com>,
        Randy Dunlap <rdunlap@...radead.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Bhaskar Chowdhury <unixbhaskar@...il.com>,
        linux-kernel@...r.kernel.org
Cc:     kernel@...o.com
Subject: [PATCH] lib/bch:using swap() instead of tmp variable

swap() was used instead of the tmp variable to swap values

Signed-off-by: Yihao Han <hanyihao@...o.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ