2022-11-06 16:16:07

by KaiLong Wang

[permalink] [raw]
Subject: [PATCH] speakup: Fix warning comparing pointer to 0

Fix the following coccicheck warning:

drivers/accessibility/speakup/utils.h:39:15-16: WARNING comparing
pointer to 0

Signed-off-by: KaiLong Wang <[email protected]>
---
drivers/accessibility/speakup/utils.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/accessibility/speakup/utils.h b/drivers/accessibility/speakup/utils.h
index 4bf2ee8ac246..5803b521df2b 100644
--- a/drivers/accessibility/speakup/utils.h
+++ b/drivers/accessibility/speakup/utils.h
@@ -36,7 +36,7 @@ static inline void open_input(const char *dir_name, const char *name)
else
snprintf(filename, sizeof(filename), "%s", name);
infile = fopen(filename, "r");
- if (infile == 0) {
+ if (infile) {
fprintf(stderr, "can't open %s\n", filename);
exit(1);
}
--
2.25.1


2022-11-06 16:38:04

by Samuel Thibault

[permalink] [raw]
Subject: Re: [PATCH] speakup: Fix warning comparing pointer to 0

[email protected], le dim. 06 nov. 2022 23:07:54 +0800, a ecrit:
> Fix the following coccicheck warning:
>
> drivers/accessibility/speakup/utils.h:39:15-16: WARNING comparing
> pointer to 0

You're replacing it with the contrary of what it should be...

> ---
> drivers/accessibility/speakup/utils.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/accessibility/speakup/utils.h b/drivers/accessibility/speakup/utils.h
> index 4bf2ee8ac246..5803b521df2b 100644
> --- a/drivers/accessibility/speakup/utils.h
> +++ b/drivers/accessibility/speakup/utils.h
> @@ -36,7 +36,7 @@ static inline void open_input(const char *dir_name, const char *name)
> else
> snprintf(filename, sizeof(filename), "%s", name);
> infile = fopen(filename, "r");
> - if (infile == 0) {
> + if (infile) {
> fprintf(stderr, "can't open %s\n", filename);
> exit(1);
> }
> --
> 2.25.1