Re: [PATCH] macintosh: windfarm: Use NULL to compare with pointer-typed value rather than 0

From: Christophe Leroy
Date: Fri Mar 18 2022 - 13:07:26 EST




Le 13/11/2020 à 08:33, Xu Wang a écrit :
Compare pointer-typed values to NULL rather than 0.

Signed-off-by: Xu Wang <vulab@xxxxxxxxxxx>

If we are going to change that, let's do it right at once

Checkpatch says:

CHECK: Comparison to NULL could be written "!hdr"
#25: FILE: drivers/macintosh/windfarm_pm121.c:653:
+ if (hdr == NULL) {

CHECK: Comparison to NULL could be written "hdr"
#34: FILE: drivers/macintosh/windfarm_pm121.c:972:
+ if (hdr != NULL) {

total: 0 errors, 0 warnings, 2 checks, 16 lines checked



---
drivers/macintosh/windfarm_pm121.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/macintosh/windfarm_pm121.c b/drivers/macintosh/windfarm_pm121.c
index ab467b9c31be..62826844b584 100644
--- a/drivers/macintosh/windfarm_pm121.c
+++ b/drivers/macintosh/windfarm_pm121.c
@@ -650,7 +650,7 @@ static void pm121_create_cpu_fans(void)
/* First, locate the PID params in SMU SBD */
hdr = smu_get_sdb_partition(SMU_SDB_CPUPIDDATA_ID, NULL);
- if (hdr == 0) {
+ if (hdr == NULL) {
printk(KERN_WARNING "pm121: CPU PID fan config not found.\n");
goto fail;
}
@@ -969,7 +969,7 @@ static int pm121_init_pm(void)
const struct smu_sdbp_header *hdr;
hdr = smu_get_sdb_partition(SMU_SDB_SENSORTREE_ID, NULL);
- if (hdr != 0) {
+ if (hdr != NULL) {
struct smu_sdbp_sensortree *st =
(struct smu_sdbp_sensortree *)&hdr[1];
pm121_mach_model = st->model_id;