* [PATCH] block: uapi: Fix compliation warning of using IOPRIO_PRIO_DATA
@ 2024-05-31 11:31 Zhiguo Niu
2024-05-31 20:13 ` Bart Van Assche
0 siblings, 1 reply; 4+ messages in thread
From: Zhiguo Niu @ 2024-05-31 11:31 UTC (permalink / raw)
To: axboe; +Cc: bvanassche, dlemoal, linux-kernel, niuzhiguo84, zhiguo.niu, ke.wang
Generally, the input of IOPRIO_PRIO_DATA has 16 bits. If use format "%d"
to printk IOPRIO_PRIO_DATA, there will be the following warning or error.
fs/f2fs/sysfs.c:348:31: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
return sysfs_emit(buf, "%s,%d\n",
~^
%ld
This is because the output of IOPRIO_PRIO_DATA is converted to "UL" from
IOPRIO_PRIO_MASK, which is not reasonable. unsigned int is more suitable.
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
---
include/uapi/linux/ioprio.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h
index bee2bdb0..9ead07f 100644
--- a/include/uapi/linux/ioprio.h
+++ b/include/uapi/linux/ioprio.h
@@ -11,7 +11,7 @@
#define IOPRIO_CLASS_SHIFT 13
#define IOPRIO_NR_CLASSES 8
#define IOPRIO_CLASS_MASK (IOPRIO_NR_CLASSES - 1)
-#define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1)
+#define IOPRIO_PRIO_MASK ((1U << IOPRIO_CLASS_SHIFT) - 1)
#define IOPRIO_PRIO_CLASS(ioprio) \
(((ioprio) >> IOPRIO_CLASS_SHIFT) & IOPRIO_CLASS_MASK)
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] block: uapi: Fix compliation warning of using IOPRIO_PRIO_DATA
2024-05-31 11:31 [PATCH] block: uapi: Fix compliation warning of using IOPRIO_PRIO_DATA Zhiguo Niu
@ 2024-05-31 20:13 ` Bart Van Assche
2024-07-09 3:27 ` Zhiguo Niu
0 siblings, 1 reply; 4+ messages in thread
From: Bart Van Assche @ 2024-05-31 20:13 UTC (permalink / raw)
To: Zhiguo Niu, axboe; +Cc: dlemoal, linux-kernel, niuzhiguo84, ke.wang
On 5/31/24 04:31, Zhiguo Niu wrote:
> Generally, the input of IOPRIO_PRIO_DATA has 16 bits. If use format "%d"
> to printk IOPRIO_PRIO_DATA, there will be the following warning or error.
>
> fs/f2fs/sysfs.c:348:31: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
> return sysfs_emit(buf, "%s,%d\n",
> ~^
> %ld
>
> This is because the output of IOPRIO_PRIO_DATA is converted to "UL" from
> IOPRIO_PRIO_MASK, which is not reasonable. unsigned int is more suitable.
>
> Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
> ---
> include/uapi/linux/ioprio.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h
> index bee2bdb0..9ead07f 100644
> --- a/include/uapi/linux/ioprio.h
> +++ b/include/uapi/linux/ioprio.h
> @@ -11,7 +11,7 @@
> #define IOPRIO_CLASS_SHIFT 13
> #define IOPRIO_NR_CLASSES 8
> #define IOPRIO_CLASS_MASK (IOPRIO_NR_CLASSES - 1)
> -#define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1)
> +#define IOPRIO_PRIO_MASK ((1U << IOPRIO_CLASS_SHIFT) - 1)
>
> #define IOPRIO_PRIO_CLASS(ioprio) \
> (((ioprio) >> IOPRIO_CLASS_SHIFT) & IOPRIO_CLASS_MASK)
This change is safe even if the mask is applied to an expression with more bits
than an int because of the integer promotion rules. Hence:
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: uapi: Fix compliation warning of using IOPRIO_PRIO_DATA
2024-05-31 20:13 ` Bart Van Assche
@ 2024-07-09 3:27 ` Zhiguo Niu
2024-07-09 4:50 ` Damien Le Moal
0 siblings, 1 reply; 4+ messages in thread
From: Zhiguo Niu @ 2024-07-09 3:27 UTC (permalink / raw)
To: axboe, dlemoal, Christoph Hellwig
Cc: Bart Van Assche, linux-kernel, Zhiguo Niu, ke.wang
kindly ping...
Bart Van Assche <bvanassche@acm.org> 于2024年6月1日周六 04:13写道:
>
> On 5/31/24 04:31, Zhiguo Niu wrote:
> > Generally, the input of IOPRIO_PRIO_DATA has 16 bits. If use format "%d"
> > to printk IOPRIO_PRIO_DATA, there will be the following warning or error.
> >
> > fs/f2fs/sysfs.c:348:31: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
> > return sysfs_emit(buf, "%s,%d\n",
> > ~^
> > %ld
> >
> > This is because the output of IOPRIO_PRIO_DATA is converted to "UL" from
> > IOPRIO_PRIO_MASK, which is not reasonable. unsigned int is more suitable.
> >
> > Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
> > ---
> > include/uapi/linux/ioprio.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h
> > index bee2bdb0..9ead07f 100644
> > --- a/include/uapi/linux/ioprio.h
> > +++ b/include/uapi/linux/ioprio.h
> > @@ -11,7 +11,7 @@
> > #define IOPRIO_CLASS_SHIFT 13
> > #define IOPRIO_NR_CLASSES 8
> > #define IOPRIO_CLASS_MASK (IOPRIO_NR_CLASSES - 1)
> > -#define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1)
> > +#define IOPRIO_PRIO_MASK ((1U << IOPRIO_CLASS_SHIFT) - 1)
> >
> > #define IOPRIO_PRIO_CLASS(ioprio) \
> > (((ioprio) >> IOPRIO_CLASS_SHIFT) & IOPRIO_CLASS_MASK)
>
> This change is safe even if the mask is applied to an expression with more bits
> than an int because of the integer promotion rules. Hence:
>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: uapi: Fix compliation warning of using IOPRIO_PRIO_DATA
2024-07-09 3:27 ` Zhiguo Niu
@ 2024-07-09 4:50 ` Damien Le Moal
0 siblings, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2024-07-09 4:50 UTC (permalink / raw)
To: Zhiguo Niu, axboe, Christoph Hellwig
Cc: Bart Van Assche, linux-kernel, Zhiguo Niu, ke.wang
On 7/9/24 12:27, Zhiguo Niu wrote:
> kindly ping...
>
> Bart Van Assche <bvanassche@acm.org> 于2024年6月1日周六 04:13写道:
>
>
>>
>> On 5/31/24 04:31, Zhiguo Niu wrote:
>>> Generally, the input of IOPRIO_PRIO_DATA has 16 bits. If use format "%d"
>>> to printk IOPRIO_PRIO_DATA, there will be the following warning or error.
>>>
>>> fs/f2fs/sysfs.c:348:31: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
>>> return sysfs_emit(buf, "%s,%d\n",
>>> ~^
>>> %ld
>>>
>>> This is because the output of IOPRIO_PRIO_DATA is converted to "UL" from
>>> IOPRIO_PRIO_MASK, which is not reasonable. unsigned int is more suitable.
>>>
>>> Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
>>> ---
>>> include/uapi/linux/ioprio.h | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h
>>> index bee2bdb0..9ead07f 100644
>>> --- a/include/uapi/linux/ioprio.h
>>> +++ b/include/uapi/linux/ioprio.h
>>> @@ -11,7 +11,7 @@
>>> #define IOPRIO_CLASS_SHIFT 13
>>> #define IOPRIO_NR_CLASSES 8
>>> #define IOPRIO_CLASS_MASK (IOPRIO_NR_CLASSES - 1)
>>> -#define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1)
>>> +#define IOPRIO_PRIO_MASK ((1U << IOPRIO_CLASS_SHIFT) - 1)
>>>
>>> #define IOPRIO_PRIO_CLASS(ioprio) \
>>> (((ioprio) >> IOPRIO_CLASS_SHIFT) & IOPRIO_CLASS_MASK)
>>
>> This change is safe even if the mask is applied to an expression with more bits
>> than an int because of the integer promotion rules. Hence:
>>
>> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Looks good to me but I think this needs a Fixes tag and Cc-stable.
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-07-09 4:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-31 11:31 [PATCH] block: uapi: Fix compliation warning of using IOPRIO_PRIO_DATA Zhiguo Niu
2024-05-31 20:13 ` Bart Van Assche
2024-07-09 3:27 ` Zhiguo Niu
2024-07-09 4:50 ` Damien Le Moal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®