Skip to content

Commit

Permalink
drm/amd/display: fix overflow on MIN_I64 definition
Browse files Browse the repository at this point in the history
[ Upstream commit 6ae0632 ]

The definition of MIN_I64 in bw_fixed.c can cause gcc to whinge about
integer overflow, because it is treated as a positive value, which is
then negated. The temporary positive value is not necessarily
representable.

This causes the following warning:
../drivers/gpu/drm/amd/amdgpu/../display/dc/dml/calcs/bw_fixed.c:30:19:
warning: integer overflow in expression ‘-9223372036854775808’ of type
‘long long int’ results in ‘-9223372036854775808’ [-Woverflow]
  30 |         (int64_t)(-(1LL << 63))
     |                   ^

Writing out (-MAX_I64 - 1) works instead.

Signed-off-by: David Gow <davidgow@google.com>
Signed-off-by: Tales Aparecida <tales.aparecida@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
sulix authored and gregkh committed Oct 21, 2022
1 parent 912f84e commit 8a5e004
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/gpu/drm/amd/display/dc/dml/calcs/bw_fixed.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
#include "bw_fixed.h"


#define MIN_I64 \
(int64_t)(-(1LL << 63))

#define MAX_I64 \
(int64_t)((1ULL << 63) - 1)

#define MIN_I64 \
(-MAX_I64 - 1)

#define FRACTIONAL_PART_MASK \
((1ULL << BW_FIXED_BITS_PER_FRACTIONAL_PART) - 1)

Expand Down

0 comments on commit 8a5e004

Please sign in to comment.