Skip to content

Commit af84b16

Browse files
committed
openrisc: uaccess: Use static inline function in access_ok
As suggested by Linus when reviewing commit 9cb2feb ("arch/openrisc: Fix issues with access_ok()") last year; making __range_ok an inline function also fixes the used twice issue that the commit was fixing. I agree it's a good cleanup. This patch addresses that as I am currently working on the access_ok macro to fixup sparse annotations in OpenRISC. Suggested-by: Linus Torvalds <[email protected]> Signed-off-by: Stafford Horne <[email protected]> Reviewed-by: Luc Van Oostenryck <[email protected]>
1 parent 17fcd83 commit af84b16

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

arch/openrisc/include/asm/uaccess.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,19 @@
4848
/* Ensure that the range from addr to addr+size is all within the process'
4949
* address space
5050
*/
51-
#define __range_ok(addr, size) (size <= get_fs() && addr <= (get_fs()-size))
51+
static inline int __range_ok(unsigned long addr, unsigned long size)
52+
{
53+
const mm_segment_t fs = get_fs();
54+
55+
return size <= fs && addr <= (fs - size);
56+
}
5257

5358
/* Ensure that addr is below task's addr_limit */
5459
#define __addr_ok(addr) ((unsigned long) addr < get_fs())
5560

5661
#define access_ok(addr, size) \
5762
({ \
58-
unsigned long __ao_addr = (unsigned long)(addr); \
59-
unsigned long __ao_size = (unsigned long)(size); \
60-
__range_ok(__ao_addr, __ao_size); \
63+
__range_ok((unsigned long)(addr), (size)); \
6164
})
6265

6366
/*

0 commit comments

Comments
 (0)