回覆: [PATCH] drm/amdgpu: Fix unsigned comparison with less than zero in vpe_u1_8_from_fraction()

Lee, Peyton Peyton.Lee at amd.com
Fri Jan 5 10:46:21 UTC 2024


[AMD Official Use Only - General]

Reviewed-by: Peyton Lee <peyton.lee at amd.com>

-----原始郵件-----
寄件者: SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM at amd.com>
寄件日期: Friday, January 5, 2024 6:41 PM
收件者: Deucher, Alexander <Alexander.Deucher at amd.com>; Koenig, Christian <Christian.Koenig at amd.com>
副本: amd-gfx at lists.freedesktop.org; SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM at amd.com>; Lee, Peyton <Peyton.Lee at amd.com>; Yu, Lang <Lang.Yu at amd.com>
主旨: [PATCH] drm/amdgpu: Fix unsigned comparison with less than zero in vpe_u1_8_from_fraction()

The variables 'numerator' and 'denominator', are unsigned 16-bit integer types, that can never be less than 0.

Thus fixing the below:
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c:62 vpe_u1_8_from_fraction() warn: unsigned 'numerator' is never less than zero.
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c:63 vpe_u1_8_from_fraction() warn: unsigned 'denominator' is never less than zero.

Cc: Peyton Lee <peytolee at amd.com>
Cc: Lang Yu <lang.yu at amd.com>
Cc: Christian König <christian.koenig at amd.com>
Cc: Alex Deucher <alexander.deucher at amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
index 6f149b54d4d3..b9a15d51eb5c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
@@ -59,11 +59,8 @@ static inline uint16_t complete_integer_division_u16(

 static uint16_t vpe_u1_8_from_fraction(uint16_t numerator, uint16_t denominator)  {
-       bool arg1_negative = numerator < 0;
-       bool arg2_negative = denominator < 0;
-
-       uint16_t arg1_value = (uint16_t)(arg1_negative ? -numerator : numerator);
-       uint16_t arg2_value = (uint16_t)(arg2_negative ? -denominator : denominator);
+       u16 arg1_value = numerator;
+       u16 arg2_value = denominator;

        uint16_t remainder;

@@ -100,9 +97,6 @@ static uint16_t vpe_u1_8_from_fraction(uint16_t numerator, uint16_t denominator)
                res_value += summand;
        }

-       if (arg1_negative ^ arg2_negative)
-               res_value = -res_value;
-
        return res_value;
 }

--
2.34.1



More information about the amd-gfx mailing list