* [PATCH] platform/x86/intel/pmt/discovery: Fix size_t specifiers for 32-bit
@ 2025-07-08 23:41 Nathan Chancellor
2025-07-09 8:37 ` Ilpo Järvinen
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2025-07-08 23:41 UTC (permalink / raw)
To: David E. Box, Hans de Goede, Ilpo Järvinen
Cc: platform-driver-x86, linux-kernel, Nathan Chancellor
When building i386 allmodconfig, there are two warnings in the newly
added discovery code:
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))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~
| |
| size_t {aka unsigned int}
...
drivers/platform/x86/intel/pmt/discovery.c:427:53: note: format string is defined here
427 | if (WARN(size > res_size, "Bad table size %ld > %pa", size, &res_size))
| ~~^
| |
| long int
| %d
drivers/platform/x86/intel/pmt/discovery-kunit.c: In function 'validate_pmt_regions':
include/linux/kern_levels.h:5:25: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
...
drivers/platform/x86/intel/pmt/discovery-kunit.c:35:17: note: in expansion of macro 'kunit_info'
35 | kunit_info(test, "\t\taddr=%p, size=%lu, num_rmids=%u", region->addr, region->size,
| ^~~~~~~~~~
size_t is 'unsigned long' for 64-bit platforms but 'unsigned int' for
32-bit platforms, so '%ld' is not correct. Use the proper size_t
specifier, '%zu', to resolve the warnings on 32-bit platforms while not
affecting 64-bit platforms.
Fixes: d9a078809356 ("platform/x86/intel/pmt: Add PMT Discovery driver")
Fixes: b9707d46a959 ("platform/x86/intel/pmt: KUNIT test for PMT Enhanced Discovery API")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
drivers/platform/x86/intel/pmt/discovery-kunit.c | 2 +-
drivers/platform/x86/intel/pmt/discovery.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/intel/pmt/discovery-kunit.c b/drivers/platform/x86/intel/pmt/discovery-kunit.c
index b4493fb96738..f44eb41d58f6 100644
--- a/drivers/platform/x86/intel/pmt/discovery-kunit.c
+++ b/drivers/platform/x86/intel/pmt/discovery-kunit.c
@@ -32,7 +32,7 @@ validate_pmt_regions(struct kunit *test, struct pmt_feature_group *feature_group
kunit_info(test, "\t\tbus=%u, device=%u, function=%u, guid=0x%x,",
region->plat_info.bus_number, region->plat_info.device_number,
region->plat_info.function_number, region->guid);
- kunit_info(test, "\t\taddr=%p, size=%lu, num_rmids=%u", region->addr, region->size,
+ kunit_info(test, "\t\taddr=%p, size=%zu, num_rmids=%u", region->addr, region->size,
region->num_rmids);
diff --git a/drivers/platform/x86/intel/pmt/discovery.c b/drivers/platform/x86/intel/pmt/discovery.c
index e72d43b675b4..1a680a042a98 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 %zu > %pa", size, &res_size))
return -EINVAL;
/* Get the feature attributes, including capability fields */
---
base-commit: 56036d6af41a473a8129fc960a5ab3673eda13d5
change-id: 20250708-discovery-pmt-fix-32-bit-formats-369370459309
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] platform/x86/intel/pmt/discovery: Fix size_t specifiers for 32-bit
2025-07-08 23:41 [PATCH] platform/x86/intel/pmt/discovery: Fix size_t specifiers for 32-bit Nathan Chancellor
@ 2025-07-09 8:37 ` Ilpo Järvinen
0 siblings, 0 replies; 2+ messages in thread
From: Ilpo Järvinen @ 2025-07-09 8:37 UTC (permalink / raw)
To: Nathan Chancellor, Randy Dunlap
Cc: David E. Box, Hans de Goede, platform-driver-x86, LKML
On Tue, 8 Jul 2025, Nathan Chancellor wrote:
> When building i386 allmodconfig, there are two warnings in the newly
> added discovery code:
>
> 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))
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~
> | |
> | size_t {aka unsigned int}
> ...
> drivers/platform/x86/intel/pmt/discovery.c:427:53: note: format string is defined here
> 427 | if (WARN(size > res_size, "Bad table size %ld > %pa", size, &res_size))
> | ~~^
> | |
> | long int
> | %d
>
> drivers/platform/x86/intel/pmt/discovery-kunit.c: In function 'validate_pmt_regions':
> include/linux/kern_levels.h:5:25: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
> ...
> drivers/platform/x86/intel/pmt/discovery-kunit.c:35:17: note: in expansion of macro 'kunit_info'
> 35 | kunit_info(test, "\t\taddr=%p, size=%lu, num_rmids=%u", region->addr, region->size,
> | ^~~~~~~~~~
>
> size_t is 'unsigned long' for 64-bit platforms but 'unsigned int' for
> 32-bit platforms, so '%ld' is not correct. Use the proper size_t
> specifier, '%zu', to resolve the warnings on 32-bit platforms while not
> affecting 64-bit platforms.
>
> Fixes: d9a078809356 ("platform/x86/intel/pmt: Add PMT Discovery driver")
> Fixes: b9707d46a959 ("platform/x86/intel/pmt: KUNIT test for PMT Enhanced Discovery API")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> drivers/platform/x86/intel/pmt/discovery-kunit.c | 2 +-
> drivers/platform/x86/intel/pmt/discovery.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/intel/pmt/discovery-kunit.c b/drivers/platform/x86/intel/pmt/discovery-kunit.c
> index b4493fb96738..f44eb41d58f6 100644
> --- a/drivers/platform/x86/intel/pmt/discovery-kunit.c
> +++ b/drivers/platform/x86/intel/pmt/discovery-kunit.c
> @@ -32,7 +32,7 @@ validate_pmt_regions(struct kunit *test, struct pmt_feature_group *feature_group
> kunit_info(test, "\t\tbus=%u, device=%u, function=%u, guid=0x%x,",
> region->plat_info.bus_number, region->plat_info.device_number,
> region->plat_info.function_number, region->guid);
> - kunit_info(test, "\t\taddr=%p, size=%lu, num_rmids=%u", region->addr, region->size,
> + kunit_info(test, "\t\taddr=%p, size=%zu, num_rmids=%u", region->addr, region->size,
> region->num_rmids);
>
>
> diff --git a/drivers/platform/x86/intel/pmt/discovery.c b/drivers/platform/x86/intel/pmt/discovery.c
> index e72d43b675b4..1a680a042a98 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 %zu > %pa", size, &res_size))
> return -EINVAL;
>
> /* Get the feature attributes, including capability fields */
>
> ---
Thanks for the patch, I've applied this to the for-next branch. I added
a few tags based on the report from Randy.
--
i.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-09 8:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-08 23:41 [PATCH] platform/x86/intel/pmt/discovery: Fix size_t specifiers for 32-bit Nathan Chancellor
2025-07-09 8:37 ` Ilpo Järvinen
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).