All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block/blk-iocost (gcc13): cast enum members to int in prints
@ 2022-10-31 11:45 ` Jiri Slaby (SUSE)
  0 siblings, 0 replies; 25+ messages in thread
From: Jiri Slaby (SUSE) @ 2022-10-31 11:45 UTC (permalink / raw)
  To: tj
  Cc: linux-kernel, Jiri Slaby (SUSE),
	Martin Liska, Josef Bacik, Jens Axboe, cgroups, linux-block

Since gcc13, each member of an enum has the same type as the enum [1]. And
that is inherited from its members. Provided:
  VTIME_PER_SEC_SHIFT     = 37,
  VTIME_PER_SEC           = 1LLU << VTIME_PER_SEC_SHIFT,
the named type is unsigned long.

This generates warnings with gcc-13:
  block/blk-iocost.c: In function 'ioc_weight_prfill':
  block/blk-iocost.c:3037:37: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'long unsigned int'

  block/blk-iocost.c: In function 'ioc_weight_show':
  block/blk-iocost.c:3047:34: error: format '%u' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int'

Cast the enum members to int when printing them.

Alternatively, we can cast them to ulong (to silence gcc < 12) and use %lu.
Alternatively, we can move VTIME_PER_SEC away from the enum.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36113

Cc: Martin Liska <mliska@suse.cz>
Cc: Tejun Heo <tj@kernel.org>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: cgroups@vger.kernel.org
Cc: linux-block@vger.kernel.org
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 block/blk-iocost.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index f01359906c83..a257ba17183b 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -3034,7 +3034,8 @@ static u64 ioc_weight_prfill(struct seq_file *sf, struct blkg_policy_data *pd,
 	struct ioc_gq *iocg = pd_to_iocg(pd);
 
 	if (dname && iocg->cfg_weight)
-		seq_printf(sf, "%s %u\n", dname, iocg->cfg_weight / WEIGHT_ONE);
+		seq_printf(sf, "%s %d\n", dname,
+				iocg->cfg_weight / (int)WEIGHT_ONE);
 	return 0;
 }
 
@@ -3044,7 +3045,8 @@ static int ioc_weight_show(struct seq_file *sf, void *v)
 	struct blkcg *blkcg = css_to_blkcg(seq_css(sf));
 	struct ioc_cgrp *iocc = blkcg_to_iocc(blkcg);
 
-	seq_printf(sf, "default %u\n", iocc->dfl_weight / WEIGHT_ONE);
+	seq_printf(sf, "default %d\n",
+			iocc->dfl_weight / (int)WEIGHT_ONE);
 	blkcg_print_blkgs(sf, blkcg, ioc_weight_prfill,
 			  &blkcg_policy_iocost, seq_cft(sf)->private, false);
 	return 0;
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2022-12-13 12:58 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-31 11:45 [PATCH] block/blk-iocost (gcc13): cast enum members to int in prints Jiri Slaby (SUSE)
2022-10-31 11:45 ` Jiri Slaby (SUSE)
2022-10-31 12:24 ` Christoph Hellwig
2022-10-31 12:24   ` Christoph Hellwig
2022-10-31 17:57   ` Tejun Heo
2022-11-01  5:46     ` Jiri Slaby
2022-11-01  5:46       ` Jiri Slaby
2022-11-01 16:46       ` Tejun Heo
2022-11-01 16:46         ` Tejun Heo
2022-11-02  8:35         ` David Laight
2022-11-02 16:27           ` 'Tejun Heo'
2022-11-02 16:43             ` 'Tejun Heo'
2022-11-02 16:43               ` 'Tejun Heo'
2022-12-12 12:14               ` Jiri Slaby
2022-12-12 12:14                 ` Jiri Slaby
2022-12-12 21:46                 ` 'Tejun Heo'
2022-12-13  8:30                   ` David Laight
2022-12-13 11:15                     ` Jiri Slaby
2022-12-13 11:15                       ` Jiri Slaby
2022-12-13 11:50                       ` David Laight
2022-12-13 11:50                         ` David Laight
2022-12-13 12:05                         ` Jiri Slaby
2022-12-13 12:05                           ` Jiri Slaby
2022-12-13 12:58                           ` David Laight
2022-12-13 12:58                             ` David Laight

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.