>> The address of a data structure member was determined before
>> a corresponding null pointer check in the implementation of
>> the function “intel_bios_encoder_supports_dp_dual_mode”.
>>
>> Thus avoid the risk for undefined behaviour by reducing the scope for
>> the variable “child” behind condition checks.
…
>> +++ b/drivers/gpu/drm/i915/display/intel_bios.c
>> @@ -3514,8 +3514,6 @@ bool intel_bios_is_port_present(struct intel_display 
>> *display, enum port port)
>>  
>>  bool intel_bios_encoder_supports_dp_dual_mode(const struct 
>> intel_bios_encoder_data *devdata)
>>  {
>> -    const struct child_device_config *child = &devdata->child;
>> -
>>      if (!devdata)
>>              return false;
>>  
>> @@ -3523,6 +3521,8 @@ bool intel_bios_encoder_supports_dp_dual_mode(const 
>> struct intel_bios_encoder_da
>>          !intel_bios_encoder_supports_hdmi(devdata))
>>              return false;
>>  
>> +    const struct child_device_config *child = &devdata->child;
>> +
> 
> does it compile?
> 
> please keep the variable definition where it is and move only its
> assignment after the null check.
Would you find the proposed adjustment more acceptable if a bit of source code
would be moved into another function?
https://refactoring.com/catalog/extractFunction.html

Regards,
Markus

Reply via email to