From: lottaviano Date: Tue, 15 Feb 2011 13:32:19 +0000 (+0000) Subject: Use more descriptive error messages for invalid stacks in proc_new() X-Git-Tag: 2.7.0~260 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=4ac3fd00c7407310d00e3b09fc96ac2293de674e;p=bertos.git Use more descriptive error messages for invalid stacks in proc_new() git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4706 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cfg/debug.h b/bertos/cfg/debug.h index 25768293..efa26e18 100644 --- a/bertos/cfg/debug.h +++ b/bertos/cfg/debug.h @@ -177,6 +177,7 @@ #define ASSERT2(x, help) ((void)ASSERT(x)) #endif + #define IS_VALID_PTR(p) (LIKELY((void *)(p) >= (void *)CPU_RAM_START)) /** * Check that the given pointer is either NULL or pointing to valid memory. * @@ -186,8 +187,8 @@ * * \see ASSERT_VALID_PTR_OR_NULL() */ - #define ASSERT_VALID_PTR(p) ((void)(LIKELY((void *)(p) >= (void *)CPU_RAM_START) \ - ? 0 : __invalid_ptr(p, #p, THIS_FILE, __LINE__))) + #define ASSERT_VALID_PTR(p) (IS_VALID_PTR(p) \ + ? 0 : __invalid_ptr(p, #p, THIS_FILE, __LINE__)) /** * Check that the given pointer is not pointing to invalid memory. @@ -293,6 +294,7 @@ #define ASSERT(x) ((void)0) #endif /* ASSERT */ #define ASSERT2(x, help) ((void)0) + #define IS_VALID_PTR(p) (1) #define ASSERT_VALID_PTR(p) ((void)0) #define ASSERT_VALID_PTR_OR_NULL(p) ((void)0) #define ASSERT_VALID_OBJ(_t, _o) ((void)0) diff --git a/bertos/kern/proc.c b/bertos/kern/proc.c index 781bd553..0bc046f8 100644 --- a/bertos/kern/proc.c +++ b/bertos/kern/proc.c @@ -323,8 +323,9 @@ struct Process *proc_new_with_name(UNUSED_ARG(const char *, name), void (*entry) #else // CONFIG_KERN_HEAP /* Stack must have been provided by the user */ - ASSERT_VALID_PTR(stack_base); - ASSERT(stack_size); + ASSERT2(IS_VALID_PTR(stack_base), "Invalid stack pointer. Did you forget to \ + enable CONFIG_KERN_HEAP?"); + ASSERT2(stack_size, "Stack size cannot be 0."); #endif // CONFIG_KERN_HEAP