Skip to content

Commit c7b4b23

Browse files
damien-lemoalaxboe
authored andcommitted
block: uapi: Fix compilation errors using ioprio.h with C++
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 <[email protected]> Fixes: 01584c1 ("scsi: block: Improve ioprio value validity checks") Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Tested-by: Igor Pylypiv <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 649f070 commit c7b4b23

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

include/uapi/linux/ioprio.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,21 @@ enum {
107107
/*
108108
* Return an I/O priority value based on a class, a level and a hint.
109109
*/
110-
static __always_inline __u16 ioprio_value(int class, int level, int hint)
110+
static __always_inline __u16 ioprio_value(int prioclass, int priolevel,
111+
int priohint)
111112
{
112-
if (IOPRIO_BAD_VALUE(class, IOPRIO_NR_CLASSES) ||
113-
IOPRIO_BAD_VALUE(level, IOPRIO_NR_LEVELS) ||
114-
IOPRIO_BAD_VALUE(hint, IOPRIO_NR_HINTS))
113+
if (IOPRIO_BAD_VALUE(prioclass, IOPRIO_NR_CLASSES) ||
114+
IOPRIO_BAD_VALUE(priolevel, IOPRIO_NR_LEVELS) ||
115+
IOPRIO_BAD_VALUE(priohint, IOPRIO_NR_HINTS))
115116
return IOPRIO_CLASS_INVALID << IOPRIO_CLASS_SHIFT;
116117

117-
return (class << IOPRIO_CLASS_SHIFT) |
118-
(hint << IOPRIO_HINT_SHIFT) | level;
118+
return (prioclass << IOPRIO_CLASS_SHIFT) |
119+
(priohint << IOPRIO_HINT_SHIFT) | priolevel;
119120
}
120121

121-
#define IOPRIO_PRIO_VALUE(class, level) \
122-
ioprio_value(class, level, IOPRIO_HINT_NONE)
123-
#define IOPRIO_PRIO_VALUE_HINT(class, level, hint) \
124-
ioprio_value(class, level, hint)
122+
#define IOPRIO_PRIO_VALUE(prioclass, priolevel) \
123+
ioprio_value(prioclass, priolevel, IOPRIO_HINT_NONE)
124+
#define IOPRIO_PRIO_VALUE_HINT(prioclass, priolevel, priohint) \
125+
ioprio_value(prioclass, priolevel, priohint)
125126

126127
#endif /* _UAPI_LINUX_IOPRIO_H */

0 commit comments

Comments
 (0)