linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] platform/x86/intel/pmt: fix format string warnings
@ 2025-07-09 15:18 Arnd Bergmann
  0 siblings, 0 replies; only message in thread
From: Arnd Bergmann @ 2025-07-09 15:18 UTC (permalink / raw)
  To: David E. Box, Hans de Goede, Ilpo Järvinen
  Cc: Arnd Bergmann, platform-driver-x86, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

The %ld format string is for 'long'. size_t is the same length
but requires the use of '%zd' to avoid this portability warning:

drivers/platform/x86/intel/pmt/discovery.c: In function 'pmt_feature_get_feature_table':
drivers/platform/x86/intel/pmt/discovery.c:427:35: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
  427 |         if (WARN(size > res_size, "Bad table size %ld > %pa", size, &res_size))

Similarly, passing a string pointer as a format string means
that gcc is unable and warns when -Wformat-security is enabled:

drivers/platform/x86/intel/pmt/discovery.c: In function 'pmt_features_discovery':
drivers/platform/x86/intel/pmt/discovery.c:505:36: error: format not a string literal and no format arguments [-Werror=format-security]
  505 |                                    pmt_feature_names[feature->id]);
      |                                    ^~~~~~~~~~~~~~~~~

Fix both trivial format string warnings in the obvious way.

Fixes: d9a078809356 ("platform/x86/intel/pmt: Add PMT Discovery driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/platform/x86/intel/pmt/discovery.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/intel/pmt/discovery.c b/drivers/platform/x86/intel/pmt/discovery.c
index e72d43b675b4..763ed2a51523 100644
--- a/drivers/platform/x86/intel/pmt/discovery.c
+++ b/drivers/platform/x86/intel/pmt/discovery.c
@@ -424,7 +424,7 @@ pmt_feature_get_feature_table(struct pmt_features_priv *priv,
 	size = sizeof(*header) + FEAT_ATTR_SIZE(header->attr_size) +
 	       PMT_GUID_SIZE(header->num_guids);
 	res_size = resource_size(&res);
-	if (WARN(size > res_size, "Bad table size %ld > %pa", size, &res_size))
+	if (WARN(size > res_size, "Bad table size %zd > %pa", size, &res_size))
 		return -EINVAL;
 
 	/* Get the feature attributes, including capability fields */
@@ -502,7 +502,7 @@ static int pmt_features_discovery(struct pmt_features_priv *priv,
 	}
 
 	ret = kobject_init_and_add(&feature->kobj, ktype, &priv->dev->kobj,
-				   pmt_feature_names[feature->id]);
+				   "%s", pmt_feature_names[feature->id]);
 	if (ret)
 		return ret;
 
-- 
2.39.5


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-07-09 15:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-09 15:18 [PATCH] platform/x86/intel/pmt: fix format string warnings Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).