2020-09-09 13:32:37

by Zheng Bin

[permalink] [raw]
Subject: [PATCH -next 0/8] 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


2020-09-09 13:52:58

by Christian König

[permalink] [raw]
Subject: Re: [PATCH -next 0/8] drm/amd/amdgpu: fix comparison pointer to bool warning

Acked-by: Christian König <[email protected]> for the series.

Am 09.09.20 um 15:07 schrieb Zheng Bin:
> 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
>

2020-09-09 14:22:21

by Zheng Bin

[permalink] [raw]
Subject: [PATCH -next 7/8] drm/amd/amdgpu: fix comparison pointer to bool warning in amdgpu_atpx_handler.c

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

Signed-off-by: Zheng Bin <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
index 3e35a8f2c5e5..7abe9500c0c6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
@@ -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

2020-09-09 14:24:17

by Zheng Bin

[permalink] [raw]
Subject: [PATCH -next 5/8] drm/amd/amdgpu: fix comparison pointer to bool warning in si.c

Fixes coccicheck warning:

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

Signed-off-by: Zheng Bin <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/si.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c
index 455d5e366c69..e5e336fd9e94 100644
--- a/drivers/gpu/drm/amd/amdgpu/si.c
+++ b/drivers/gpu/drm/amd/amdgpu/si.c
@@ -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

2020-09-09 14:26:42

by Zheng Bin

[permalink] [raw]
Subject: [PATCH -next 6/8] drm/amd/amdgpu: fix comparison pointer to bool warning in uvd_v6_0.c

Fixes coccicheck warning:

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

Signed-off-by: Zheng Bin <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index 0a880bc101b8..ed30fb48b9db 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
@@ -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

2020-09-09 14:28:34

by Zheng Bin

[permalink] [raw]
Subject: [PATCH -next 2/8] drm/amd/amdgpu: fix comparison pointer to bool warning in gfx_v10_0.c

Fixes coccicheck warning:

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

Signed-off-by: Zheng Bin <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 2db195ec8d0c..a78c0dbda968 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -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

2020-09-09 14:32:00

by Zheng Bin

[permalink] [raw]
Subject: [PATCH -next 4/8] drm/amd/amdgpu: fix comparison pointer to bool warning in sdma_v5_2.c

Fixes coccicheck warning:

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

Signed-off-by: Zheng Bin <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
index 46a9617fee5f..34ccf376ee45 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
@@ -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

2020-09-15 19:24:31

by Alex Deucher

[permalink] [raw]
Subject: Re: [PATCH -next 0/8] drm/amd/amdgpu: fix comparison pointer to bool warning

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

On Wed, Sep 9, 2020 at 9:21 AM Christian König <[email protected]> wrote:
>
> Acked-by: Christian König <[email protected]> for the series.
>
> Am 09.09.20 um 15:07 schrieb Zheng Bin:
> > 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
> >
>
> _______________________________________________
> amd-gfx mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

2020-09-15 19:43:16

by Ville Syrjälä

[permalink] [raw]
Subject: Re: [PATCH -next 0/8] drm/amd/amdgpu: fix comparison pointer to bool warning

On Tue, Sep 15, 2020 at 03:16:32PM -0400, Alex Deucher wrote:
> 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 :)

>
> Alex
>
> On Wed, Sep 9, 2020 at 9:21 AM Christian K?nig <[email protected]> wrote:
> >
> > Acked-by: Christian K?nig <[email protected]> for the series.
> >
> > Am 09.09.20 um 15:07 schrieb Zheng Bin:
> > > 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
> > >
> >
> > _______________________________________________
> > 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

--
Ville Syrj?l?
Intel

2020-09-16 07:39:35

by Christian König

[permalink] [raw]
Subject: Re: [PATCH -next 0/8] drm/amd/amdgpu: fix comparison pointer to bool warning

Am 15.09.20 um 21:35 schrieb Ville Syrjälä:
> On Tue, Sep 15, 2020 at 03:16:32PM -0400, Alex Deucher wrote:
>> 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.

>
>> Alex
>>
>> On Wed, Sep 9, 2020 at 9:21 AM Christian König <[email protected]> wrote:
>>> Acked-by: Christian König <[email protected]> for the series.
>>>
>>> Am 09.09.20 um 15:07 schrieb Zheng Bin:
>>>> 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
>>>>
>>> _______________________________________________
>>> 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

2020-09-16 07:52:59

by Daniel Vetter

[permalink] [raw]
Subject: Re: [PATCH -next 0/8] drm/amd/amdgpu: fix comparison pointer to bool warning

On Wed, Sep 16, 2020 at 09:38:34AM +0200, Christian K?nig wrote:
> Am 15.09.20 um 21:35 schrieb Ville Syrj?l?:
> > On Tue, Sep 15, 2020 at 03:16:32PM -0400, Alex Deucher wrote:
> > > 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

+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

>
> Christian.
>
> >
> > > Alex
> > >
> > > On Wed, Sep 9, 2020 at 9:21 AM Christian K?nig <[email protected]> wrote:
> > > > Acked-by: Christian K?nig <[email protected]> for the series.
> > > >
> > > > Am 09.09.20 um 15:07 schrieb Zheng Bin:
> > > > > 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
> > > > >
> > > > _______________________________________________
> > > > 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

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

2020-09-16 18:04:28

by Alex Deucher

[permalink] [raw]
Subject: Re: [PATCH -next 0/8] drm/amd/amdgpu: fix comparison pointer to bool warning

On Wed, Sep 16, 2020 at 3:51 AM Daniel Vetter <[email protected]> wrote:
>
> On Wed, Sep 16, 2020 at 09:38:34AM +0200, Christian König wrote:
> > Am 15.09.20 um 21:35 schrieb Ville Syrjälä:
> > > On Tue, Sep 15, 2020 at 03:16:32PM -0400, Alex Deucher wrote:
> > > > 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
>
> +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 :-)

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

>
> Cheers, Daniel
>
> >
> > Christian.
> >
> > >
> > > > Alex
> > > >
> > > > On Wed, Sep 9, 2020 at 9:21 AM Christian König <[email protected]> wrote:
> > > > > Acked-by: Christian König <[email protected]> for the series.
> > > > >
> > > > > Am 09.09.20 um 15:07 schrieb Zheng Bin:
> > > > > > 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
> > > > > >
> > > > > _______________________________________________
> > > > > 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
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

2020-09-16 20:25:12

by Daniel Vetter

[permalink] [raw]
Subject: Re: [PATCH -next 0/8] drm/amd/amdgpu: fix comparison pointer to bool warning

On Wed, Sep 16, 2020 at 04:02:18PM +0200, Christian K?nig wrote:
> Am 16.09.20 um 15:36 schrieb Alex Deucher:
> > On Wed, Sep 16, 2020 at 3:51 AM Daniel Vetter <[email protected]> wrote:
> > > On Wed, Sep 16, 2020 at 09:38:34AM +0200, Christian K?nig wrote:
> > > > Am 15.09.20 um 21:35 schrieb Ville Syrj?l?:
> > > > > On Tue, Sep 15, 2020 at 03:16:32PM -0400, Alex Deucher wrote:
> > > > > > 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
> > > +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 :-)
> > 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

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

>
> Christian.
>
> >
> > Alex
> >
> > > Cheers, Daniel
> > >
> > > > Christian.
> > > >
> > > > > > Alex
> > > > > >
> > > > > > On Wed, Sep 9, 2020 at 9:21 AM Christian K?nig <[email protected]> wrote:
> > > > > > > Acked-by: Christian K?nig <[email protected]> for the series.
> > > > > > >
> > > > > > > Am 09.09.20 um 15:07 schrieb Zheng Bin:
> > > > > > > > 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
> > > > > > > >
> > > > > > > _______________________________________________
> > > > > > > amd-gfx mailing list
> > > > > > > [email protected]
> > > > > > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051676053&amp;sdata=MS0vcBcU7unXjEFlbd8kLbJkJ4sKcvIdLjc8yhX4UUI%3D&amp;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&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051686051&amp;sdata=MgfR%2BwCVY9gWfhQ9i5kWcKiiYkV1C8O2dEKlZYSqscE%3D&amp;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&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051686051&amp;sdata=MgfR%2BwCVY9gWfhQ9i5kWcKiiYkV1C8O2dEKlZYSqscE%3D&amp;reserved=0
> > > --
> > > Daniel Vetter
> > > Software Engineer, Intel Corporation
> > > https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll.ch%2F&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051686051&amp;sdata=GvLs5OXw2Ny%2BieJxm8hjawNb0rGA966539iAwlWwPMY%3D&amp;reserved=0
>
> _______________________________________________
> dri-devel mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

2020-09-16 20:54:30

by Christian König

[permalink] [raw]
Subject: Re: [PATCH -next 0/8] drm/amd/amdgpu: fix comparison pointer to bool warning

Am 16.09.20 um 15:36 schrieb Alex Deucher:
> On Wed, Sep 16, 2020 at 3:51 AM Daniel Vetter <[email protected]> wrote:
>> On Wed, Sep 16, 2020 at 09:38:34AM +0200, Christian König wrote:
>>> Am 15.09.20 um 21:35 schrieb Ville Syrjälä:
>>>> On Tue, Sep 15, 2020 at 03:16:32PM -0400, Alex Deucher wrote:
>>>>> 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
>> +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 :-)
> 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.

>
> Alex
>
>> Cheers, Daniel
>>
>>> Christian.
>>>
>>>>> Alex
>>>>>
>>>>> On Wed, Sep 9, 2020 at 9:21 AM Christian König <[email protected]> wrote:
>>>>>> Acked-by: Christian König <[email protected]> for the series.
>>>>>>
>>>>>> Am 09.09.20 um 15:07 schrieb Zheng Bin:
>>>>>>> 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
>>>>>>>
>>>>>> _______________________________________________
>>>>>> amd-gfx mailing list
>>>>>> [email protected]
>>>>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051676053&amp;sdata=MS0vcBcU7unXjEFlbd8kLbJkJ4sKcvIdLjc8yhX4UUI%3D&amp;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&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051686051&amp;sdata=MgfR%2BwCVY9gWfhQ9i5kWcKiiYkV1C8O2dEKlZYSqscE%3D&amp;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&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051686051&amp;sdata=MgfR%2BwCVY9gWfhQ9i5kWcKiiYkV1C8O2dEKlZYSqscE%3D&amp;reserved=0
>> --
>> Daniel Vetter
>> Software Engineer, Intel Corporation
>> https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll.ch%2F&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7Cdc7a8d7517d341e3a80c08d85a458ba8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637358602051686051&amp;sdata=GvLs5OXw2Ny%2BieJxm8hjawNb0rGA966539iAwlWwPMY%3D&amp;reserved=0