drm/amd/display: Pass app_tf by value rather than by reference
authorNathan Chancellor <natechancellor@gmail.com>
Mon, 10 Dec 2018 23:42:01 +0000 (16:42 -0700)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 28 Feb 2019 03:23:55 +0000 (22:23 -0500)
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 bb47de736661 ("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>
drivers/gpu/drm/amd/display/modules/freesync/freesync.c
drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h

index 94a84bc57c7a6a5db2604fbaf4d2ef9ae40e445d..bfd27f10879e98bb866b6877fc9c0a8b1e4188b5 100644 (file)
@@ -724,7 +724,7 @@ static void build_vrr_infopacket_v1(enum signal_type signal,
 
 static void build_vrr_infopacket_v2(enum signal_type signal,
                const struct mod_vrr_params *vrr,
-               const enum color_transfer_func *app_tf,
+               enum color_transfer_func app_tf,
                struct dc_info_packet *infopacket)
 {
        unsigned int payload_size = 0;
@@ -732,8 +732,7 @@ static void build_vrr_infopacket_v2(enum signal_type signal,
        build_vrr_infopacket_header_v2(signal, infopacket, &payload_size);
        build_vrr_infopacket_data(vrr, infopacket);
 
-       if (app_tf != NULL)
-               build_vrr_infopacket_fs2_data(*app_tf, infopacket);
+       build_vrr_infopacket_fs2_data(app_tf, infopacket);
 
        build_vrr_infopacket_checksum(&payload_size, infopacket);
 
@@ -757,7 +756,7 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
                const struct dc_stream_state *stream,
                const struct mod_vrr_params *vrr,
                enum vrr_packet_type packet_type,
-               const enum color_transfer_func *app_tf,
+               enum color_transfer_func app_tf,
                struct dc_info_packet *infopacket)
 {
        /* SPD info packet for FreeSync
index 4222e403b15150f43d50e75822844b47570107e4..dcef85994c45d189065f8723f1c7b9471538e5ca 100644 (file)
@@ -145,7 +145,7 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
                const struct dc_stream_state *stream,
                const struct mod_vrr_params *vrr,
                enum vrr_packet_type packet_type,
-               const enum color_transfer_func *app_tf,
+               enum color_transfer_func app_tf,
                struct dc_info_packet *infopacket);
 
 void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,