Skip to content

Commit cf3b9fc

Browse files
authored
Sync #if/ifdef/defined (-Wundef) (#14623)
These are either define (to value 1) or undefined: - __GNUC__ - DBA_CDB_BUILTIN - DBA_GDBM - HAVE_FORK - HAVE_PUTENV - HAVE_SETENV - HAVE_SYS_SELECT_H - HAVE_SYS_SOCKET_H - HAVE_SYS_WAIT_H - HAVE_UNSETENV - RFC3678_API - ZEND_ENABLE_ZVAL_LONG64 - ZTS Follow-up of GH-5526
1 parent ab9a029 commit cf3b9fc

File tree

14 files changed

+39
-39
lines changed

14 files changed

+39
-39
lines changed

ext/dba/dba_cdb.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#endif
3131
#include <fcntl.h>
3232

33-
#if DBA_CDB_BUILTIN
33+
#ifdef DBA_CDB_BUILTIN
3434
# include "libcdb/cdb.h"
3535
# include "libcdb/cdb_make.h"
3636
# include "libcdb/uint32.h"
@@ -45,7 +45,7 @@
4545

4646
typedef struct {
4747
struct cdb c;
48-
#if DBA_CDB_BUILTIN
48+
#ifdef DBA_CDB_BUILTIN
4949
struct cdb_make m;
5050
php_stream *file;
5151
int make;
@@ -58,7 +58,7 @@ typedef struct {
5858

5959
DBA_OPEN_FUNC(cdb)
6060
{
61-
#if DBA_CDB_BUILTIN
61+
#ifdef DBA_CDB_BUILTIN
6262
php_stream* file = 0;
6363
int make;
6464
#else
@@ -69,7 +69,7 @@ DBA_OPEN_FUNC(cdb)
6969

7070
switch (info->mode) {
7171
case DBA_READER:
72-
#if DBA_CDB_BUILTIN
72+
#ifdef DBA_CDB_BUILTIN
7373
make = 0;
7474
file = info->fp;
7575
#else
@@ -80,7 +80,7 @@ DBA_OPEN_FUNC(cdb)
8080
}
8181
#endif
8282
break;
83-
#if DBA_CDB_BUILTIN
83+
#ifdef DBA_CDB_BUILTIN
8484
case DBA_TRUNC:
8585
make = 1;
8686
file = info->fp;
@@ -98,7 +98,7 @@ DBA_OPEN_FUNC(cdb)
9898
cdb = pemalloc(sizeof(dba_cdb), info->flags&DBA_PERSISTENT);
9999
memset(cdb, 0, sizeof(dba_cdb));
100100

101-
#if DBA_CDB_BUILTIN
101+
#ifdef DBA_CDB_BUILTIN
102102
if (make) {
103103
cdb_make_start(&cdb->m, file);
104104
} else {
@@ -119,7 +119,7 @@ DBA_CLOSE_FUNC(cdb)
119119
CDB_INFO;
120120

121121
/* cdb_free does not close associated file */
122-
#if DBA_CDB_BUILTIN
122+
#ifdef DBA_CDB_BUILTIN
123123
if (cdb->make) {
124124
cdb_make_finish(&cdb->m);
125125
} else {
@@ -132,7 +132,7 @@ DBA_CLOSE_FUNC(cdb)
132132
pefree(cdb, info->flags&DBA_PERSISTENT);
133133
}
134134

135-
#if DBA_CDB_BUILTIN
135+
#ifdef DBA_CDB_BUILTIN
136136
# define php_cdb_read(cdb, buf, len, pos) cdb_read(cdb, buf, len, pos)
137137
# define php_cdb_findnext(cdb, key, len) cdb_findnext(cdb, key, len)
138138
# define php_cdb_find(cdb, key, len) cdb_find(cdb, key, len)
@@ -148,7 +148,7 @@ DBA_FETCH_FUNC(cdb)
148148
zend_string *fetched_val = NULL;
149149
unsigned int len;
150150

151-
#if DBA_CDB_BUILTIN
151+
#ifdef DBA_CDB_BUILTIN
152152
if (cdb->make)
153153
return NULL; /* database was opened writeonly */
154154
#endif
@@ -173,7 +173,7 @@ DBA_FETCH_FUNC(cdb)
173173

174174
DBA_UPDATE_FUNC(cdb)
175175
{
176-
#if DBA_CDB_BUILTIN
176+
#ifdef DBA_CDB_BUILTIN
177177
CDB_INFO;
178178

179179
if (!cdb->make)
@@ -190,7 +190,7 @@ DBA_EXISTS_FUNC(cdb)
190190
{
191191
CDB_INFO;
192192

193-
#if DBA_CDB_BUILTIN
193+
#ifdef DBA_CDB_BUILTIN
194194
if (cdb->make)
195195
return FAILURE; /* database was opened writeonly */
196196
#endif
@@ -205,7 +205,7 @@ DBA_DELETE_FUNC(cdb)
205205
}
206206

207207
/* {{{ cdb_file_read */
208-
#if DBA_CDB_BUILTIN
208+
#ifdef DBA_CDB_BUILTIN
209209
# define cdb_file_read(fildes, buf, size) php_stream_read(fildes, buf, size)
210210
#else
211211
# define cdb_file_read(fildes, buf, size) read(fildes, buf, size)
@@ -218,7 +218,7 @@ DBA_DELETE_FUNC(cdb)
218218

219219
/* {{{ cdb_file_lseek
220220
php_stream_seek does not return actual position */
221-
#if DBA_CDB_BUILTIN
221+
#ifdef DBA_CDB_BUILTIN
222222
zend_off_t cdb_file_lseek(php_stream *fp, zend_off_t offset, int whence) {
223223
php_stream_seek(fp, offset, whence);
224224
return php_stream_tell(fp);
@@ -243,7 +243,7 @@ DBA_FIRSTKEY_FUNC(cdb)
243243
char buf[8];
244244
zend_string *key;
245245

246-
#if DBA_CDB_BUILTIN
246+
#ifdef DBA_CDB_BUILTIN
247247
if (cdb->make)
248248
return NULL; /* database was opened writeonly */
249249
#endif
@@ -283,7 +283,7 @@ DBA_NEXTKEY_FUNC(cdb)
283283
char buf[8];
284284
zend_string *key;
285285

286-
#if DBA_CDB_BUILTIN
286+
#ifdef DBA_CDB_BUILTIN
287287
if (cdb->make)
288288
return NULL; /* database was opened writeonly */
289289
#endif
@@ -319,7 +319,7 @@ DBA_SYNC_FUNC(cdb)
319319

320320
DBA_INFO_FUNC(cdb)
321321
{
322-
#if DBA_CDB_BUILTIN
322+
#ifdef DBA_CDB_BUILTIN
323323
if (!strcmp(hnd->name, "cdb")) {
324324
return estrdup(cdb_version());
325325
} else {

ext/dba/dba_dbm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ DBA_SYNC_FUNC(dbm)
188188

189189
DBA_INFO_FUNC(dbm)
190190
{
191-
#if DBA_GDBM
191+
#ifdef DBA_GDBM
192192
if (!strcmp(DBM_VERSION, "GDBM"))
193193
{
194194
return dba_info_gdbm(hnd, info);

ext/opcache/ZendAccelerator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2181,7 +2181,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
21812181
ZCSG(hits)++; /* TBFixed: may lose one hit */
21822182
persistent_script->dynamic_members.hits++; /* see above */
21832183
#else
2184-
#if ZEND_ENABLE_ZVAL_LONG64
2184+
#ifdef ZEND_ENABLE_ZVAL_LONG64
21852185
InterlockedIncrement64(&ZCSG(hits));
21862186
InterlockedIncrement64(&persistent_script->dynamic_members.hits);
21872187
#else

ext/sockets/multicast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ static int _php_mcast_source_op(
560560
#endif
561561
}
562562

563-
#if RFC3678_API
563+
#ifdef RFC3678_API
564564
static int _php_source_op_to_rfc3678_op(enum source_op sop)
565565
{
566566
switch (sop) {

ext/sockets/php_sockets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extern zend_module_entry sockets_module_entry;
4141
#ifdef PHP_WIN32
4242
#include <Winsock2.h>
4343
#else
44-
#if HAVE_SYS_SOCKET_H
44+
#ifdef HAVE_SYS_SOCKET_H
4545
#include <sys/socket.h>
4646
#endif
4747
#endif

ext/standard/basic_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ typedef struct _user_tick_function_entry {
122122
bool calling;
123123
} user_tick_function_entry;
124124

125-
#if HAVE_PUTENV
125+
#ifdef HAVE_PUTENV
126126
typedef struct {
127127
char *putenv_string;
128128
char *previous_value;

ext/standard/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
# ifdef HAVE_SYS_PARAM_H
4949
# include <sys/param.h>
5050
# endif
51-
# if HAVE_SYS_SELECT_H
51+
# ifdef HAVE_SYS_SELECT_H
5252
# include <sys/select.h>
5353
# endif
5454
# include <sys/socket.h>

ext/standard/proc_open.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static void _php_free_envp(php_process_env env)
232232
}
233233
/* }}} */
234234

235-
#if HAVE_SYS_WAIT_H
235+
#ifdef HAVE_SYS_WAIT_H
236236
static pid_t waitpid_cached(php_process_handle *proc, int *wait_status, int options)
237237
{
238238
if (proc->has_cached_exit_wait_status) {
@@ -544,7 +544,7 @@ static bool is_special_character_present(const zend_string *arg)
544544
return false;
545545
}
546546

547-
/* See https://docs.microsoft.com/en-us/cpp/cpp/parsing-cpp-command-line-arguments and
547+
/* See https://docs.microsoft.com/en-us/cpp/cpp/parsing-cpp-command-line-arguments and
548548
* https://learn.microsoft.com/en-us/archive/blogs/twistylittlepassagesallalike/everyone-quotes-command-line-arguments-the-wrong-way */
549549
static void append_win_escaped_arg(smart_str *str, zend_string *arg, bool is_cmd_argument)
550550
{
@@ -1352,7 +1352,7 @@ PHP_FUNCTION(proc_open)
13521352
php_error_docref(NULL, E_WARNING, "posix_spawn() failed: %s", strerror(r));
13531353
goto exit_fail;
13541354
}
1355-
#elif HAVE_FORK
1355+
#elif defined(HAVE_FORK)
13561356
/* the Unix way */
13571357
child = fork();
13581358

@@ -1414,7 +1414,7 @@ PHP_FUNCTION(proc_open)
14141414
proc->childHandle = childHandle;
14151415
#endif
14161416
proc->env = env;
1417-
#if HAVE_SYS_WAIT_H
1417+
#ifdef HAVE_SYS_WAIT_H
14181418
proc->has_cached_exit_wait_status = false;
14191419
#endif
14201420

ext/standard/proc_open.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ typedef struct _php_process_handle {
4343
zend_resource **pipes;
4444
zend_string *command;
4545
php_process_env env;
46-
#if HAVE_SYS_WAIT_H
46+
#ifdef HAVE_SYS_WAIT_H
4747
/* We can only request the status once before it becomes unavailable.
4848
* Cache the result so we can request it multiple times. */
4949
int cached_exit_wait_status_value;

sapi/cgi/cgi_main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -595,23 +595,23 @@ static char *sapi_fcgi_getenv(const char *name, size_t name_len)
595595

596596
static char *_sapi_cgi_putenv(char *name, size_t name_len, char *value)
597597
{
598-
#if !HAVE_SETENV || !HAVE_UNSETENV
598+
#if !defined(HAVE_SETENV) || !defined(HAVE_UNSETENV)
599599
size_t len;
600600
char *buf;
601601
#endif
602602

603-
#if HAVE_SETENV
603+
#ifdef HAVE_SETENV
604604
if (value) {
605605
setenv(name, value, 1);
606606
}
607607
#endif
608-
#if HAVE_UNSETENV
608+
#ifdef HAVE_UNSETENV
609609
if (!value) {
610610
unsetenv(name);
611611
}
612612
#endif
613613

614-
#if !HAVE_SETENV || !HAVE_UNSETENV
614+
#if !defined(HAVE_SETENV) || !defined(HAVE_UNSETENV)
615615
/* if cgi, or fastcgi and not found in fcgi env
616616
check the regular environment
617617
this leaks, but it's only cgi anyway, we'll fix
@@ -623,13 +623,13 @@ static char *_sapi_cgi_putenv(char *name, size_t name_len, char *value)
623623
return getenv(name);
624624
}
625625
#endif
626-
#if !HAVE_SETENV
626+
#if !defined(HAVE_SETENV)
627627
if (value) {
628628
len = slprintf(buf, len - 1, "%s=%s", name, value);
629629
putenv(buf);
630630
}
631631
#endif
632-
#if !HAVE_UNSETENV
632+
#if !defined(HAVE_UNSETENV)
633633
if (!value) {
634634
len = slprintf(buf, len - 1, "%s=", name);
635635
putenv(buf);

sapi/cli/php_cli_server.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
#define OUTPUT_IS_TTY 1
111111
#define OUTPUT_NOT_TTY 0
112112

113-
#if HAVE_FORK
113+
#ifdef HAVE_FORK
114114
# include <sys/wait.h>
115115
static pid_t php_cli_server_master;
116116
static pid_t *php_cli_server_workers;
@@ -2362,7 +2362,7 @@ static void php_cli_server_dtor(php_cli_server *server) /* {{{ */
23622362
if (server->router) {
23632363
pefree(server->router, 1);
23642364
}
2365-
#if HAVE_FORK
2365+
#ifdef HAVE_FORK
23662366
if (php_cli_server_workers_max > 1 &&
23672367
php_cli_server_workers &&
23682368
getpid() == php_cli_server_master) {
@@ -2484,7 +2484,7 @@ static void php_cli_server_startup_workers(void) {
24842484
return;
24852485
}
24862486

2487-
#if HAVE_FORK
2487+
#ifdef HAVE_FORK
24882488
php_cli_server_workers_max = ZEND_ATOL(workers);
24892489
if (php_cli_server_workers_max > 1) {
24902490
zend_long php_cli_server_worker;

sapi/litespeed/lsapilib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ int LSAPI_Postfork_Parent(LSAPI_Request * pReq);
418418
#define LSAPI_LOG_PID (0x10000)
419419

420420
void LSAPI_Log(int flag, const char * fmt, ...)
421-
#if __GNUC__
421+
#ifdef __GNUC__
422422
__attribute__((format(printf, 2, 3)))
423423
#endif
424424
;

scripts/phpize.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ old_CPPFLAGS=$CPPFLAGS
100100
CPPFLAGS="-I$phpincludedir"
101101
AC_EGREP_CPP(php_zts_is_enabled,[
102102
#include <main/php_config.h>
103-
#if ZTS
103+
#ifdef ZTS
104104
php_zts_is_enabled
105105
#endif
106106
],[

win32/signal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ PHP_FUNCTION(sapi_windows_set_ctrl_handler)
9797
RETURN_THROWS();
9898
}
9999

100-
#if ZTS
100+
#ifdef ZTS
101101
if (!tsrm_is_main_thread()) {
102102
zend_throw_error(NULL, "CTRL events can only be received on the main thread");
103103
RETURN_THROWS();

0 commit comments

Comments
 (0)