Commit 8e8272f0 authored by Srinivasan Shanmugam's avatar Srinivasan Shanmugam Committed by Alex Deucher

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@amd.com>
Cc: Lang Yu <lang.yu@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: default avatarPeyton Lee <peyton.lee@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent fac4ebd7
...@@ -59,11 +59,8 @@ static inline uint16_t complete_integer_division_u16( ...@@ -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) static uint16_t vpe_u1_8_from_fraction(uint16_t numerator, uint16_t denominator)
{ {
bool arg1_negative = numerator < 0; u16 arg1_value = numerator;
bool arg2_negative = denominator < 0; u16 arg2_value = denominator;
uint16_t arg1_value = (uint16_t)(arg1_negative ? -numerator : numerator);
uint16_t arg2_value = (uint16_t)(arg2_negative ? -denominator : denominator);
uint16_t remainder; uint16_t remainder;
...@@ -100,9 +97,6 @@ static uint16_t vpe_u1_8_from_fraction(uint16_t numerator, uint16_t denominator) ...@@ -100,9 +97,6 @@ static uint16_t vpe_u1_8_from_fraction(uint16_t numerator, uint16_t denominator)
res_value += summand; res_value += summand;
} }
if (arg1_negative ^ arg2_negative)
res_value = -res_value;
return res_value; return res_value;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment