Linux block layer
 help / color / mirror / Atom feed
* [PATCH] block: uapi: Fix compilation errors using ioprio.h with C++
@ 2023-08-14 21:58 Damien Le Moal
  2023-08-14 22:35 ` Igor Pylypiv
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Damien Le Moal @ 2023-08-14 21:58 UTC (permalink / raw)
  To: Jens Axboe, linux-block; +Cc: Igor Pylypiv

The use of the "class" argument name in the ioprio_value() inline
function in include/uapi/linux/ioprio.h confuses C++ compilers
resulting in compilation errors such as:

/usr/include/linux/ioprio.h:110:43: error: expected primary-expression before ‘int’
  110 | static __always_inline __u16 ioprio_value(int class, int level, int hint)
      |                                           ^~~

for user C++ programs including linux/ioprio.h.

Avoid these errors by renaming the arguments of the ioprio_value()
function to prioclass, priolevel and priohint. For consistency, the
arguments of the IOPRIO_PRIO_VALUE() and IOPRIO_PRIO_VALUE_HINT() macros
are also renamed in the same manner.

Reported-by: Igor Pylypiv <ipylypiv@google.com>
Fixes: 01584c1e2337 ("scsi: block: Improve ioprio value validity checks")
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 include/uapi/linux/ioprio.h | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h
index 99440b2e8c35..bee2bdb0eedb 100644
--- a/include/uapi/linux/ioprio.h
+++ b/include/uapi/linux/ioprio.h
@@ -107,20 +107,21 @@ enum {
 /*
  * Return an I/O priority value based on a class, a level and a hint.
  */
-static __always_inline __u16 ioprio_value(int class, int level, int hint)
+static __always_inline __u16 ioprio_value(int prioclass, int priolevel,
+					  int priohint)
 {
-	if (IOPRIO_BAD_VALUE(class, IOPRIO_NR_CLASSES) ||
-	    IOPRIO_BAD_VALUE(level, IOPRIO_NR_LEVELS) ||
-	    IOPRIO_BAD_VALUE(hint, IOPRIO_NR_HINTS))
+	if (IOPRIO_BAD_VALUE(prioclass, IOPRIO_NR_CLASSES) ||
+	    IOPRIO_BAD_VALUE(priolevel, IOPRIO_NR_LEVELS) ||
+	    IOPRIO_BAD_VALUE(priohint, IOPRIO_NR_HINTS))
 		return IOPRIO_CLASS_INVALID << IOPRIO_CLASS_SHIFT;
 
-	return (class << IOPRIO_CLASS_SHIFT) |
-		(hint << IOPRIO_HINT_SHIFT) | level;
+	return (prioclass << IOPRIO_CLASS_SHIFT) |
+		(priohint << IOPRIO_HINT_SHIFT) | priolevel;
 }
 
-#define IOPRIO_PRIO_VALUE(class, level)			\
-	ioprio_value(class, level, IOPRIO_HINT_NONE)
-#define IOPRIO_PRIO_VALUE_HINT(class, level, hint)	\
-	ioprio_value(class, level, hint)
+#define IOPRIO_PRIO_VALUE(prioclass, priolevel)			\
+	ioprio_value(prioclass, priolevel, IOPRIO_HINT_NONE)
+#define IOPRIO_PRIO_VALUE_HINT(prioclass, priolevel, priohint)	\
+	ioprio_value(prioclass, priolevel, priohint)
 
 #endif /* _UAPI_LINUX_IOPRIO_H */
-- 
2.41.0


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

* Re: [PATCH] block: uapi: Fix compilation errors using ioprio.h with C++
  2023-08-14 21:58 [PATCH] block: uapi: Fix compilation errors using ioprio.h with C++ Damien Le Moal
@ 2023-08-14 22:35 ` Igor Pylypiv
  2023-08-15  1:00   ` Chaitanya Kulkarni
  2023-08-15  1:55 ` Jens Axboe
  2023-08-15 15:52 ` Bart Van Assche
  2 siblings, 1 reply; 5+ messages in thread
From: Igor Pylypiv @ 2023-08-14 22:35 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: Jens Axboe, linux-block

On Tue, Aug 15, 2023 at 06:58:32AM +0900, Damien Le Moal wrote:
> The use of the "class" argument name in the ioprio_value() inline
> function in include/uapi/linux/ioprio.h confuses C++ compilers
> resulting in compilation errors such as:
> 
> /usr/include/linux/ioprio.h:110:43: error: expected primary-expression before ‘int’
>   110 | static __always_inline __u16 ioprio_value(int class, int level, int hint)
>       |                                           ^~~
> 
> for user C++ programs including linux/ioprio.h.
> 
> Avoid these errors by renaming the arguments of the ioprio_value()
> function to prioclass, priolevel and priohint. For consistency, the
> arguments of the IOPRIO_PRIO_VALUE() and IOPRIO_PRIO_VALUE_HINT() macros
> are also renamed in the same manner.
> 
> Reported-by: Igor Pylypiv <ipylypiv@google.com>
> Fixes: 01584c1e2337 ("scsi: block: Improve ioprio value validity checks")
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>

Tested-by: Igor Pylypiv <ipylypiv@google.com>

Thanks!
> ---
>  include/uapi/linux/ioprio.h | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h
> index 99440b2e8c35..bee2bdb0eedb 100644
> --- a/include/uapi/linux/ioprio.h
> +++ b/include/uapi/linux/ioprio.h
> @@ -107,20 +107,21 @@ enum {
>  /*
>   * Return an I/O priority value based on a class, a level and a hint.
>   */
> -static __always_inline __u16 ioprio_value(int class, int level, int hint)
> +static __always_inline __u16 ioprio_value(int prioclass, int priolevel,
> +					  int priohint)
>  {
> -	if (IOPRIO_BAD_VALUE(class, IOPRIO_NR_CLASSES) ||
> -	    IOPRIO_BAD_VALUE(level, IOPRIO_NR_LEVELS) ||
> -	    IOPRIO_BAD_VALUE(hint, IOPRIO_NR_HINTS))
> +	if (IOPRIO_BAD_VALUE(prioclass, IOPRIO_NR_CLASSES) ||
> +	    IOPRIO_BAD_VALUE(priolevel, IOPRIO_NR_LEVELS) ||
> +	    IOPRIO_BAD_VALUE(priohint, IOPRIO_NR_HINTS))
>  		return IOPRIO_CLASS_INVALID << IOPRIO_CLASS_SHIFT;
>  
> -	return (class << IOPRIO_CLASS_SHIFT) |
> -		(hint << IOPRIO_HINT_SHIFT) | level;
> +	return (prioclass << IOPRIO_CLASS_SHIFT) |
> +		(priohint << IOPRIO_HINT_SHIFT) | priolevel;
>  }
>  
> -#define IOPRIO_PRIO_VALUE(class, level)			\
> -	ioprio_value(class, level, IOPRIO_HINT_NONE)
> -#define IOPRIO_PRIO_VALUE_HINT(class, level, hint)	\
> -	ioprio_value(class, level, hint)
> +#define IOPRIO_PRIO_VALUE(prioclass, priolevel)			\
> +	ioprio_value(prioclass, priolevel, IOPRIO_HINT_NONE)
> +#define IOPRIO_PRIO_VALUE_HINT(prioclass, priolevel, priohint)	\
> +	ioprio_value(prioclass, priolevel, priohint)
>  
>  #endif /* _UAPI_LINUX_IOPRIO_H */
> -- 
> 2.41.0
> 

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

* Re: [PATCH] block: uapi: Fix compilation errors using ioprio.h with C++
  2023-08-14 22:35 ` Igor Pylypiv
@ 2023-08-15  1:00   ` Chaitanya Kulkarni
  0 siblings, 0 replies; 5+ messages in thread
From: Chaitanya Kulkarni @ 2023-08-15  1:00 UTC (permalink / raw)
  To: Igor Pylypiv, Damien Le Moal; +Cc: Jens Axboe, linux-block@vger.kernel.org

On 8/14/2023 3:35 PM, Igor Pylypiv wrote:
> On Tue, Aug 15, 2023 at 06:58:32AM +0900, Damien Le Moal wrote:
>> The use of the "class" argument name in the ioprio_value() inline
>> function in include/uapi/linux/ioprio.h confuses C++ compilers
>> resulting in compilation errors such as:
>>
>> /usr/include/linux/ioprio.h:110:43: error: expected primary-expression before ‘int’
>>    110 | static __always_inline __u16 ioprio_value(int class, int level, int hint)
>>        |                                           ^~~
>>
>> for user C++ programs including linux/ioprio.h.
>>
>> Avoid these errors by renaming the arguments of the ioprio_value()
>> function to prioclass, priolevel and priohint. For consistency, the
>> arguments of the IOPRIO_PRIO_VALUE() and IOPRIO_PRIO_VALUE_HINT() macros
>> are also renamed in the same manner.
>>
>> Reported-by: Igor Pylypiv <ipylypiv@google.com>
>> Fixes: 01584c1e2337 ("scsi: block: Improve ioprio value validity checks")
>> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> 

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck


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

* Re: [PATCH] block: uapi: Fix compilation errors using ioprio.h with C++
  2023-08-14 21:58 [PATCH] block: uapi: Fix compilation errors using ioprio.h with C++ Damien Le Moal
  2023-08-14 22:35 ` Igor Pylypiv
@ 2023-08-15  1:55 ` Jens Axboe
  2023-08-15 15:52 ` Bart Van Assche
  2 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2023-08-15  1:55 UTC (permalink / raw)
  To: linux-block, Damien Le Moal; +Cc: Igor Pylypiv


On Tue, 15 Aug 2023 06:58:32 +0900, Damien Le Moal wrote:
> The use of the "class" argument name in the ioprio_value() inline
> function in include/uapi/linux/ioprio.h confuses C++ compilers
> resulting in compilation errors such as:
> 
> /usr/include/linux/ioprio.h:110:43: error: expected primary-expression before ‘int’
>   110 | static __always_inline __u16 ioprio_value(int class, int level, int hint)
>       |                                           ^~~
> 
> [...]

Applied, thanks!

[1/1] block: uapi: Fix compilation errors using ioprio.h with C++
      commit: 8b6e92c358d2e12ff9f12e55bb6101e2ab053ee7

Best regards,
-- 
Jens Axboe




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

* Re: [PATCH] block: uapi: Fix compilation errors using ioprio.h with C++
  2023-08-14 21:58 [PATCH] block: uapi: Fix compilation errors using ioprio.h with C++ Damien Le Moal
  2023-08-14 22:35 ` Igor Pylypiv
  2023-08-15  1:55 ` Jens Axboe
@ 2023-08-15 15:52 ` Bart Van Assche
  2 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2023-08-15 15:52 UTC (permalink / raw)
  To: Damien Le Moal, Jens Axboe, linux-block; +Cc: Igor Pylypiv

On 8/14/23 14:58, Damien Le Moal wrote:
> The use of the "class" argument name in the ioprio_value() inline
> function in include/uapi/linux/ioprio.h confuses C++ compilers
> resulting in compilation errors such as:
> 
> /usr/include/linux/ioprio.h:110:43: error: expected primary-expression before ‘int’
>    110 | static __always_inline __u16 ioprio_value(int class, int level, int hint)
>        |                                           ^~~
> 
> for user C++ programs including linux/ioprio.h.
> 
> Avoid these errors by renaming the arguments of the ioprio_value()
> function to prioclass, priolevel and priohint. For consistency, the
> arguments of the IOPRIO_PRIO_VALUE() and IOPRIO_PRIO_VALUE_HINT() macros
> are also renamed in the same manner.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

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

end of thread, other threads:[~2023-08-15 15:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-14 21:58 [PATCH] block: uapi: Fix compilation errors using ioprio.h with C++ Damien Le Moal
2023-08-14 22:35 ` Igor Pylypiv
2023-08-15  1:00   ` Chaitanya Kulkarni
2023-08-15  1:55 ` Jens Axboe
2023-08-15 15:52 ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox