Skip to contentSkip to conversation

drm/vc4: use %z format string for size_t

PATCH In review Arnd Bergmann 2 participants 2 messages Nov 2, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/vc4: use %z format string for size_t

Printing a size_t variable needs to use the %z format string modifier rather than %l, otherwise we get this warning on 64-bit architectures:

drivers/gpu/drm/vc4/vc4_bo.c: In function 'vc4_bo_stats_debugfs':
drivers/gpu/drm/vc4/vc4_bo.c:91:26: error: format '%d' expects argument of type 'int', but argument 4 has type 'size_t {aka long unsigned int}' [-Werror=format=]

Fixes b9f19259b84d ("drm/vc4: Add the DRM_IOCTL_VC4_GEM_MADVISE ioctl")
---
 drivers/gpu/drm/vc4/vc4_bo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_bo.c +2 -2
index 3c3d11236910..4ae45d7dac42 100644
@@ -88,11 +88,11 @@ int vc4_bo_stats_debugfs(struct seq_file *m, void *unused)
 
 	mutex_lock(&vc4->purgeable.lock);
 	if (vc4->purgeable.num)
-		seq_printf(m, "%30s: %6dkb BOs (%d)\n", "userspace BO cache",
+		seq_printf(m, "%30s: %6zdkb BOs (%d)\n", "userspace BO cache",
 			   vc4->purgeable.size / 1024, vc4->purgeable.num);
 
 	if (vc4->purgeable.purged_num)
-		seq_printf(m, "%30s: %6dkb BOs (%d)\n", "total purged BO",
+		seq_printf(m, "%30s: %6zdkb BOs (%d)\n", "total purged BO",
 			   vc4->purgeable.purged_size / 1024,
 			   vc4->purgeable.purged_num);
 	mutex_unlock(&vc4->purgeable.lock);
Signature · 6 lines
2.9.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Hi Arnd,

Quoted 6 lines · On Thu, 2 Nov 2017 12:20:43 +0100 Arnd Bergmann <[email protected]> wrote:

Printing a size_t variable needs to use the %z format string modifier rather than %l, otherwise we get this warning on 64-bit architectures:

drivers/gpu/drm/vc4/vc4_bo.c: In function 'vc4_bo_stats_debugfs':
drivers/gpu/drm/vc4/vc4_bo.c:91:26: error: format '%d' expects argument of type 'int', but argument 4 has type 'size_t {aka long unsigned int}' [-Werror=format=]

I already sent (and applied) a fix for this bug [1].

Regards,

Boris

[1]https://patchwork.kernel.org/patch/10036075/

Quoted 14 lines
Fixes b9f19259b84d ("drm/vc4: Add the DRM_IOCTL_VC4_GEM_MADVISE ioctl")
---
 drivers/gpu/drm/vc4/vc4_bo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_bo.c +0 -0
index 3c3d11236910..4ae45d7dac42 100644
@@ -88,11 +88,11 @@ int vc4_bo_stats_debugfs(struct seq_file *m, void *unused)
 
 	mutex_lock(&vc4->purgeable.lock);
 	if (vc4->purgeable.num)

drivers/gpu/drm/vc4/vc4_bo.c int vc4_bo_stats_debugfs(struct seq_file *m, void *unused) · line 98

Quoted 10 lines
drivers/gpu/drm/vc4/vc4_bo.c +2 -2
-		seq_printf(m, "%30s: %6dkb BOs (%d)\n", "userspace BO cache",
+		seq_printf(m, "%30s: %6zdkb BOs (%d)\n", "userspace BO cache",
 			   vc4->purgeable.size / 1024, vc4->purgeable.num);
 
 	if (vc4->purgeable.purged_num)
-		seq_printf(m, "%30s: %6dkb BOs (%d)\n", "total purged BO",
+		seq_printf(m, "%30s: %6zdkb BOs (%d)\n", "total purged BO",
 			   vc4->purgeable.purged_size / 1024,
 			   vc4->purgeable.purged_num);
 	mutex_unlock(&vc4->purgeable.lock);

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel