Skip to content

Commit 428f6f3

Browse files
nathanchanceij-intel
authored andcommitted
platform/x86/intel/pmt/discovery: Fix size_t specifiers for 32-bit
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. Reported-by: Randy Dunlap <rdunlap@infradead.org> Reported-by: kernelci.org bot <bot@kernelci.org> Fixes: d9a0788 ("platform/x86/intel/pmt: Add PMT Discovery driver") Fixes: b9707d4 ("platform/x86/intel/pmt: KUNIT test for PMT Enhanced Discovery API") Closes: https://lore.kernel.org/all/CACo-S-29Degjym-azsJNSd1yofLOB2_Rf5xpa9b7L-14OPn7wQ@mail.gmail.com/ Signed-off-by: Nathan Chancellor <nathan@kernel.org> Link: https://lore.kernel.org/r/20250708-discovery-pmt-fix-32-bit-formats-v1-1-296a5fc9c3d4@kernel.org Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 56036d6 commit 428f6f3

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/platform/x86/intel/pmt/discovery-kunit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ validate_pmt_regions(struct kunit *test, struct pmt_feature_group *feature_group
3232
kunit_info(test, "\t\tbus=%u, device=%u, function=%u, guid=0x%x,",
3333
region->plat_info.bus_number, region->plat_info.device_number,
3434
region->plat_info.function_number, region->guid);
35-
kunit_info(test, "\t\taddr=%p, size=%lu, num_rmids=%u", region->addr, region->size,
35+
kunit_info(test, "\t\taddr=%p, size=%zu, num_rmids=%u", region->addr, region->size,
3636
region->num_rmids);
3737

3838

drivers/platform/x86/intel/pmt/discovery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ pmt_feature_get_feature_table(struct pmt_features_priv *priv,
424424
size = sizeof(*header) + FEAT_ATTR_SIZE(header->attr_size) +
425425
PMT_GUID_SIZE(header->num_guids);
426426
res_size = resource_size(&res);
427-
if (WARN(size > res_size, "Bad table size %ld > %pa", size, &res_size))
427+
if (WARN(size > res_size, "Bad table size %zu > %pa", size, &res_size))
428428
return -EINVAL;
429429

430430
/* Get the feature attributes, including capability fields */

0 commit comments

Comments
 (0)