diff mbox series

staging: sm750fb: Replace comparisons with NULL and 0

Message ID 20240319181735.366565-1-chandrapratap3519@gmail.com (mailing list archive)
State Handled Elsewhere
Headers show
Series staging: sm750fb: Replace comparisons with NULL and 0 | expand

Commit Message

Chandra Pratap March 19, 2024, 6:17 p.m. UTC
Replace '(foo != NULL)' with '(foo)' and 'x != 0'
with 'x' to adhere to the coding standards.

Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
---
 drivers/staging/sm750fb/sm750.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Dan Carpenter March 20, 2024, 5:08 a.m. UTC | #1
On Tue, Mar 19, 2024 at 11:47:35PM +0530, Chandra Pratap wrote:
> Replace '(foo != NULL)' with '(foo)' and 'x != 0'
> with 'x' to adhere to the coding standards.
> 

In your commit message use "opt" and "*opt" instead of "foo" and "x".

Removing the != NULL is fine, but the *opt != 0 should be changed to
(*opt != '\0').  There are times where comparing against zero helps
readability.  I wrote a blog about this, but I had forgotten the case
with the NUL terminator...

https://staticthinking.wordpress.com/2024/02/20/when-to-use-0/

regards,
dan carpenter
diff mbox series

Patch

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 04c1b32a22c5..4537f007a810 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -926,7 +926,7 @@  static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src)
 		goto NO_PARAM;
 	}
 
-	while ((opt = strsep(&src, ":")) != NULL && *opt != 0) {
+	while ((opt = strsep(&src, ":")) && *opt) {
 		dev_info(&sm750_dev->pdev->dev, "opt=%s\n", opt);
 		dev_info(&sm750_dev->pdev->dev, "src=%s\n", src);
 
@@ -1147,7 +1147,7 @@  static int __init lynxfb_setup(char *options)
 	 * strsep() updates @options to pointer after the first found token
 	 * it also returns the pointer ahead the token.
 	 */
-	while ((opt = strsep(&options, ":")) != NULL) {
+	while ((opt = strsep(&options, ":"))) {
 		/* options that mean for any lynx chips are configured here */
 		if (!strncmp(opt, "noaccel", strlen("noaccel"))) {
 			g_noaccel = 1;