* [PATCH] staging: sm750fb: Replace comparisons with NULL and 0
@ 2024-03-15 13:01 Chandra Pratap
0 siblings, 0 replies; 3+ messages in thread
From: Chandra Pratap @ 2024-03-15 13:01 UTC (permalink / raw)
To: outreachy
Cc: sudipm.mukherjee, teddy.wang, gregkh, linux-fbdev, staging,
linux-kernel, Chandra Pratap
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(-)
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;
--
2.43.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH] staging: sm750fb: Replace comparisons with NULL and 0
@ 2024-03-19 18:17 Chandra Pratap
2024-03-20 5:08 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Chandra Pratap @ 2024-03-19 18:17 UTC (permalink / raw)
To: sudipm.mukherjee, teddy.wang, gregkh, linux-fbdev, linux-staging,
linux-kernel, outreachy
Cc: Chandra Pratap
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(-)
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;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] staging: sm750fb: Replace comparisons with NULL and 0
2024-03-19 18:17 Chandra Pratap
@ 2024-03-20 5:08 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-03-20 5:08 UTC (permalink / raw)
To: Chandra Pratap
Cc: sudipm.mukherjee, teddy.wang, gregkh, linux-fbdev, linux-staging,
linux-kernel, outreachy
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-20 5:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-15 13:01 [PATCH] staging: sm750fb: Replace comparisons with NULL and 0 Chandra Pratap
-- strict thread matches above, loose matches on Subject: below --
2024-03-19 18:17 Chandra Pratap
2024-03-20 5:08 ` Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.