sibyte: pointless if tests

Message ID 2cf0b77f51b907969ae83993854773961b4e159c.camel@perches.com
State New
Headers
Series sibyte: pointless if tests |

Commit Message

Joe Perches Feb. 24, 2024, 10:28 p.m. UTC
  A checkpatch modification was suggested privately about
braces around an if test like

	if (foo)
		;

so I thought I'd see how many of these possibly pointless
if tests exist.  There aren't many.

Here are a couple in sibyte:

Maybe this should be documented as:

	"well, don't know what to do here"

$ cat if_semi.cocci
@@
expression e;
@@

*	if (e) ;

$ spatch --very-quiet -sp-file if_semi.cocci .
  

Comments

Philippe Mathieu-Daudé Feb. 28, 2024, 11:52 a.m. UTC | #1
On 24/2/24 23:28, Joe Perches wrote:
> A checkpatch modification was suggested privately about
> braces around an if test like
> 
> 	if (foo)
> 		;
> 
> so I thought I'd see how many of these possibly pointless
> if tests exist.  There aren't many.
> 
> Here are a couple in sibyte:
> 
> Maybe this should be documented as:
> 
> 	"well, don't know what to do here"

Or pr_devel() / pr_warn() if you want someone to notice it :)

> 
> $ cat if_semi.cocci
> @@
> expression e;
> @@
> 
> *	if (e) ;
> 
> $ spatch --very-quiet -sp-file if_semi.cocci .
> diff -u -p ./arch/mips/sibyte/common/cfe_console.c /tmp/nothing/arch/mips/sibyte/common/cfe_console.c
> --- ./arch/mips/sibyte/common/cfe_console.c
> +++ /tmp/nothing/arch/mips/sibyte/common/cfe_console.c
> @@ -22,8 +22,6 @@ static void cfe_console_write(struct con
>   		if (str[i] == '\n') {
>   			do {
>   				written = cfe_write(cfe_cons_handle, &str[last], i-last);
> -				if (written < 0)
> -					;
>   				last += written;
>   			} while (last < i);
>   			while (cfe_write(cfe_cons_handle, "\r", 1) <= 0)
> @@ -33,8 +31,6 @@ static void cfe_console_write(struct con
>   	if (last != count) {
>   		do {
>   			written = cfe_write(cfe_cons_handle, &str[last], count-last);
> -			if (written < 0)
> -				;
>   			last += written;
>   		} while (last < count);
>   	}
>
  

Patch

diff -u -p ./arch/mips/sibyte/common/cfe_console.c /tmp/nothing/arch/mips/sibyte/common/cfe_console.c
--- ./arch/mips/sibyte/common/cfe_console.c
+++ /tmp/nothing/arch/mips/sibyte/common/cfe_console.c
@@ -22,8 +22,6 @@  static void cfe_console_write(struct con
 		if (str[i] == '\n') {
 			do {
 				written = cfe_write(cfe_cons_handle, &str[last], i-last);
-				if (written < 0)
-					;
 				last += written;
 			} while (last < i);
 			while (cfe_write(cfe_cons_handle, "\r", 1) <= 0)
@@ -33,8 +31,6 @@  static void cfe_console_write(struct con
 	if (last != count) {
 		do {
 			written = cfe_write(cfe_cons_handle, &str[last], count-last);
-			if (written < 0)
-				;
 			last += written;
 		} while (last < count);
 	}