From 018bd07f07e43a5be8ed94cfbcaac3c742b30b0a Mon Sep 17 00:00:00 2001 From: Raed Rizqie Date: Fri, 16 Aug 2024 13:51:21 +0800 Subject: [PATCH] Fix some warnings * Fix unused functions when no `mmap`. ``` shape.c:285:1: warning: unused function 'redblack_insert' [-Wunused-function] 285 | redblack_insert(redblack_node_t * tree, ID key, rb_shape_t * value) | ^~~~~~~~~~~~~~~ ``` * Fix unknown warning group '-Wmaybe-uninitialized' with clang. ``` thread_win32.c:596:1: warning: unknown warning group '-Wmaybe-uninitialized', ignored [-Wunknown-warning-option] 596 | COMPILER_WARNING_IGNORED(-Wmaybe-uninitialized) | ^ ``` Co-authored-by: Nobuyoshi Nakada --- shape.c | 18 +++++++++--------- thread_win32.c | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/shape.c b/shape.c index 00fc627b5e..0200a6e526 100644 --- a/shape.c +++ b/shape.c @@ -98,6 +98,15 @@ redblack_find(redblack_node_t * tree, ID key) } } +static inline rb_shape_t * +redblack_value(redblack_node_t * node) +{ + // Color is stored in the bottom bit of the shape pointer + // Mask away the bit so we get the actual pointer back + return (rb_shape_t *)((uintptr_t)node->value & (((uintptr_t)-1) - 1)); +} + +#ifdef HAVE_MMAP static inline char redblack_color(redblack_node_t * node) { @@ -110,15 +119,6 @@ redblack_red_p(redblack_node_t * node) return redblack_color(node) == RED; } -static inline rb_shape_t * -redblack_value(redblack_node_t * node) -{ - // Color is stored in the bottom bit of the shape pointer - // Mask away the bit so we get the actual pointer back - return (rb_shape_t *)((uintptr_t)node->value & (((uintptr_t)-1) - 1)); -} - -#ifdef HAVE_MMAP static redblack_id_t redblack_id_for(redblack_node_t * node) { diff --git a/thread_win32.c b/thread_win32.c index 74015b463b..1e2d4bdd19 100644 --- a/thread_win32.c +++ b/thread_win32.c @@ -589,7 +589,7 @@ rb_native_cond_destroy(rb_nativethread_cond_t *cond) {if (!(expr)) {rb_bug("err: %lu - %s", GetLastError(), #expr);}} COMPILER_WARNING_PUSH -#if defined(__GNUC__) +#if __has_warning("-Wmaybe-uninitialized") COMPILER_WARNING_IGNORED(-Wmaybe-uninitialized) #endif static inline SIZE_T