• Nathan Chancellor's avatar
    drm/amd/display: Pass app_tf by value rather than by reference · 672e78ca
    Nathan Chancellor authored
    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 bb47de73 ("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: default avatarHarry Wentland <harry.wentland@amd.com>
    Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
    Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    672e78ca
mod_freesync.h 5.46 KB