* [Intel-gfx] [PATCH] drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init
@ 2023-10-25 13:57 Nirmoy Das
2023-10-25 15:45 ` Imre Deak
0 siblings, 1 reply; 3+ messages in thread
From: Nirmoy Das @ 2023-10-25 13:57 UTC (permalink / raw)
To: intel-gfx; +Cc: Jani Nikula, Nirmoy Das
Fix below compiler warning:
intel_tc.c:1879:11: error: ‘%d’ directive output may be truncated
writing between 1 and 11 bytes into a region of size 3
[-Werror=format-truncation=]
"%c/TC#%d", port_name(port), tc_port + 1);
^~
intel_tc.c:1878:2: note: ‘snprintf’ output between 7 and 17 bytes
into a destination of size 8
snprintf(tc->port_name, sizeof(tc->port_name),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"%c/TC#%d", port_name(port), tc_port + 1);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixes: fe03f637b7bd ("drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init")
intel_tc_port struct")
Cc: Mika Kahola <mika.kahola@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
---
drivers/gpu/drm/i915/display/intel_tc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/display/intel_tc.c b/drivers/gpu/drm/i915/display/intel_tc.c
index 37b0f8529b4f..0afcee279aff 100644
--- a/drivers/gpu/drm/i915/display/intel_tc.c
+++ b/drivers/gpu/drm/i915/display/intel_tc.c
@@ -58,7 +58,7 @@ struct intel_tc_port {
struct delayed_work link_reset_work;
int link_refcount;
bool legacy_port:1;
- char port_name[8];
+ char port_name[17];
enum tc_port_mode mode;
enum tc_port_mode init_mode;
enum phy_fia phy_fia;
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init
2023-10-25 13:57 [Intel-gfx] [PATCH] drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init Nirmoy Das
@ 2023-10-25 15:45 ` Imre Deak
2023-10-25 15:56 ` Nirmoy Das
0 siblings, 1 reply; 3+ messages in thread
From: Imre Deak @ 2023-10-25 15:45 UTC (permalink / raw)
To: Nirmoy Das; +Cc: Jani Nikula, intel-gfx
On Wed, Oct 25, 2023 at 03:57:26PM +0200, Nirmoy Das wrote:
> Fix below compiler warning:
>
> intel_tc.c:1879:11: error: ‘%d’ directive output may be truncated
> writing between 1 and 11 bytes into a region of size 3
> [-Werror=format-truncation=]
> "%c/TC#%d", port_name(port), tc_port + 1);
> ^~
> intel_tc.c:1878:2: note: ‘snprintf’ output between 7 and 17 bytes
> into a destination of size 8
> snprintf(tc->port_name, sizeof(tc->port_name),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> "%c/TC#%d", port_name(port), tc_port + 1);
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Fixes: fe03f637b7bd ("drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init")
> intel_tc_port struct")
> Cc: Mika Kahola <mika.kahola@intel.com>
> Cc: Imre Deak <imre.deak@intel.com>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_tc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_tc.c b/drivers/gpu/drm/i915/display/intel_tc.c
> index 37b0f8529b4f..0afcee279aff 100644
> --- a/drivers/gpu/drm/i915/display/intel_tc.c
> +++ b/drivers/gpu/drm/i915/display/intel_tc.c
> @@ -58,7 +58,7 @@ struct intel_tc_port {
> struct delayed_work link_reset_work;
> int link_refcount;
> bool legacy_port:1;
> - char port_name[8];
> + char port_name[17];
I'd use instead kasprintf() to suppress the warn.
Imo (at one point) the 'Port %s:', tc->port_name prefix could be
replaced by the usual [ENCODER:%d:%s].
> enum tc_port_mode mode;
> enum tc_port_mode init_mode;
> enum phy_fia phy_fia;
> --
> 2.41.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init
2023-10-25 15:45 ` Imre Deak
@ 2023-10-25 15:56 ` Nirmoy Das
0 siblings, 0 replies; 3+ messages in thread
From: Nirmoy Das @ 2023-10-25 15:56 UTC (permalink / raw)
To: imre.deak, Nirmoy Das; +Cc: Jani Nikula, intel-gfx
On 10/25/2023 5:45 PM, Imre Deak wrote:
> On Wed, Oct 25, 2023 at 03:57:26PM +0200, Nirmoy Das wrote:
>> Fix below compiler warning:
>>
>> intel_tc.c:1879:11: error: ‘%d’ directive output may be truncated
>> writing between 1 and 11 bytes into a region of size 3
>> [-Werror=format-truncation=]
>> "%c/TC#%d", port_name(port), tc_port + 1);
>> ^~
>> intel_tc.c:1878:2: note: ‘snprintf’ output between 7 and 17 bytes
>> into a destination of size 8
>> snprintf(tc->port_name, sizeof(tc->port_name),
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> "%c/TC#%d", port_name(port), tc_port + 1);
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> Fixes: fe03f637b7bd ("drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init")
>> intel_tc_port struct")
>> Cc: Mika Kahola <mika.kahola@intel.com>
>> Cc: Imre Deak <imre.deak@intel.com>
>> Cc: Jani Nikula <jani.nikula@intel.com>
>> Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
>> ---
>> drivers/gpu/drm/i915/display/intel_tc.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/display/intel_tc.c b/drivers/gpu/drm/i915/display/intel_tc.c
>> index 37b0f8529b4f..0afcee279aff 100644
>> --- a/drivers/gpu/drm/i915/display/intel_tc.c
>> +++ b/drivers/gpu/drm/i915/display/intel_tc.c
>> @@ -58,7 +58,7 @@ struct intel_tc_port {
>> struct delayed_work link_reset_work;
>> int link_refcount;
>> bool legacy_port:1;
>> - char port_name[8];
>> + char port_name[17];
> I'd use instead kasprintf() to suppress the warn.
>
> Imo (at one point) the 'Port %s:', tc->port_name prefix could be
> replaced by the usual [ENCODER:%d:%s].
That is even better, thanks I will resend.
Regards,
Nirmoy
>
>> enum tc_port_mode mode;
>> enum tc_port_mode init_mode;
>> enum phy_fia phy_fia;
>> --
>> 2.41.0
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-25 15:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-25 13:57 [Intel-gfx] [PATCH] drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init Nirmoy Das
2023-10-25 15:45 ` Imre Deak
2023-10-25 15:56 ` Nirmoy Das
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.