[前][次][番号順一覧][スレッド一覧]

ruby-changes:66044

From: Benoit <ko1@a...>
Date: Tue, 4 May 2021 21:57:17 +0900 (JST)
Subject: [ruby-changes:66044] 0764d323d8 (master): Fix -Wundef warnings for patterns `#if HAVE`

https://git.ruby-lang.org/ruby.git/commit/?id=0764d323d8

From 0764d323d8908c1682f3ab654c48783438a88a54 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Thu, 29 Apr 2021 15:12:44 +0200
Subject: Fix -Wundef warnings for patterns `#if HAVE`

* See [Feature #17752]
* Using this to detect them:
  git grep -P 'if\s+HAVE' | grep -Pv 'HAVE_LONG_LONG|/ChangeLog|HAVE_TYPEOF'
---
 dir.c                         | 6 +++---
 ext/bigdecimal/missing.h      | 2 +-
 ext/psych/yaml/yaml_private.h | 2 +-
 gc.c                          | 4 ++--
 random.c                      | 2 +-
 signal.c                      | 2 +-
 siphash.c                     | 4 ++--
 strftime.c                    | 2 +-
 thread_pthread.c              | 4 ++--
 9 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/dir.c b/dir.c
index fb31bd4..b122b2c 100644
--- a/dir.c
+++ b/dir.c
@@ -50,13 +50,13 @@ https://github.com/ruby/ruby/blob/trunk/dir.c#L50
 # define dirent direct
 # define NAMLEN(dirent) (dirent)->d_namlen
 # define HAVE_DIRENT_NAMLEN 1
-# if HAVE_SYS_NDIR_H
+# ifdef HAVE_SYS_NDIR_H
 #  include <sys/ndir.h>
 # endif
-# if HAVE_SYS_DIR_H
+# ifdef HAVE_SYS_DIR_H
 #  include <sys/dir.h>
 # endif
-# if HAVE_NDIR_H
+# ifdef HAVE_NDIR_H
 #  include <ndir.h>
 # endif
 # ifdef _WIN32
diff --git a/ext/bigdecimal/missing.h b/ext/bigdecimal/missing.h
index 11b58c0..7969849 100644
--- a/ext/bigdecimal/missing.h
+++ b/ext/bigdecimal/missing.h
@@ -45,7 +45,7 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/missing.h#L45
 # if __has_builtin(__builtin_unreachable)
 #  define UNREACHABLE __builtin_unreachable()
 
-# elif HAVE___ASSUME
+# elif defined(HAVE___ASSUME)
 #  define UNREACHABLE __assume(0)
 
 # else
diff --git a/ext/psych/yaml/yaml_private.h b/ext/psych/yaml/yaml_private.h
index 6c674de..266a6bd 100644
--- a/ext/psych/yaml/yaml_private.h
+++ b/ext/psych/yaml/yaml_private.h
@@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/yaml_private.h#L2
 #include RUBY_EXTCONF_H
 #endif
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
diff --git a/gc.c b/gc.c
index 4eb5488..9fdcbb4 100644
--- a/gc.c
+++ b/gc.c
@@ -45,7 +45,7 @@ https://github.com/ruby/ruby/blob/trunk/gc.c#L45
 #ifdef HAVE_MALLOC_USABLE_SIZE
 # ifdef RUBY_ALTERNATIVE_MALLOC_HEADER
 #  include RUBY_ALTERNATIVE_MALLOC_HEADER
-# elif HAVE_MALLOC_H
+# elif defined(HAVE_MALLOC_H)
 #  include <malloc.h>
 # elif defined(HAVE_MALLOC_NP_H)
 #  include <malloc_np.h>
@@ -381,7 +381,7 @@ static ruby_gc_params_t gc_params = { https://github.com/ruby/ruby/blob/trunk/gc.c#L381
 #endif
 #if RGENGC_DEBUG < 0 && !defined(_MSC_VER)
 # define RGENGC_DEBUG_ENABLED(level) (-(RGENGC_DEBUG) >= (level) && ruby_rgengc_debug >= (level))
-#elif HAVE_VA_ARGS_MACRO
+#elif defined(HAVE_VA_ARGS_MACRO)
 # define RGENGC_DEBUG_ENABLED(level) ((RGENGC_DEBUG) >= (level))
 #else
 # define RGENGC_DEBUG_ENABLED(level) 0
diff --git a/random.c b/random.c
index eec017c..2c9fe0c 100644
--- a/random.c
+++ b/random.c
@@ -428,7 +428,7 @@ random_init(int argc, VALUE *argv, VALUE obj) https://github.com/ruby/ruby/blob/trunk/random.c#L428
 # define USE_DEV_URANDOM 0
 #endif
 
-#if HAVE_GETENTROPY
+#ifdef HAVE_GETENTROPY
 # define MAX_SEED_LEN_PER_READ 256
 static int
 fill_random_bytes_urandom(void *seed, size_t size)
diff --git a/signal.c b/signal.c
index 2ebd119..46ac6c2 100644
--- a/signal.c
+++ b/signal.c
@@ -29,7 +29,7 @@ https://github.com/ruby/ruby/blob/trunk/signal.c#L29
 # include <ucontext.h>
 #endif
 
-#if HAVE_PTHREAD_H
+#ifdef HAVE_PTHREAD_H
 # include <pthread.h>
 #endif
 
diff --git a/siphash.c b/siphash.c
index ddf8ee2..2c48fa8 100644
--- a/siphash.c
+++ b/siphash.c
@@ -180,7 +180,7 @@ int_sip_dump(sip_state *state) https://github.com/ruby/ruby/blob/trunk/siphash.c#L180
     int v;
 
     for (v = 0; v < 4; v++) {
-#if HAVE_UINT64_T
+#ifdef HAVE_UINT64_T
 	printf("v%d: %" PRIx64 "\n", v, state->v[v]);
 #else
 	printf("v%d: %" PRIx32 "%.8" PRIx32 "\n", v, state->v[v].hi, state->v[v].lo);
@@ -447,7 +447,7 @@ sip_hash13(const uint8_t key[16], const uint8_t *data, size_t len) https://github.com/ruby/ruby/blob/trunk/siphash.c#L447
 	    OR_BYTE(4);
 	case 4:
 #if BYTE_ORDER == LITTLE_ENDIAN && UNALIGNED_WORD_ACCESS
-  #if HAVE_UINT64_T
+  #ifdef HAVE_UINT64_T
 	    last |= (uint64_t) ((uint32_t *) end)[0];
   #else
 	    last.lo |= ((uint32_t *) end)[0];
diff --git a/strftime.c b/strftime.c
index d963038..17cfed1 100644
--- a/strftime.c
+++ b/strftime.c
@@ -59,7 +59,7 @@ https://github.com/ruby/ruby/blob/trunk/strftime.c#L59
 #endif
 #if defined(TM_IN_SYS_TIME) || !defined(GAWK)
 #include <sys/types.h>
-#if HAVE_SYS_TIME_H
+#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
 #endif
diff --git a/thread_pthread.c b/thread_pthread.c
index 8149ee5..3e0c78b 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -20,9 +20,9 @@ https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L20
 #ifdef HAVE_THR_STKSEGMENT
 #include <thread.h>
 #endif
-#if HAVE_FCNTL_H
+#if defined(HAVE_FCNTL_H)
 #include <fcntl.h>
-#elif HAVE_SYS_FCNTL_H
+#elif defined(HAVE_SYS_FCNTL_H)
 #include <sys/fcntl.h>
 #endif
 #ifdef HAVE_SYS_PRCTL_H
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]