diff mbox series

[v3] drm/display: Fix building with GCC 15

Message ID 20241002092311.942822-1-brahmajit.xyz@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v3] drm/display: Fix building with GCC 15 | expand

Commit Message

Brahmajit Das Oct. 2, 2024, 9:23 a.m. UTC
GCC 15 enables -Werror=unterminated-string-initialization by default.
This results in the following build error

drivers/gpu/drm/display/drm_dp_dual_mode_helper.c: In function ‘is_hdmi_adaptor’:
drivers/gpu/drm/display/drm_dp_dual_mode_helper.c:164:17: error: initializer-string for array of
 ‘char’ is too long [-Werror=unterminated-string-initialization]
  164 |                 "DP-HDMI ADAPTOR\x04";
      |                 ^~~~~~~~~~~~~~~~~~~~~

After discussion with Ville, the fix was to increase the size of
dp_dual_mode_hdmi_id array by one, so that it can accommodate the NULL
line character. This should let us build the kernel with GCC 15.

Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
---
 drivers/gpu/drm/display/drm_dp_dual_mode_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jani Nikula Oct. 10, 2024, 12:04 p.m. UTC | #1
On Wed, 02 Oct 2024, Jani Nikula <jani.nikula@linux.intel.com> wrote:
> On Wed, 02 Oct 2024, Brahmajit Das <brahmajit.xyz@gmail.com> wrote:
>> GCC 15 enables -Werror=unterminated-string-initialization by default.
>> This results in the following build error
>>
>> drivers/gpu/drm/display/drm_dp_dual_mode_helper.c: In function ‘is_hdmi_adaptor’:
>> drivers/gpu/drm/display/drm_dp_dual_mode_helper.c:164:17: error: initializer-string for array of
>>  ‘char’ is too long [-Werror=unterminated-string-initialization]
>>   164 |                 "DP-HDMI ADAPTOR\x04";
>>       |                 ^~~~~~~~~~~~~~~~~~~~~
>>
>> After discussion with Ville, the fix was to increase the size of
>> dp_dual_mode_hdmi_id array by one, so that it can accommodate the NULL
>> line character. This should let us build the kernel with GCC 15.
>
> Still s/NULL line/NUL/ but this can be fixed while applying, no need to
> resend.
>
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>

Pushed to drm-misc-next, and forgot to update the commit message. Oh
well. My bad.

Thanks for the patch.

BR,
Jani.

>
>
>>
>> Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
>> ---
>>  drivers/gpu/drm/display/drm_dp_dual_mode_helper.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c b/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c
>> index 14a2a8473682..c491e3203bf1 100644
>> --- a/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c
>> +++ b/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c
>> @@ -160,11 +160,11 @@ EXPORT_SYMBOL(drm_dp_dual_mode_write);
>>  
>>  static bool is_hdmi_adaptor(const char hdmi_id[DP_DUAL_MODE_HDMI_ID_LEN])
>>  {
>> -	static const char dp_dual_mode_hdmi_id[DP_DUAL_MODE_HDMI_ID_LEN] =
>> +	static const char dp_dual_mode_hdmi_id[DP_DUAL_MODE_HDMI_ID_LEN + 1] =
>>  		"DP-HDMI ADAPTOR\x04";
>>  
>>  	return memcmp(hdmi_id, dp_dual_mode_hdmi_id,
>> -		      sizeof(dp_dual_mode_hdmi_id)) == 0;
>> +		      DP_DUAL_MODE_HDMI_ID_LEN) == 0;
>>  }
>>  
>>  static bool is_type1_adaptor(uint8_t adaptor_id)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c b/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c
index 14a2a8473682..c491e3203bf1 100644
--- a/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c
+++ b/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c
@@ -160,11 +160,11 @@  EXPORT_SYMBOL(drm_dp_dual_mode_write);
 
 static bool is_hdmi_adaptor(const char hdmi_id[DP_DUAL_MODE_HDMI_ID_LEN])
 {
-	static const char dp_dual_mode_hdmi_id[DP_DUAL_MODE_HDMI_ID_LEN] =
+	static const char dp_dual_mode_hdmi_id[DP_DUAL_MODE_HDMI_ID_LEN + 1] =
 		"DP-HDMI ADAPTOR\x04";
 
 	return memcmp(hdmi_id, dp_dual_mode_hdmi_id,
-		      sizeof(dp_dual_mode_hdmi_id)) == 0;
+		      DP_DUAL_MODE_HDMI_ID_LEN) == 0;
 }
 
 static bool is_type1_adaptor(uint8_t adaptor_id)