Skip to contentSkip to conversation

drm/amd/amdgpu: fix comparison pointer to bool warning

PATCH In review Zheng Bin 6 participants 17 messages Sep 9, 2020 – Sep 16, 2020

Subsystems (2)
lore
Share & tools
lore

Zheng Bin

author
#0 lore raw

cover drm/amd/amdgpu: fix comparison pointer to bool warning

Zheng Bin (8):
drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v9_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v10_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_2.c drm/amd/amdgpu: fix comparison pointer to bool warning in si.c drm/amd/amdgpu: fix comparison pointer to bool warning in uvd_v6_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in
amdgpu_atpx_handler.c
drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v4_0.c

 drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 4 ++--
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c           | 2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c            | 2 +-
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c           | 4 ++--
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c           | 2 +-
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c           | 2 +-
 drivers/gpu/drm/amd/amdgpu/si.c                  | 2 +-
 drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c            | 4 ++--
 8 files changed, 11 insertions(+), 11 deletions(-)

--
2.26.0.106.g9fadedd

author
#1 lore raw

PATCH 1/8 drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v9_0.c

Fixes coccicheck warning:

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:2805:5-11: WARNING: Comparison to bool

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -1
index fed2690d1380..20d8a03ca866 100644
@@ -2802,7 +2802,7 @@ static void pwr_10_0_gfxip_control_over_cgpg(struct amdgpu_device *adev,
 	uint32_t default_data = 0;
 
 	default_data = data = RREG32(SOC15_REG_OFFSET(PWR, 0, mmPWR_MISC_CNTL_STATUS));
-	if (enable == true) {
+	if (enable) {
 		/* enable GFXIP control over CGPG */
 		data |= PWR_MISC_CNTL_STATUS__PWR_GFX_RLC_CGPG_EN_MASK;
 		if(default_data != data)

--
2.26.0.106.g9fadedd

maintainer Acked-by on the v1 series
#2 lore raw
In reply to Zheng Bin

Am 09.09.20 um 15:07 schrieb Zheng Bin:

Quoted 21 lines

Zheng Bin (8):
drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v9_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v10_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_2.c drm/amd/amdgpu: fix comparison pointer to bool warning in si.c drm/amd/amdgpu: fix comparison pointer to bool warning in uvd_v6_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in
amdgpu_atpx_handler.c
drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v4_0.c

  drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 4 ++--
  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c           | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c            | 2 +-
  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c           | 4 ++--
  drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c           | 2 +-
  drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c           | 2 +-
  drivers/gpu/drm/amd/amdgpu/si.c                  | 2 +-
  drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c            | 4 ++--
  8 files changed, 11 insertions(+), 11 deletions(-)
Quoted 3 lines

--
2.26.0.106.g9fadedd

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw

I question the value of these warnings. Why even have a boolean type if you are going to get warnings when you use them...
That said, applied to avoid getting these patches again and again every time someone sees this.

Alex

Quoted 25 lines · Christian König

Am 09.09.20 um 15:07 schrieb Zheng Bin:

Quoted 21 lines

Zheng Bin (8):
drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v9_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v10_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_2.c drm/amd/amdgpu: fix comparison pointer to bool warning in si.c drm/amd/amdgpu: fix comparison pointer to bool warning in uvd_v6_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in
amdgpu_atpx_handler.c
drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v4_0.c

  drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 4 ++--
  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c           | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c            | 2 +-
  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c           | 4 ++--
  drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c           | 2 +-
  drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c           | 2 +-
  drivers/gpu/drm/amd/amdgpu/si.c                  | 2 +-
  drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c            | 4 ++--
  8 files changed, 11 insertions(+), 11 deletions(-)
Quoted 8 lines
Quoted 3 lines

--
2.26.0.106.g9fadedd

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#4 lore raw
Quoted 4 lines · Alex Deucher

I question the value of these warnings. Why even have a boolean type if you are going to get warnings when you use them...
That said, applied to avoid getting these patches again and again every time someone sees this.

if (this_is_sparta)
if (this_is_sparta == true)
if (this_is_sparta != false)

I think the first one reads the best, and avoids having to decide between truth and falsehood :)

Quoted 41 lines

Alex

Quoted 25 lines · Christian König

Am 09.09.20 um 15:07 schrieb Zheng Bin:

Quoted 21 lines

Zheng Bin (8):
drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v9_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v10_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_2.c drm/amd/amdgpu: fix comparison pointer to bool warning in si.c drm/amd/amdgpu: fix comparison pointer to bool warning in uvd_v6_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in
amdgpu_atpx_handler.c
drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v4_0.c

  drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 4 ++--
  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c           | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c            | 2 +-
  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c           | 4 ++--
  drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c           | 2 +-
  drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c           | 2 +-
  drivers/gpu/drm/amd/amdgpu/si.c                  | 2 +-
  drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c            | 4 ++--
  8 files changed, 11 insertions(+), 11 deletions(-)
Quoted 8 lines
Quoted 3 lines

--
2.26.0.106.g9fadedd

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

Am 15.09.20 um 21:35 schrieb Ville Syrjälä:

Quoted 11 lines · Alex Deucher
Quoted 4 lines

I question the value of these warnings. Why even have a boolean type if you are going to get warnings when you use them...
That said, applied to avoid getting these patches again and again every time someone sees this.

if (this_is_sparta)
if (this_is_sparta == true)
if (this_is_sparta != false)

I think the first one reads the best, and avoids having to decide between truth and falsehood :)

+1

Christian.

Quoted 31 lines
Quoted 31 lines

Alex

Quoted 27 lines · Christian König

Am 09.09.20 um 15:07 schrieb Zheng Bin:

Quoted 24 lines

Zheng Bin (8):
drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v9_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v10_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_2.c drm/amd/amdgpu: fix comparison pointer to bool warning in si.c drm/amd/amdgpu: fix comparison pointer to bool warning in uvd_v6_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in
amdgpu_atpx_handler.c
drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v4_0.c

   drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 4 ++--
   drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c           | 2 +-
   drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c            | 2 +-
   drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c           | 4 ++--
   drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c           | 2 +-
   drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c           | 2 +-
   drivers/gpu/drm/amd/amdgpu/si.c                  | 2 +-
   drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c            | 4 ++--
   8 files changed, 11 insertions(+), 11 deletions(-)

--
2.26.0.106.g9fadedd

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw
Quoted 6 lines · Christian König

Am 15.09.20 um 21:35 schrieb Ville Syrjälä:

Quoted 5 lines · Alex Deucher
Quoted 4 lines

I question the value of these warnings. Why even have a boolean type if you are going to get warnings when you use them...
That said, applied to avoid getting these patches again and again every time someone sees this.

Quoted 8 lines
Quoted 6 lines

if (this_is_sparta)
if (this_is_sparta == true)
if (this_is_sparta != false)

I think the first one reads the best, and avoids having to decide between truth and falsehood :)

+1

+1, especially because we also have the inversion when using negative errno codes for failures and 0 as success, which results in

	if (errno == 0) /* success case */

but

	if (bool == 0) /* failure case */

now creative people do sometimes

if (!errno) /* success case */

which I think is horribly confusing. So imo for more easier telling apart of these too I think consistently using the short form for booleans, and consistently using the more explicit long form for errno checks is a Very Good Pattern :-)

Cheers, Daniel

Quoted 47 lines

Christian.

Quoted 31 lines
Quoted 31 lines

Alex

Quoted 27 lines · Christian König

Am 09.09.20 um 15:07 schrieb Zheng Bin:

Quoted 24 lines

Zheng Bin (8):
drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v9_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v10_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_2.c drm/amd/amdgpu: fix comparison pointer to bool warning in si.c drm/amd/amdgpu: fix comparison pointer to bool warning in uvd_v6_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in
amdgpu_atpx_handler.c
drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v4_0.c

   drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 4 ++--
   drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c           | 2 +-
   drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c            | 2 +-
   drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c           | 4 ++--
   drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c           | 2 +-
   drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c           | 2 +-
   drivers/gpu/drm/amd/amdgpu/si.c                  | 2 +-
   drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c            | 4 ++--
   8 files changed, 11 insertions(+), 11 deletions(-)

--
2.26.0.106.g9fadedd

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#7 lore raw
Quoted 25 lines · Daniel Vetter
Quoted 6 lines · Christian König

Am 15.09.20 um 21:35 schrieb Ville Syrjälä:

Quoted 5 lines · Alex Deucher
Quoted 4 lines

I question the value of these warnings. Why even have a boolean type if you are going to get warnings when you use them...
That said, applied to avoid getting these patches again and again every time someone sees this.

Quoted 8 lines
Quoted 6 lines

if (this_is_sparta)
if (this_is_sparta == true)
if (this_is_sparta != false)

I think the first one reads the best, and avoids having to decide between truth and falsehood :)

+1

+1, especially because we also have the inversion when using negative errno codes for failures and 0 as success, which results in

        if (errno == 0) /* success case */

but

        if (bool == 0) /* failure case */
Quoted 8 lines

now creative people do sometimes

if (!errno) /* success case */

which I think is horribly confusing. So imo for more easier telling apart of these too I think consistently using the short form for booleans, and consistently using the more explicit long form for errno checks is a Very Good Pattern :-)

I don't disagree with your logic, but we regularly get patches to convert errno checks to drop the direct comparison because that is the "preferred kernel style". Arguably, we should be explicit in all cases as that avoids all confusion. With that in mind, my original point stands. Why have a type when comparisons against valid settings for that type produce errors?

Alex

Quoted 51 lines

Cheers, Daniel

Quoted 43 lines

Christian.

Quoted 31 lines
Quoted 31 lines

Alex

Quoted 27 lines · Christian König

Am 09.09.20 um 15:07 schrieb Zheng Bin:

Quoted 24 lines

Zheng Bin (8):
drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v9_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v10_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_2.c drm/amd/amdgpu: fix comparison pointer to bool warning in si.c drm/amd/amdgpu: fix comparison pointer to bool warning in uvd_v6_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in
amdgpu_atpx_handler.c
drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v4_0.c

   drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 4 ++--
   drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c           | 2 +-
   drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c            | 2 +-
   drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c           | 4 ++--
   drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c           | 2 +-
   drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c           | 2 +-
   drivers/gpu/drm/amd/amdgpu/si.c                  | 2 +-
   drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c            | 4 ++--
   8 files changed, 11 insertions(+), 11 deletions(-)

--
2.26.0.106.g9fadedd

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer
#8 lore raw

Am 16.09.20 um 15:36 schrieb Alex Deucher:

Quoted 31 lines · Daniel Vetter
Quoted 22 lines · Christian König
Quoted 6 lines

Am 15.09.20 um 21:35 schrieb Ville Syrjälä:

Quoted 5 lines · Alex Deucher
Quoted 4 lines

I question the value of these warnings. Why even have a boolean type if you are going to get warnings when you use them...
That said, applied to avoid getting these patches again and again every time someone sees this.

Quoted 7 lines
Quoted 6 lines

if (this_is_sparta)
if (this_is_sparta == true)
if (this_is_sparta != false)

I think the first one reads the best, and avoids having to decide between truth and falsehood :)

+1

+1, especially because we also have the inversion when using negative errno codes for failures and 0 as success, which results in

         if (errno == 0) /* success case */

but

         if (bool == 0) /* failure case */
Quoted 8 lines

now creative people do sometimes

if (!errno) /* success case */

which I think is horribly confusing. So imo for more easier telling apart of these too I think consistently using the short form for booleans, and consistently using the more explicit long form for errno checks is a Very Good Pattern :-)

Quoted 6 lines

I don't disagree with your logic, but we regularly get patches to convert errno checks to drop the direct comparison because that is the "preferred kernel style". Arguably, we should be explicit in all cases as that avoids all confusion. With that in mind, my original point stands. Why have a type when comparisons against valid settings for that type produce errors?

Well it isn't an error, but raising a nice warning is most likely a good idea.

Christian.

Quoted 53 lines

Alex

Quoted 50 lines

Cheers, Daniel

Quoted 36 lines

Christian.

Quoted 34 lines
Quoted 34 lines

Alex

Quoted 31 lines · Christian König

Am 09.09.20 um 15:07 schrieb Zheng Bin:

Quoted 21 lines

Zheng Bin (8):
drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v9_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v10_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_2.c drm/amd/amdgpu: fix comparison pointer to bool warning in si.c drm/amd/amdgpu: fix comparison pointer to bool warning in uvd_v6_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in
amdgpu_atpx_handler.c
drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v4_0.c

drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 4 ++--
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +-
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +-
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 4 ++--
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 2 +-
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 2 +-
drivers/gpu/drm/amd/amdgpu/si.c | 2 +-
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 4 ++--
8 files changed, 11 insertions(+), 11 deletions(-)

Quoted 3 lines

--
2.26.0.106.g9fadedd

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051676053&sdata=MS0vcBcU7unXjEFlbd8kLbJkJ4sKcvIdLjc8yhX4UUI%3D&reserved=0

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051686051&sdata=MgfR%2BwCVY9gWfhQ9i5kWcKiiYkV1C8O2dEKlZYSqscE%3D&reserved=0

_______________________________________________
dri-devel mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051686051&sdata=MgfR%2BwCVY9gWfhQ9i5kWcKiiYkV1C8O2dEKlZYSqscE%3D&reserved=0

--
Daniel Vetter
Software Engineer, Intel Corporation
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll.ch%2F&data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051686051&sdata=GvLs5OXw2Ny%2BieJxm8hjawNb0rGA966539iAwlWwPMY%3D&reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#9 lore raw
Quoted 38 lines · Christian König

Am 16.09.20 um 15:36 schrieb Alex Deucher:

Quoted 37 lines · Daniel Vetter
Quoted 22 lines · Christian König
Quoted 6 lines

Am 15.09.20 um 21:35 schrieb Ville Syrjälä:

Quoted 5 lines · Alex Deucher
Quoted 4 lines

I question the value of these warnings. Why even have a boolean type if you are going to get warnings when you use them...
That said, applied to avoid getting these patches again and again every time someone sees this.

Quoted 7 lines
Quoted 6 lines

if (this_is_sparta)
if (this_is_sparta == true)
if (this_is_sparta != false)

I think the first one reads the best, and avoids having to decide between truth and falsehood :)

+1

+1, especially because we also have the inversion when using negative errno codes for failures and 0 as success, which results in

         if (errno == 0) /* success case */

but

         if (bool == 0) /* failure case */
Quoted 8 lines

now creative people do sometimes

if (!errno) /* success case */

which I think is horribly confusing. So imo for more easier telling apart of these too I think consistently using the short form for booleans, and consistently using the more explicit long form for errno checks is a Very Good Pattern :-)

I don't disagree with your logic, but we regularly get patches to convert errno checks to drop the direct comparison because that is the "preferred kernel style". Arguably, we should be explicit in all cases as that avoids all confusion. With that in mind, my original point stands. Why have a type when comparisons against valid settings for that type produce errors?

Oh, I didn't know that this happens for errno too.

I withdraw my +1 and concur this is a bikeshed. I guess still applying to shut up the patch stream is the most reasonable thing :-/ -Daniel

Quoted 64 lines

Well it isn't an error, but raising a nice warning is most likely a good idea.

Christian.

Quoted 53 lines

Alex

Quoted 50 lines

Cheers, Daniel

Quoted 36 lines

Christian.

Quoted 34 lines
Quoted 34 lines

Alex

Quoted 31 lines · Christian König

Am 09.09.20 um 15:07 schrieb Zheng Bin:

Quoted 21 lines

Zheng Bin (8):
drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v9_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v10_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_2.c drm/amd/amdgpu: fix comparison pointer to bool warning in si.c drm/amd/amdgpu: fix comparison pointer to bool warning in uvd_v6_0.c drm/amd/amdgpu: fix comparison pointer to bool warning in
amdgpu_atpx_handler.c
drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v4_0.c

drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 4 ++--
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +-
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +-
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 4 ++--
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 2 +-
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 2 +-
drivers/gpu/drm/amd/amdgpu/si.c | 2 +-
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 4 ++--
8 files changed, 11 insertions(+), 11 deletions(-)

Quoted 3 lines

--
2.26.0.106.g9fadedd

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051676053&sdata=MS0vcBcU7unXjEFlbd8kLbJkJ4sKcvIdLjc8yhX4UUI%3D&reserved=0

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051686051&sdata=MgfR%2BwCVY9gWfhQ9i5kWcKiiYkV1C8O2dEKlZYSqscE%3D&reserved=0

_______________________________________________
dri-devel mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051686051&sdata=MgfR%2BwCVY9gWfhQ9i5kWcKiiYkV1C8O2dEKlZYSqscE%3D&reserved=0

--
Daniel Vetter
Software Engineer, Intel Corporation
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll.ch%2F&data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051686051&sdata=GvLs5OXw2Ny%2BieJxm8hjawNb0rGA966539iAwlWwPMY%3D&reserved=0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#10 lore raw

PATCH 2/8 drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v10_0.c

In reply to Zheng Bin

Fixes coccicheck warning:

drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:3563:5-31: WARNING: Comparison to bool

---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1 -1
index 2db195ec8d0c..a78c0dbda968 100644
@@ -3560,7 +3560,7 @@ static void gfx_v10_0_check_fw_write_wait(struct amdgpu_device *adev)
 		break;
 	}
 
-	if (adev->gfx.cp_fw_write_wait == false)
+	if (!adev->gfx.cp_fw_write_wait)
 		DRM_WARN_ONCE("CP firmware version too old, please update!");
 }
 

--
2.26.0.106.g9fadedd

author
#11 lore raw

PATCH 3/8 drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_0.c

In reply to Zheng Bin

Fixes coccicheck warning:

drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c:619:5-11: WARNING: Comparison to bool

---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +1 -1
index e2232dd12d8e..48c95a78a173 100644
@@ -616,7 +616,7 @@ static void sdma_v5_0_enable(struct amdgpu_device *adev, bool enable)
 	u32 f32_cntl;
 	int i;
 
-	if (enable == false) {
+	if (!enable) {
 		sdma_v5_0_gfx_stop(adev);
 		sdma_v5_0_rlc_stop(adev);
 	}

--
2.26.0.106.g9fadedd

author
#12 lore raw

PATCH 4/8 drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_2.c

In reply to Zheng Bin

Fixes coccicheck warning:

drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c:562:5-11: WARNING: Comparison to bool

---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +1 -1
index 46a9617fee5f..34ccf376ee45 100644
@@ -559,7 +559,7 @@ static void sdma_v5_2_enable(struct amdgpu_device *adev, bool enable)
 	u32 f32_cntl;
 	int i;
 
-	if (enable == false) {
+	if (!enable) {
 		sdma_v5_2_gfx_stop(adev);
 		sdma_v5_2_rlc_stop(adev);
 	}

--
2.26.0.106.g9fadedd

author
#13 lore raw

PATCH 5/8 drm/amd/amdgpu: fix comparison pointer to bool warning in si.c

In reply to Zheng Bin

Fixes coccicheck warning:

drivers/gpu/drm/amd/amdgpu/si.c:1342:5-10: WARNING: Comparison to bool

---
 drivers/gpu/drm/amd/amdgpu/si.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/si.c +1 -1
index 455d5e366c69..e5e336fd9e94 100644
@@ -1339,7 +1339,7 @@ static void si_vga_set_state(struct amdgpu_device *adev, bool state)
 	uint32_t temp;
 
 	temp = RREG32(CONFIG_CNTL);
-	if (state == false) {
+	if (!state) {
 		temp &= ~(1<<0);
 		temp |= (1<<1);
 	} else {

--
2.26.0.106.g9fadedd

author
#14 lore raw

PATCH 6/8 drm/amd/amdgpu: fix comparison pointer to bool warning in uvd_v6_0.c

In reply to Zheng Bin

Fixes coccicheck warning:

drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c:1243:14-25: WARNING: Comparison to bool

---
 drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +2 -2
index 0a880bc101b8..ed30fb48b9db 100644
@@ -1240,8 +1240,8 @@ static int uvd_v6_0_process_interrupt(struct amdgpu_device *adev,
 		break;
 	}
 
-	if (false == int_handled)
-			DRM_ERROR("Unhandled interrupt: %d %d\n",
+	if (!int_handled)
+		DRM_ERROR("Unhandled interrupt: %d %d\n",
 			  entry->src_id, entry->src_data[0]);
 
 	return 0;

--
2.26.0.106.g9fadedd

author
#15 lore raw

PATCH 7/8 drm/amd/amdgpu: fix comparison pointer to bool warning in amdgpu_atpx_handler.c

In reply to Zheng Bin

Fixes coccicheck warning:

drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c:619:15-49: WARNING: Comparison to bool drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c:629:15-49: WARNING: Comparison to bool

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c +2 -2
index 3e35a8f2c5e5..7abe9500c0c6 100644
@@ -616,7 +616,7 @@ static bool amdgpu_atpx_detect(void)
 	while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
 		vga_count++;
 
-		has_atpx |= (amdgpu_atpx_pci_probe_handle(pdev) == true);
+		has_atpx |= amdgpu_atpx_pci_probe_handle(pdev);
 
 		parent_pdev = pci_upstream_bridge(pdev);
 		d3_supported |= parent_pdev && parent_pdev->bridge_d3;
@@ -626,7 +626,7 @@ static bool amdgpu_atpx_detect(void)
 	while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
 		vga_count++;
 
-		has_atpx |= (amdgpu_atpx_pci_probe_handle(pdev) == true);
+		has_atpx |= amdgpu_atpx_pci_probe_handle(pdev);
 
 		parent_pdev = pci_upstream_bridge(pdev);
 		d3_supported |= parent_pdev && parent_pdev->bridge_d3;

--
2.26.0.106.g9fadedd

author
#16 lore raw

PATCH 8/8 drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v4_0.c

In reply to Zheng Bin

Fixes coccicheck warning:

drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c:1003:4-9: WARNING: Comparison to bool drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c:1083:5-11: WARNING: Comparison to bool

---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +2 -2
index f975dc4b143a..e8e7d4228b92 100644
@@ -1000,7 +1000,7 @@ static void sdma_v4_0_page_stop(struct amdgpu_device *adev)
 		sdma[i] = &adev->sdma.instance[i].page;
 
 		if ((adev->mman.buffer_funcs_ring == sdma[i]) &&
-			(unset == false)) {
+			(!unset)) {
 			amdgpu_ttm_set_buffer_funcs_status(adev, false);
 			unset = true;
 		}
@@ -1080,7 +1080,7 @@ static void sdma_v4_0_enable(struct amdgpu_device *adev, bool enable)
 	u32 f32_cntl;
 	int i;
 
-	if (enable == false) {
+	if (!enable) {
 		sdma_v4_0_gfx_stop(adev);
 		sdma_v4_0_rlc_stop(adev);
 		if (adev->sdma.has_page_queue)

--
2.26.0.106.g9fadedd