From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============8951434724563875354==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: misc: fix swap.cocci warnings Date: Mon, 31 Jan 2022 20:13:24 +0800 Message-ID: <20220131121324.GA55098@a436543d8a13> In-Reply-To: <202201312002.gljszrs9-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============8951434724563875354== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov CC: Julia Lawall CC: linux-kernel(a)vger.kernel.org From: kernel test robot 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 Reported-by: kernel test robot Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git = master head: 26291c54e111ff6ba87a164d85d4a4e134b7315c commit: 7845daa8bd72efa8bbc1de122edfce6e058bbe41 coccinelle: misc: add swap= script :::::: branch date: 23 hours ago :::::: commit date: 9 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 =3D p; r < m; r++) { if (rows[r] & mask) { - if (r !=3D p) { - tmp =3D rows[r]; - rows[r] =3D rows[p]; - rows[p] =3D tmp; - } + if (r !=3D p) + = + swap(rows[r], rows[p]); rem =3D r+1; break; } @@ -837,17 +835,13 @@ static struct gf_poly *gf_poly_gcd(struc = dbg("gcd(%s,%s)=3D", gf_poly_str@, gf_poly_str(b)); = - if (a->deg < b->deg) { - tmp =3D b; - b =3D a; - a =3D tmp; - } + if (a->deg < b->deg) + = + swap(b, a); = while (b->deg > 0) { gf_poly_mod(bch, a, b, NULL); - tmp =3D b; - b =3D a; - a =3D tmp; + swap(b, a); } = dbg("%s\n", gf_poly_str(a)); --===============8951434724563875354==--