Skip to content

Commit b28efd5

Browse files
eparisJames Morris
authored andcommitted
kernel: roundup should only reference arguments once
Currently the roundup macro references it's arguments more than one time. This patch changes it so it will only use its arguments once. Suggested-by: Andrew Morton <[email protected]> Signed-off-by: Eric Paris <[email protected]> Signed-off-by: James Morris <[email protected]>
1 parent 686a0f3 commit b28efd5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

include/linux/kernel.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ extern const char linux_proc_banner[];
5858

5959
#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
6060
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
61-
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
61+
#define roundup(x, y) ( \
62+
{ \
63+
typeof(y) __y = y; \
64+
(((x) + (__y - 1)) / __y) * __y; \
65+
} \
66+
)
6267
#define rounddown(x, y) ( \
6368
{ \
6469
typeof(x) __x = (x); \

0 commit comments

Comments
 (0)