Skip to contentSkip to conversation

drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init

PATCH Superseded Nirmoy Das 3 participants 3 messages Oct 25, 2023

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Nirmoy Das

author
#0 lore raw

PATCH 1/1 drm/i915/tc: Fix -Wformat-truncation in intel_tc_port_init

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 <[email protected]>
Cc Imre Deak <[email protected]>
Cc Jani Nikula <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_tc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_tc.c +1 -1
index 37b0f8529b4f..0afcee279aff 100644
@@ -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;
Signature · 1 line
2.41.0
#1 lore raw
Quoted 29 lines · 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 <[email protected]>
Cc Imre Deak <[email protected]>
Cc Jani Nikula <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_tc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_tc.c +0 -0
index 37b0f8529b4f..0afcee279aff 100644

drivers/gpu/drm/i915/display/intel_tc.c struct intel_tc_port { · line 61

Quoted 5 lines
drivers/gpu/drm/i915/display/intel_tc.c +1 -1
@@ -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].

Quoted 6 lines
drivers/gpu/drm/i915/display/intel_tc.c +0 -0
 	enum tc_port_mode mode;
 	enum tc_port_mode init_mode;
 	enum phy_fia phy_fia;
Signature · 1 line
2.41.0
#2 lore raw
Quoted 37 lines · Imre Deak
Quoted 29 lines · 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 <[email protected]>
Cc Imre Deak <[email protected]>
Cc Jani Nikula <[email protected]>
---
  drivers/gpu/drm/i915/display/intel_tc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_tc.c +0 -0
index 37b0f8529b4f..0afcee279aff 100644

drivers/gpu/drm/i915/display/intel_tc.c struct intel_tc_port { · line 61

Quoted 5 lines
drivers/gpu/drm/i915/display/intel_tc.c +1 -1
@@ -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.

Quoted 2 lines

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

Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/i915/display/intel_tc.c +0 -0
  	enum tc_port_mode mode;
  	enum tc_port_mode init_mode;
  	enum phy_fia phy_fia;
Signature · 1 line
2.41.0