Skip to content

Commit 672e78c

Browse files
nathanchancealexdeucher
authored andcommitted
drm/amd/display: Pass app_tf by value rather than by reference
Clang warns when an expression that equals zero is used as a null pointer constant (in lieu of NULL): drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:4435:3: warning: expression which evaluates to zero treated as a null pointer constant of type 'const enum color_transfer_func *' [-Wnon-literal-null-conversion] TRANSFER_FUNC_UNKNOWN, ^~~~~~~~~~~~~~~~~~~~~ 1 warning generated. This warning is caused by commit bb47de7 ("drm/amdgpu: Set FreeSync state using drm VRR properties") and it could be solved by using NULL instead of TRANSFER_FUNC_UNKNOWN or casting TRANSFER_FUNC_UNKNOWN as a pointer. However, after looking into it, there doesn't appear to be a good reason to pass app_tf by reference as it is never mutated along the way. This is the only code path in which app_tf is used: mod_freesync_build_vrr_infopacket -> build_vrr_infopacket_v2 -> build_vrr_infopacket_fs2_data Neither mod_freesync_build_vrr_infopacket or build_vrr_infopacket_v2 modify app_tf's value and build_vrr_infopacket_fs2_data expects just the value so we can avoid dereferencing anything by just passing in app_tf's value to mod_freesync_build_vrr_infopacket and build_vrr_infopacket_v2. There is no functional change because build_vrr_infopacket_fs2_data doesn't do anything if TRANSFER_FUNC_UNKNOWN is passed to it, the same as not calling build_vrr_infopacket_fs2_data at all like before this change when NULL was used for app_tf. Reviewed-by: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 7db329e commit 672e78c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

drivers/gpu/drm/amd/display/modules/freesync/freesync.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -724,16 +724,15 @@ static void build_vrr_infopacket_v1(enum signal_type signal,
724724

725725
static void build_vrr_infopacket_v2(enum signal_type signal,
726726
const struct mod_vrr_params *vrr,
727-
const enum color_transfer_func *app_tf,
727+
enum color_transfer_func app_tf,
728728
struct dc_info_packet *infopacket)
729729
{
730730
unsigned int payload_size = 0;
731731

732732
build_vrr_infopacket_header_v2(signal, infopacket, &payload_size);
733733
build_vrr_infopacket_data(vrr, infopacket);
734734

735-
if (app_tf != NULL)
736-
build_vrr_infopacket_fs2_data(*app_tf, infopacket);
735+
build_vrr_infopacket_fs2_data(app_tf, infopacket);
737736

738737
build_vrr_infopacket_checksum(&payload_size, infopacket);
739738

@@ -757,7 +756,7 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
757756
const struct dc_stream_state *stream,
758757
const struct mod_vrr_params *vrr,
759758
enum vrr_packet_type packet_type,
760-
const enum color_transfer_func *app_tf,
759+
enum color_transfer_func app_tf,
761760
struct dc_info_packet *infopacket)
762761
{
763762
/* SPD info packet for FreeSync

drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
145145
const struct dc_stream_state *stream,
146146
const struct mod_vrr_params *vrr,
147147
enum vrr_packet_type packet_type,
148-
const enum color_transfer_func *app_tf,
148+
enum color_transfer_func app_tf,
149149
struct dc_info_packet *infopacket);
150150

151151
void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,

0 commit comments

Comments
 (0)