Re: [PATCH] blk-iocost: fix seq_printf compile type mismatch error

From: Carlos Bilbao
Date: Mon Jul 17 2023 - 10:23:54 EST


On 7/17/23 09:18, Carlos Bilbao wrote:
From: amd <amd@localhost.localdomain>

Please disregard this "From" label.


Fix two type mismatch errors encountered while compiling blk-iocost.c with
GCC version 13.1.1 that involved constant operator WEIGHT_ONE. Cast the
result of the division operation to (unsigned int) to match the expected
format specifier %u in two seq_printf invocations.

Reviewed-by: Carlos Bilbao <carlos.bilbao@xxxxxxx>
---
block/blk-iocost.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 495396425bad..4721009a3f03 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -3032,7 +3032,7 @@ 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 %u\n", dname, (unsigned int)(iocg->cfg_weight / (unsigned int)WEIGHT_ONE));
return 0;
}
@@ -3042,7 +3042,7 @@ 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 %u\n", (unsigned int) (iocc->dfl_weight / (unsigned int)WEIGHT_ONE));
blkcg_print_blkgs(sf, blkcg, ioc_weight_prfill,
&blkcg_policy_iocost, seq_cft(sf)->private, false);
return 0;

Thanks,
Carlos