Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib/bch.c: use swap() to improve code

Use the swap() macro to simplify the functions solve_linear_system() and
gf_poly_gcd() and improve their readability. Remove the local variable
tmp.

Fixes the following three Coccinelle/coccicheck warnings reported by
swap.cocci:

WARNING opportunity for swap()
WARNING opportunity for swap()
WARNING opportunity for swap()

Link: https://lkml.kernel.org/r/20240708224023.9312-2-thorsten.blum@toblux.com
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Thorsten Blum and committed by
Andrew Morton
e1fb7430 4f5d4a1b

+5 -15
+5 -15
lib/bch.c
··· 479 479 /* find suitable row for elimination */ 480 480 for (r = p; r < m; r++) { 481 481 if (rows[r] & mask) { 482 - if (r != p) { 483 - tmp = rows[r]; 484 - rows[r] = rows[p]; 485 - rows[p] = tmp; 486 - } 482 + if (r != p) 483 + swap(rows[r], rows[p]); 487 484 rem = r+1; 488 485 break; 489 486 } ··· 796 799 static struct gf_poly *gf_poly_gcd(struct bch_control *bch, struct gf_poly *a, 797 800 struct gf_poly *b) 798 801 { 799 - struct gf_poly *tmp; 800 - 801 802 dbg("gcd(%s,%s)=", gf_poly_str(a), gf_poly_str(b)); 802 803 803 - if (a->deg < b->deg) { 804 - tmp = b; 805 - b = a; 806 - a = tmp; 807 - } 804 + if (a->deg < b->deg) 805 + swap(a, b); 808 806 809 807 while (b->deg > 0) { 810 808 gf_poly_mod(bch, a, b, NULL); 811 - tmp = b; 812 - b = a; 813 - a = tmp; 809 + swap(a, b); 814 810 } 815 811 816 812 dbg("%s\n", gf_poly_str(a));