lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 24 Oct 2022 21:01:56 +0200
From:   Martin Liška <mliska@...e.cz>
To:     linux-kernel@...r.kernel.org
Cc:     linux-block@...r.kernel.org, axboe@...nel.dk
Subject: [PATCH] block: fix Werror=format with GCC 13

Starting with GCC 13, since
[g3b3083a598ca3f4b] c: C2x enums wider than int [PR36113]

GCC promotes enum values with larger than integer types to a wider type.
In case of the anonymous enum type in blk-iocost.c it is:

enum {
	MILLION			= 1000000,
...

	WEIGHT_ONE		= 1 << 16,
...
	VTIME_PER_SEC_SHIFT	= 37,
	VTIME_PER_SEC		= 1LLU << VTIME_PER_SEC_SHIFT,
...

as seen VTIME_PER_SEC cannot fit into 32-bits (int type), thus one needs
to use 'long unsigned int' in the format string.

It fixes then the following 2 warnings:

block/blk-iocost.c: In function ‘ioc_weight_prfill’:
block/blk-iocost.c:3035:37: error: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘long unsigned int’ [-Werror=format=]
 3035 |                 seq_printf(sf, "%s %u\n", dname, iocg->cfg_weight / WEIGHT_ONE);
      |                                    ~^            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                     |                             |
      |                                     unsigned int                  long unsigned int
      |                                    %lu
block/blk-iocost.c: In function ‘ioc_weight_show’:
block/blk-iocost.c:3045:34: error: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘long unsigned int’ [-Werror=format=]
 3045 |         seq_printf(sf, "default %u\n", iocc->dfl_weight / WEIGHT_ONE);
      |                                 ~^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                  |                      |
      |                                  unsigned int           long unsigned int
      |                                 %lu

Signed-off-by: Martin Liska <mliska@...e.cz>
---
 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..f165bac9bffb 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 %lu\n", dname, iocg->cfg_weight / 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 %lu\n", iocc->dfl_weight / WEIGHT_ONE);
 	blkcg_print_blkgs(sf, blkcg, ioc_weight_prfill,
 			  &blkcg_policy_iocost, seq_cft(sf)->private, false);
 	return 0;
-- 
2.38.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ