CC: [email protected]
CC: [email protected]
TO: Denis Efremov <[email protected]>
CC: Julia Lawall <[email protected]>
CC: [email protected]

From: kernel test robot <[email protected]>

lib/bch.c:842:7-8: WARNING opportunity for swap()
lib/bch.c:849:7-8: WARNING opportunity for swap()
lib/bch.c:518:22-23: WARNING opportunity for swap()


 Check for opencoded swap() implementation.

Generated by: scripts/coccinelle/misc/swap.cocci

CC: Denis Efremov <[email protected]>
Reported-by: kernel test robot <[email protected]>
Signed-off-by: kernel test robot <[email protected]>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   cd8c917a56f20f48748dd43d9ae3caff51d5b987
commit: 7845daa8bd72efa8bbc1de122edfce6e058bbe41 coccinelle: misc: add swap 
script
:::::: branch date: 10 hours ago
:::::: commit date: 7 months ago

Please take the patch only if it's a positive warning. Thanks!

 bch.c |   20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

--- a/lib/bch.c
+++ b/lib/bch.c
@@ -513,11 +513,9 @@ static int solve_linear_system(struct bc
                /* find suitable row for elimination */
                for (r = p; r < m; r++) {
                        if (rows[r] & mask) {
-                               if (r != p) {
-                                       tmp = rows[r];
-                                       rows[r] = rows[p];
-                                       rows[p] = tmp;
-                               }
+                               if (r != p)
+                                       
+                                       swap(rows[r], rows[p]);
                                rem = r+1;
                                break;
                        }
@@ -837,17 +835,13 @@ static struct gf_poly *gf_poly_gcd(struc
 
        dbg("gcd(%s,%s)=", gf_poly_str(a), gf_poly_str(b));
 
-       if (a->deg < b->deg) {
-               tmp = b;
-               b = a;
-               a = tmp;
-       }
+       if (a->deg < b->deg)
+               
+               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));
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to