Skip to content

Commit 34f96b4

Browse files
committed
Fix various [-Wundef] compiler warnings
1 parent 3a7b482 commit 34f96b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+415
-413
lines changed

TSRM/TSRM.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <stdio.h>
1818
#include <stdarg.h>
1919

20-
#ifdef ZEND_DEBUG
20+
#if ZEND_DEBUG
2121
# include <assert.h>
2222
# define TSRM_ASSERT assert
2323
#else
@@ -74,7 +74,7 @@ int tsrm_error(int level, const char *format, ...);
7474
static int tsrm_error_level;
7575
static FILE *tsrm_error_file;
7676

77-
#if TSRM_DEBUG
77+
#ifdef TSRM_DEBUG
7878
#define TSRM_ERROR(args) tsrm_error args
7979
#define TSRM_SAFE_RETURN_RSRC(array, offset, range) \
8080
{ \
@@ -102,7 +102,7 @@ static FILE *tsrm_error_file;
102102
}
103103
#endif
104104

105-
#if defined(TSRM_WIN32)
105+
#ifdef TSRM_WIN32
106106
static DWORD tls_key;
107107
# define tsrm_tls_set(what) TlsSetValue(tls_key, (void*)(what))
108108
# define tsrm_tls_get() TlsGetValue(tls_key)
@@ -118,7 +118,7 @@ TSRM_TLS uint8_t is_thread_shutdown = 0;
118118
/* Startup TSRM (call once for the entire process) */
119119
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename)
120120
{/*{{{*/
121-
#if defined(TSRM_WIN32)
121+
#ifdef TSRM_WIN32
122122
tls_key = TlsAlloc();
123123
#else
124124
pthread_key_create(&tls_key, 0);
@@ -209,7 +209,7 @@ TSRM_API void tsrm_shutdown(void)
209209
if (tsrm_error_file!=stderr) {
210210
fclose(tsrm_error_file);
211211
}
212-
#if defined(TSRM_WIN32)
212+
#ifdef TSRM_WIN32
213213
TlsFree(tls_key);
214214
#else
215215
pthread_setspecific(tls_key, 0);
@@ -677,7 +677,7 @@ TSRM_API void *tsrm_set_shutdown_handler(tsrm_shutdown_func_t shutdown_handler)
677677
* Debug support
678678
*/
679679

680-
#if TSRM_DEBUG
680+
#ifdef TSRM_DEBUG
681681
int tsrm_error(int level, const char *format, ...)
682682
{/*{{{*/
683683
if (level<=tsrm_error_level) {
@@ -702,7 +702,7 @@ void tsrm_error_set(int level, char *debug_filename)
702702
{/*{{{*/
703703
tsrm_error_level = level;
704704

705-
#if TSRM_DEBUG
705+
#ifdef TSRM_DEBUG
706706
if (tsrm_error_file!=stderr) { /* close files opened earlier */
707707
fclose(tsrm_error_file);
708708
}
@@ -758,7 +758,7 @@ TSRM_API uint8_t tsrm_is_shutdown(void)
758758

759759
TSRM_API const char *tsrm_api_name(void)
760760
{/*{{{*/
761-
#if defined(TSRM_WIN32)
761+
#ifdef TSRM_WIN32
762762
return "Windows Threads";
763763
#else
764764
return "POSIX Threads";

Zend/zend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ int zend_startup(zend_utility_functions *utility_functions) /* {{{ */
828828

829829
zend_interrupt_function = NULL;
830830

831-
#if HAVE_DTRACE
831+
#ifdef HAVE_DTRACE
832832
/* build with dtrace support */
833833
{
834834
char *tmp = getenv("USE_ZEND_DTRACE");

Zend/zend_API.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ typedef struct _zend_fcall_info_cache {
204204
#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor) \
205205
ts_allocate_id(&module_name##_globals_id, sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor);
206206
#define ZEND_MODULE_GLOBALS_ACCESSOR(module_name, v) ZEND_TSRMG(module_name##_globals_id, zend_##module_name##_globals *, v)
207-
#if ZEND_ENABLE_STATIC_TSRMLS_CACHE
207+
#ifdef ZEND_ENABLE_STATIC_TSRMLS_CACHE
208208
#define ZEND_MODULE_GLOBALS_BULK(module_name) TSRMG_BULK_STATIC(module_name##_globals_id, zend_##module_name##_globals *)
209209
#else
210210
#define ZEND_MODULE_GLOBALS_BULK(module_name) TSRMG_BULK(module_name##_globals_id, zend_##module_name##_globals *)

Zend/zend_hash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static void ZEND_FASTCALL zend_hash_do_resize(HashTable *ht);
110110

111111
static zend_always_inline uint32_t zend_hash_check_size(uint32_t nSize)
112112
{
113-
#if defined(ZEND_WIN32)
113+
#ifdef ZEND_WIN32
114114
unsigned long index;
115115
#endif
116116

@@ -122,7 +122,7 @@ static zend_always_inline uint32_t zend_hash_check_size(uint32_t nSize)
122122
zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%u * %zu + %zu)", nSize, sizeof(Bucket), sizeof(Bucket));
123123
}
124124

125-
#if defined(ZEND_WIN32)
125+
#ifdef ZEND_WIN32
126126
if (BitScanReverse(&index, nSize - 1)) {
127127
return 0x2u << ((31 - index) ^ 0x1f);
128128
} else {

Zend/zend_object_handlers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
13891389
}
13901390
} while (0);
13911391

1392-
#if MBO_0
1392+
#ifdef MBO_0
13931393
/* right now this function is used for non static method lookup too */
13941394
/* Is the function static */
13951395
if (UNEXPECTED(!(fbc->common.fn_flags & ZEND_ACC_STATIC))) {

Zend/zend_operators.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <emmintrin.h>
3535
#endif
3636

37-
#if ZEND_USE_TOLOWER_L
37+
#ifdef ZEND_USE_TOLOWER_L
3838
#include <locale.h>
3939
static _locale_t current_locale = NULL;
4040
/* this is true global! may lead to strange effects on ZTS, but so may setlocale() */
@@ -3187,7 +3187,7 @@ ZEND_API const char* ZEND_FASTCALL zend_memnrstr_ex(const char *haystack, const
31873187
}
31883188
/* }}} */
31893189

3190-
#if !ZEND_DVAL_TO_LVAL_CAST_OK
3190+
#ifndef ZEND_DVAL_TO_LVAL_CAST_OK
31913191
# if SIZEOF_ZEND_LONG == 4
31923192
ZEND_API zend_long ZEND_FASTCALL zend_dval_to_lval_slow(double d) /* {{{ */
31933193
{

Zend/zend_operators.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ZEND_API const char* ZEND_FASTCALL zend_memnrstr_ex(const char *haystack, const
9898
# define ZEND_DOUBLE_FITS_LONG(d) (!((d) >= (double)ZEND_LONG_MAX || (d) < (double)ZEND_LONG_MIN))
9999
#endif
100100

101-
#if ZEND_DVAL_TO_LVAL_CAST_OK
101+
#ifdef ZEND_DVAL_TO_LVAL_CAST_OK
102102
static zend_always_inline zend_long zend_dval_to_lval(double d)
103103
{
104104
if (EXPECTED(zend_finite(d)) && EXPECTED(!zend_isnan(d))) {

Zend/zend_portability.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ char *alloca();
318318
# endif
319319
#endif /* ZEND_DEBUG */
320320

321-
#if PHP_HAVE_BUILTIN_EXPECT
321+
#ifdef PHP_HAVE_BUILTIN_EXPECT
322322
# define EXPECTED(condition) __builtin_expect(!!(condition), 1)
323323
# define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
324324
#else
@@ -351,7 +351,7 @@ char *alloca();
351351

352352
#endif
353353

354-
#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(HPUX)) && !defined(DARWIN)
354+
#if (defined(HAVE_ALLOCA) || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(HPUX)) && !defined(DARWIN)
355355
# define ZEND_ALLOCA_MAX_SIZE (32 * 1024)
356356
# define ALLOCA_FLAG(name) \
357357
zend_bool name;
@@ -494,19 +494,19 @@ extern "C++" {
494494
#endif
495495

496496
#if (defined(__i386__) || defined(__x86_64__))
497-
# if PHP_HAVE_SSSE3_INSTRUCTIONS && defined(HAVE_TMMINTRIN_H)
497+
# if defined(PHP_HAVE_SSSE3_INSTRUCTIONS) && defined(HAVE_TMMINTRIN_H)
498498
# define PHP_HAVE_SSSE3
499499
# endif
500500

501-
# if PHP_HAVE_SSE4_2_INSTRUCTIONS && defined(HAVE_NMMINTRIN_H)
501+
# if defined(PHP_HAVE_SSE4_2_INSTRUCTIONS) && defined(HAVE_NMMINTRIN_H)
502502
# define PHP_HAVE_SSE4_2
503503
# endif
504504

505505
/*
506506
* AVX2 support was added in gcc 4.7, but AVX2 intrinsics don't work in
507507
* __attribute__((target("avx2"))) functions until gcc 4.9.
508508
*/
509-
# if PHP_HAVE_AVX2_INSTRUCTIONS && defined(HAVE_IMMINTRIN_H) && \
509+
# if defined(PHP_HAVE_AVX2_INSTRUCTIONS) && defined(HAVE_IMMINTRIN_H) && \
510510
(defined(__llvm__) || defined(__clang__) || (defined(__GNUC__) && ZEND_GCC_VERSION >= 4009))
511511
# define PHP_HAVE_AVX2
512512
# endif
@@ -521,14 +521,14 @@ extern "C++" {
521521
#endif
522522

523523
/* Do not use for conditional declaration of API functions! */
524-
#if ZEND_INTRIN_SSSE3_RESOLVER && ZEND_INTRIN_HAVE_IFUNC_TARGET
524+
#if defined(ZEND_INTRIN_SSSE3_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
525525
# define ZEND_INTRIN_SSSE3_FUNC_PROTO 1
526-
#elif ZEND_INTRIN_SSSE3_RESOLVER
526+
#elif defined(ZEND_INTRIN_SSSE3_RESOLVER)
527527
# define ZEND_INTRIN_SSSE3_FUNC_PTR 1
528528
#endif
529529

530-
#if ZEND_INTRIN_SSSE3_RESOLVER
531-
# if defined(HAVE_FUNC_ATTRIBUTE_TARGET)
530+
#ifdef ZEND_INTRIN_SSSE3_RESOLVER
531+
# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
532532
# define ZEND_INTRIN_SSSE3_FUNC_DECL(func) ZEND_API func __attribute__((target("ssse3")))
533533
# else
534534
# define ZEND_INTRIN_SSSE3_FUNC_DECL(func) func
@@ -546,14 +546,14 @@ extern "C++" {
546546
#endif
547547

548548
/* Do not use for conditional declaration of API functions! */
549-
#if ZEND_INTRIN_SSE4_2_RESOLVER && ZEND_INTRIN_HAVE_IFUNC_TARGET
549+
#if defined(ZEND_INTRIN_SSE4_2_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
550550
# define ZEND_INTRIN_SSE4_2_FUNC_PROTO 1
551-
#elif ZEND_INTRIN_SSE4_2_RESOLVER
551+
#elif defined(ZEND_INTRIN_SSE4_2_RESOLVER)
552552
# define ZEND_INTRIN_SSE4_2_FUNC_PTR 1
553553
#endif
554554

555-
#if ZEND_INTRIN_SSE4_2_RESOLVER
556-
# if defined(HAVE_FUNC_ATTRIBUTE_TARGET)
555+
#ifdef ZEND_INTRIN_SSE4_2_RESOLVER
556+
# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
557557
# define ZEND_INTRIN_SSE4_2_FUNC_DECL(func) ZEND_API func __attribute__((target("sse4.2")))
558558
# else
559559
# define ZEND_INTRIN_SSE4_2_FUNC_DECL(func) func
@@ -569,14 +569,14 @@ extern "C++" {
569569
#endif
570570

571571
/* Do not use for conditional declaration of API functions! */
572-
#if ZEND_INTRIN_AVX2_RESOLVER && ZEND_INTRIN_HAVE_IFUNC_TARGET
572+
#if defined(ZEND_INTRIN_AVX2_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
573573
# define ZEND_INTRIN_AVX2_FUNC_PROTO 1
574-
#elif ZEND_INTRIN_AVX2_RESOLVER
574+
#elif defined(ZEND_INTRIN_AVX2_RESOLVER)
575575
# define ZEND_INTRIN_AVX2_FUNC_PTR 1
576576
#endif
577577

578-
#if ZEND_INTRIN_AVX2_RESOLVER
579-
# if defined(HAVE_FUNC_ATTRIBUTE_TARGET)
578+
#ifdef ZEND_INTRIN_AVX2_RESOLVER
579+
# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
580580
# define ZEND_INTRIN_AVX2_FUNC_DECL(func) ZEND_API func __attribute__((target("avx2")))
581581
# else
582582
# define ZEND_INTRIN_AVX2_FUNC_DECL(func) func
@@ -589,7 +589,7 @@ extern "C++" {
589589

590590
#ifdef ZEND_WIN32
591591
# define ZEND_SET_ALIGNED(alignment, decl) __declspec(align(alignment)) decl
592-
#elif HAVE_ATTRIBUTE_ALIGNED
592+
#elif defined(HAVE_ATTRIBUTE_ALIGNED)
593593
# define ZEND_SET_ALIGNED(alignment, decl) decl __attribute__ ((__aligned__ (alignment)))
594594
#else
595595
# define ZEND_SET_ALIGNED(alignment, decl) decl

ext/bz2/bz2.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "php_bz2.h"
2323
#include "bz2_arginfo.h"
2424

25-
#if HAVE_BZ2
25+
#ifdef HAVE_BZ2
2626

2727
/* PHP Includes */
2828
#include "ext/standard/info.h"
@@ -504,7 +504,7 @@ PHP_FUNCTION(bzdecompress)
504504
size_t source_len;
505505
int error;
506506
zend_long small = 0;
507-
#if defined(PHP_WIN32)
507+
#ifdef PHP_WIN32
508508
unsigned __int64 size = 0;
509509
#else
510510
unsigned long long size = 0;
@@ -534,7 +534,7 @@ PHP_FUNCTION(bzdecompress)
534534
/* compression is better then 2:1, need to allocate more memory */
535535
bzs.avail_out = source_len;
536536
size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32;
537-
#if !ZEND_ENABLE_ZVAL_LONG64
537+
#ifndef ZEND_ENABLE_ZVAL_LONG64
538538
if (size > SIZE_MAX) {
539539
/* no reason to continue if we're going to drop it anyway */
540540
break;
@@ -546,7 +546,7 @@ PHP_FUNCTION(bzdecompress)
546546

547547
if (error == BZ_STREAM_END || error == BZ_OK) {
548548
size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32;
549-
#if !ZEND_ENABLE_ZVAL_LONG64
549+
#ifndef ZEND_ENABLE_ZVAL_LONG64
550550
if (UNEXPECTED(size > SIZE_MAX)) {
551551
php_error_docref(NULL, E_WARNING, "Decompressed size too big, max is %zd", SIZE_MAX);
552552
zend_string_efree(dest);

ext/bz2/php_bz2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef PHP_BZ2_H
1818
#define PHP_BZ2_H
1919

20-
#if HAVE_BZ2
20+
#ifdef HAVE_BZ2
2121

2222
extern zend_module_entry bz2_module_entry;
2323
#define phpext_bz2_ptr &bz2_module_entry

ext/date/lib/timelib_private.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@
4949
# include <stdint.h>
5050
#endif
5151

52-
#if HAVE_UNISTD_H
52+
#ifdef HAVE_UNISTD_H
5353
# include <unistd.h>
5454
#endif
5555

56-
#if HAVE_IO_H
56+
#ifdef HAVE_IO_H
5757
# include <io.h>
5858
#endif
5959

60-
#if HAVE_DIRENT_H
60+
#ifdef HAVE_DIRENT_H
6161
# include <dirent.h>
6262
#endif
6363

ext/ffi/ffi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5105,7 +5105,7 @@ const struct {
51055105
{"ssize_t", &zend_ffi_type_sint64},
51065106
{"ptrdiff_t", &zend_ffi_type_sint64},
51075107
#endif
5108-
#if SIZEOF_OFF_T == 4
5108+
#if defined(SIZEOF_OFF_T) && SIZEOF_OFF_T == 4
51095109
{"off_t", &zend_ffi_type_sint32},
51105110
#else
51115111
{"off_t", &zend_ffi_type_sint64},

ext/fileinfo/libmagic/file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090

9191
#define private static
9292

93-
#if HAVE_VISIBILITY && !defined(WIN32)
93+
#if defined(HAVE_VISIBILITY) && !defined(WIN32)
9494
#define public __attribute__ ((__visibility__("default")))
9595
#ifndef protected
9696
#define protected __attribute__ ((__visibility__("hidden")))

ext/fileinfo/libmagic/funcs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ file_buffer(struct magic_set *ms, php_stream *stream, zend_stat_t *st,
255255
}
256256
#endif
257257

258-
#if PHP_FILEINFO_UNCOMPRESS
258+
#ifdef PHP_FILEINFO_UNCOMPRESS
259259
if ((ms->flags & MAGIC_NO_CHECK_COMPRESS) == 0) {
260260
m = file_zmagic(ms, &b, inname);
261261
if ((ms->flags & MAGIC_DEBUG) != 0)
@@ -367,7 +367,7 @@ file_buffer(struct magic_set *ms, php_stream *stream, zend_stat_t *st,
367367
if (file_printf(ms, "%s", code_mime) == -1)
368368
rv = -1;
369369
}
370-
#if PHP_FILEINFO_UNCOMPRESS
370+
#ifdef PHP_FILEINFO_UNCOMPRESS
371371
done_encoding:
372372
#endif
373373
efree(rbuf);
@@ -434,7 +434,7 @@ file_getbuffer(struct magic_set *ms)
434434
}
435435
ms->o.pbuf = pbuf;
436436

437-
#if defined(HAVE_WCWIDTH)
437+
#ifdef HAVE_WCWIDTH
438438
{
439439
mbstate_t state;
440440
wchar_t nextchar;

ext/ftp/ftp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include "php.h"
2323

24-
#if HAVE_FTP
24+
#ifdef HAVE_FTP
2525

2626
#include <stdio.h>
2727
#include <ctype.h>
@@ -45,7 +45,7 @@
4545
#endif
4646
#include <errno.h>
4747

48-
#if HAVE_SYS_TIME_H
48+
#ifdef HAVE_SYS_TIME_H
4949
#include <sys/time.h>
5050
#endif
5151

@@ -816,7 +816,7 @@ ftp_pasv(ftpbuf_t *ftp, int pasv)
816816
return 0;
817817
}
818818

819-
#if HAVE_IPV6
819+
#ifdef HAVE_IPV6
820820
if (sa->sa_family == AF_INET6) {
821821
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa;
822822
char *endptr, delimiter;
@@ -1719,7 +1719,7 @@ ftp_getdata(ftpbuf_t *ftp)
17191719

17201720
data->listener = fd;
17211721

1722-
#if HAVE_IPV6 && HAVE_INET_NTOP
1722+
#if defined(HAVE_IPV6) && defined(HAVE_INET_NTOP)
17231723
if (sa->sa_family == AF_INET6) {
17241724
/* need to use EPRT */
17251725
char eprtarg[INET6_ADDRSTRLEN + sizeof("|x||xxxxx|")];

0 commit comments

Comments
 (0)