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
Fixes coccicheck warning:
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:2805:5-11: WARNING: Comparison to bool
Signed-off-by: Zheng Bin zhengbin13@huawei.com --- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c index fed2690d1380..20d8a03ca866 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c @@ -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
Fixes coccicheck warning:
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:3563:5-31: WARNING: Comparison to bool
Signed-off-by: Zheng Bin zhengbin13@huawei.com --- 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
Fixes coccicheck warning:
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c:619:5-11: WARNING: Comparison to bool
Signed-off-by: Zheng Bin zhengbin13@huawei.com --- drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c index e2232dd12d8e..48c95a78a173 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c @@ -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
Fixes coccicheck warning:
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c:562:5-11: WARNING: Comparison to bool
Signed-off-by: Zheng Bin zhengbin13@huawei.com --- 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
Fixes coccicheck warning:
drivers/gpu/drm/amd/amdgpu/si.c:1342:5-10: WARNING: Comparison to bool
Signed-off-by: Zheng Bin zhengbin13@huawei.com --- 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
Fixes coccicheck warning:
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c:1243:14-25: WARNING: Comparison to bool
Signed-off-by: Zheng Bin zhengbin13@huawei.com --- 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
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 zhengbin13@huawei.com --- 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
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
Signed-off-by: Zheng Bin zhengbin13@huawei.com --- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c index f975dc4b143a..e8e7d4228b92 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c @@ -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
Acked-by: Christian König christian.koenig@amd.com 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
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 christian.koenig@amd.com wrote:
Acked-by: Christian König christian.koenig@amd.com 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 amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
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 christian.koenig@amd.com wrote:
Acked-by: Christian König christian.koenig@amd.com 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 amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
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 christian.koenig@amd.com wrote:
Acked-by: Christian König christian.koenig@amd.com 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 amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
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 christian.koenig@amd.com wrote:
Acked-by: Christian König christian.koenig@amd.com 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 amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
On Wed, Sep 16, 2020 at 3:51 AM Daniel Vetter daniel@ffwll.ch 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 christian.koenig@amd.com wrote:
Acked-by: Christian König christian.koenig@amd.com 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 amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
-- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Am 16.09.20 um 15:36 schrieb Alex Deucher:
On Wed, Sep 16, 2020 at 3:51 AM Daniel Vetter daniel@ffwll.ch 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 christian.koenig@amd.com wrote:
Acked-by: Christian König christian.koenig@amd.com 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 amd-gfx@lists.freedesktop.org https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.free...
dri-devel mailing list dri-devel@lists.freedesktop.org https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.free...
dri-devel mailing list dri-devel@lists.freedesktop.org https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.free...
-- Daniel Vetter Software Engineer, Intel Corporation https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll....
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 daniel@ffwll.ch 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 christian.koenig@amd.com wrote: > Acked-by: Christian König christian.koenig@amd.com 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 > amd-gfx@lists.freedesktop.org > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.free... _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.free...
dri-devel mailing list dri-devel@lists.freedesktop.org https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.free...
-- Daniel Vetter Software Engineer, Intel Corporation https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll....
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
dri-devel@lists.freedesktop.org