linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] cpufreq: Fix NULL pointer comparison warning
@ 2016-12-06 10:17 Mohamed Wasif
  2016-12-06 10:29 ` Viresh Kumar
  2016-12-06 21:03 ` Rafael J. Wysocki
  0 siblings, 2 replies; 3+ messages in thread
From: Mohamed Wasif @ 2016-12-06 10:17 UTC (permalink / raw)
  To: Rafael J. Wysocki, Viresh Kumar, Mohamed Wasif
  Cc: linux-pm, linux-kernel, vidushi.koul

Replace direct comparisons to NULL
This problem was detected by checkpatch.

Signed-off-by: Mohamed Wasif <m.wasif@samsung.com>
---
 drivers/cpufreq/cpufreq.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 6e6c1fb..ca3542e 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -590,7 +590,7 @@ static int cpufreq_parse_governor(char *str_governor, unsigned int *policy,
 
 		t = find_governor(str_governor);
 
-		if (t == NULL) {
+		if (!t) {
 			int ret;
 
 			mutex_unlock(&cpufreq_governor_mutex);
@@ -601,7 +601,7 @@ static int cpufreq_parse_governor(char *str_governor, unsigned int *policy,
 				t = find_governor(str_governor);
 		}
 
-		if (t != NULL) {
+		if (t) {
 			*governor = t;
 			err = 0;
 		}
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] cpufreq: Fix NULL pointer comparison warning
  2016-12-06 10:17 [PATCH 1/1] cpufreq: Fix NULL pointer comparison warning Mohamed Wasif
@ 2016-12-06 10:29 ` Viresh Kumar
  2016-12-06 21:03 ` Rafael J. Wysocki
  1 sibling, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2016-12-06 10:29 UTC (permalink / raw)
  To: Mohamed Wasif; +Cc: Rafael J. Wysocki, linux-pm, linux-kernel, vidushi.koul

On 06-12-16, 15:47, Mohamed Wasif wrote:
> Replace direct comparisons to NULL
> This problem was detected by checkpatch.
> 
> Signed-off-by: Mohamed Wasif <m.wasif@samsung.com>
> ---
>  drivers/cpufreq/cpufreq.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 6e6c1fb..ca3542e 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -590,7 +590,7 @@ static int cpufreq_parse_governor(char *str_governor, unsigned int *policy,
>  
>  		t = find_governor(str_governor);
>  
> -		if (t == NULL) {
> +		if (!t) {
>  			int ret;
>  
>  			mutex_unlock(&cpufreq_governor_mutex);
> @@ -601,7 +601,7 @@ static int cpufreq_parse_governor(char *str_governor, unsigned int *policy,
>  				t = find_governor(str_governor);
>  		}
>  
> -		if (t != NULL) {
> +		if (t) {
>  			*governor = t;
>  			err = 0;
>  		}

What exact checkpatch error did you get ?

This patch would still be not worth it, as the style of comparing with
NULL is just fine. But still I am unable to see the checkpatch warning
in my setup.

-- 
viresh

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] cpufreq: Fix NULL pointer comparison warning
  2016-12-06 10:17 [PATCH 1/1] cpufreq: Fix NULL pointer comparison warning Mohamed Wasif
  2016-12-06 10:29 ` Viresh Kumar
@ 2016-12-06 21:03 ` Rafael J. Wysocki
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2016-12-06 21:03 UTC (permalink / raw)
  To: Mohamed Wasif
  Cc: Rafael J. Wysocki, Viresh Kumar, Linux PM,
	Linux Kernel Mailing List, vidushi.koul

On Tue, Dec 6, 2016 at 11:17 AM, Mohamed Wasif <m.wasif@samsung.com> wrote:
> Replace direct comparisons to NULL
> This problem was detected by checkpatch.
>
> Signed-off-by: Mohamed Wasif <m.wasif@samsung.com>
> ---
>  drivers/cpufreq/cpufreq.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 6e6c1fb..ca3542e 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -590,7 +590,7 @@ static int cpufreq_parse_governor(char *str_governor, unsigned int *policy,
>
>                 t = find_governor(str_governor);
>
> -               if (t == NULL) {
> +               if (!t) {
>                         int ret;
>
>                         mutex_unlock(&cpufreq_governor_mutex);
> @@ -601,7 +601,7 @@ static int cpufreq_parse_governor(char *str_governor, unsigned int *policy,
>                                 t = find_governor(str_governor);
>                 }
>
> -               if (t != NULL) {
> +               if (t) {
>                         *governor = t;
>                         err = 0;
>                 }
> --

The code is correct as is and this patch doesn't fix anything.

Besides, you are supposed to run checkpatch against *patches* and not
against existing code.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-06 21:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-06 10:17 [PATCH 1/1] cpufreq: Fix NULL pointer comparison warning Mohamed Wasif
2016-12-06 10:29 ` Viresh Kumar
2016-12-06 21:03 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).