From 930a446a7b8e218942f9d9c0c02daf01b2c3856c Mon Sep 17 00:00:00 2001 From: Nathan Hartman <59230071+hartmannathan@users.noreply.github.com> Date: Thu, 7 May 2020 15:06:05 -0400 Subject: [PATCH] sched/init/nx_start.c: Reinstate logic to remove compiler warning Revert a portion of eca70597858bc619d3114901d16e4a30f1ebffbe that causes compiler warnings about unused variables if nx_start() is not initializing any of the user-mode heap, kernel-mode heap, or page allocator: init/nx_start.c: In function 'nx_start': init/nx_start.c:552:14: warning: unused variable 'heap_size' [-Wunused-variable] size_t heap_size; ^~~~~~~~~ init/nx_start.c:551:17: warning: unused variable 'heap_start' [-Wunused-variable] FAR void *heap_start; ^~~~~~~~~~ See dev@nuttx.apache.org mailing list discussion "New unused variables warning in nx_start()" starting 6 May 2020, archived here: https://lists.apache.org/thread.html/r3900727e6a06f4445d6eb881d065119ba6647daab89600c3d45d1424%40%3Cdev.nuttx.apache.org%3E sched/init/nx_start.c: * If none of MM_KERNEL_USRHEAP_INIT, CONFIG_MM_KERNEL_HEAP, or CONFIG_MM_PGALLOC are defined, the variables heap_start and heap_size were declared but never used. * This change reinstates wrapping the block with a preprocessor conditional to prevent the variables being declared if they will not be used. This preprocessor condition was removed in the above-mentioned commit. --- sched/init/nx_start.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c index 75abaddb56..b1c4d4626d 100644 --- a/sched/init/nx_start.c +++ b/sched/init/nx_start.c @@ -545,6 +545,8 @@ void nx_start(void) nxsem_initialize(); +#if defined(MM_KERNEL_USRHEAP_INIT) || defined(CONFIG_MM_KERNEL_HEAP) || \ + defined(CONFIG_MM_PGALLOC) /* Initialize the memory manager */ { @@ -579,6 +581,7 @@ void nx_start(void) mm_pginitialize(heap_start, heap_size); #endif } +#endif #ifdef CONFIG_ARCH_USE_MODULE_TEXT up_module_text_init();