linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] block/blk-iocost (gcc13): keep large values in a new enum
@ 2022-12-13 12:08 Jiri Slaby (SUSE)
  2022-12-14 16:56 ` Jens Axboe
  2022-12-14 16:56 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Jiri Slaby (SUSE) @ 2022-12-13 12:08 UTC (permalink / raw)
  To: Tejun Heo
  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,
  ...
  AUTOP_CYCLE_NSEC        = 10LLU * NSEC_PER_SEC,
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'

So split the anonumois enum with large values to a separate enum, so
that they don't affect other members.

[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>
---

Notes:
    [v3] move more to a new enum (effectively split the enums)
    [v2] move to a new enum

 block/blk-iocost.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index d1bdc12deaa7..549ddc9e0c6f 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -232,7 +232,9 @@ enum {
 
 	/* 1/64k is granular enough and can easily be handled w/ u32 */
 	WEIGHT_ONE		= 1 << 16,
+};
 
+enum {
 	/*
 	 * As vtime is used to calculate the cost of each IO, it needs to
 	 * be fairly high precision.  For example, it should be able to
-- 
2.39.0


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

* Re: [PATCH v3] block/blk-iocost (gcc13): keep large values in a new enum
  2022-12-13 12:08 [PATCH v3] block/blk-iocost (gcc13): keep large values in a new enum Jiri Slaby (SUSE)
@ 2022-12-14 16:56 ` Jens Axboe
  2022-12-14 16:56 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2022-12-14 16:56 UTC (permalink / raw)
  To: Jiri Slaby (SUSE), Tejun Heo
  Cc: linux-kernel, Martin Liska, Josef Bacik, cgroups, linux-block

On 12/13/22 5:08 AM, Jiri Slaby (SUSE) wrote:
> 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,
>   ...
>   AUTOP_CYCLE_NSEC        = 10LLU * NSEC_PER_SEC,
> 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'
> 
> So split the anonumois enum with large values to a separate enum, so

anonymous?

-- 
Jens Axboe



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

* Re: [PATCH v3] block/blk-iocost (gcc13): keep large values in a new enum
  2022-12-13 12:08 [PATCH v3] block/blk-iocost (gcc13): keep large values in a new enum Jiri Slaby (SUSE)
  2022-12-14 16:56 ` Jens Axboe
@ 2022-12-14 16:56 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2022-12-14 16:56 UTC (permalink / raw)
  To: Tejun Heo, Jiri Slaby (SUSE)
  Cc: linux-kernel, Martin Liska, Josef Bacik, cgroups, linux-block


On Tue, 13 Dec 2022 13:08:26 +0100, Jiri Slaby (SUSE) wrote:
> 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,
>   ...
>   AUTOP_CYCLE_NSEC        = 10LLU * NSEC_PER_SEC,
> the named type is unsigned long.
> 
> [...]

Applied, thanks!

[1/1] block/blk-iocost (gcc13): keep large values in a new enum
      commit: ff1cc97b1f4c10db224f276d9615b22835b8c424

Best regards,
-- 
Jens Axboe



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

end of thread, other threads:[~2022-12-14 16:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-13 12:08 [PATCH v3] block/blk-iocost (gcc13): keep large values in a new enum Jiri Slaby (SUSE)
2022-12-14 16:56 ` Jens Axboe
2022-12-14 16:56 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).