Skip to contentSkip to conversation

coccinelle: misc: fix swap.cocci warnings

PATCH kernel test robot 1 participant 1 message Dec 12, 2021

Subsystems (2)
lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Denis Efremov <[email protected]>
CC: Julia Lawall <[email protected]>
CC: Thomas Winischhofer <[email protected]>
CC: dri-devel(a)lists.freedesktop.org
CC: linux-fbdev(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org

From: kernel test robot <[email protected]>

drivers/video/fbdev/sis/sis_main.c:216:26-27: WARNING opportunity for swap()

Check for opencoded swap() implementation.

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

---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   bbdff6d583be718935b613ab2a966cddaadf661f
commit: 7845daa8bd72efa8bbc1de122edfce6e058bbe41 coccinelle: misc: add swap script

:::::: branch date: 3 hours ago
:::::: commit date: 7 months ago

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

 sis_main.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/video/fbdev/sis/sis_main.c +3 -3
@@ -212,9 +212,9 @@ static void sisfb_search_mode(char *name
 
 		/* This does some fuzzy mode naming detection */
 		if(sscanf(strbuf1, "%u %u %u %u", &xres, &yres, &depth, &rate) == 4) {
-			if((rate <= 32) || (depth > 32)) {
-				j = rate; rate = depth; depth = j;
-			}
+			if((rate <= 32) || (depth > 32))
+				
+				swap(rate, depth);
 			sprintf(strbuf, "%ux%ux%u", xres, yres, depth);
 			nameptr = strbuf;
 			sisfb_parm_rate = rate;