* IS_KERNEL_ADDRESS(): Avoid the check against KERNEL_BASE or KERNEL_TOP, if

that's the limit of the addr_t domain anyway.
* Defined IS_USER_ADDRESS() to !IS_KERNEL_ADDRESS(), which semantically it was
  already, just more verbosely.

Should, in the future, avoid hundreds of useless Coverity tickets where the
macros are used.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40093 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2011-01-03 17:56:04 +00:00
parent c5f2df286e
commit 0536ff83e9
1 changed files with 14 additions and 5 deletions

View File

@ -9,16 +9,25 @@
#define _KERNEL_KERNEL_H
#include <config/types.h>
#include <arch_kernel.h>
#include <arch_config.h>
/* Passed in buffers from user-space shouldn't point into the kernel */
#define IS_USER_ADDRESS(x) \
((addr_t)(x) < KERNEL_BASE || (addr_t)(x) > KERNEL_TOP)
// macro to check whether an address is in the kernel address space (avoid
// always-true checks)
#if KERNEL_BASE == 0
# define IS_KERNEL_ADDRESS(x) ((addr_t)(x) <= KERNEL_TOP)
#elif KERNEL_TOP == __HAIKU_ADDR_MAX
# define IS_KERNEL_ADDRESS(x) ((addr_t)(x) >= KERNEL_BASE)
#else
# define IS_KERNEL_ADDRESS(x) \
((addr_t)(x) >= KERNEL_BASE && (addr_t)(x) <= KERNEL_TOP)
#endif
#define IS_KERNEL_ADDRESS(x) \
((addr_t)(x) >= KERNEL_BASE && (addr_t)(x) <= KERNEL_TOP)
// Buffers passed in from user-space shouldn't point into the kernel.
#define IS_USER_ADDRESS(x) (!IS_KERNEL_ADDRESS(x))
#define DEBUG_KERNEL_STACKS
// Note, debugging kernel stacks doesn't really work yet. Since the