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
This commit is contained in:
Peter Kokot 2024-06-24 19:37:07 +02:00 committed by GitHub
parent ab9a0295c5
commit cf3b9fca8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 39 additions and 39 deletions

View File

@ -30,7 +30,7 @@
#endif
#include <fcntl.h>
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
# include "libcdb/cdb.h"
# include "libcdb/cdb_make.h"
# include "libcdb/uint32.h"
@ -45,7 +45,7 @@
typedef struct {
struct cdb c;
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
struct cdb_make m;
php_stream *file;
int make;
@ -58,7 +58,7 @@ typedef struct {
DBA_OPEN_FUNC(cdb)
{
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
php_stream* file = 0;
int make;
#else
@ -69,7 +69,7 @@ DBA_OPEN_FUNC(cdb)
switch (info->mode) {
case DBA_READER:
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
make = 0;
file = info->fp;
#else
@ -80,7 +80,7 @@ DBA_OPEN_FUNC(cdb)
}
#endif
break;
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
case DBA_TRUNC:
make = 1;
file = info->fp;
@ -98,7 +98,7 @@ DBA_OPEN_FUNC(cdb)
cdb = pemalloc(sizeof(dba_cdb), info->flags&DBA_PERSISTENT);
memset(cdb, 0, sizeof(dba_cdb));
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
if (make) {
cdb_make_start(&cdb->m, file);
} else {
@ -119,7 +119,7 @@ DBA_CLOSE_FUNC(cdb)
CDB_INFO;
/* cdb_free does not close associated file */
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
if (cdb->make) {
cdb_make_finish(&cdb->m);
} else {
@ -132,7 +132,7 @@ DBA_CLOSE_FUNC(cdb)
pefree(cdb, info->flags&DBA_PERSISTENT);
}
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
# define php_cdb_read(cdb, buf, len, pos) cdb_read(cdb, buf, len, pos)
# define php_cdb_findnext(cdb, key, len) cdb_findnext(cdb, key, len)
# define php_cdb_find(cdb, key, len) cdb_find(cdb, key, len)
@ -148,7 +148,7 @@ DBA_FETCH_FUNC(cdb)
zend_string *fetched_val = NULL;
unsigned int len;
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
if (cdb->make)
return NULL; /* database was opened writeonly */
#endif
@ -173,7 +173,7 @@ DBA_FETCH_FUNC(cdb)
DBA_UPDATE_FUNC(cdb)
{
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
CDB_INFO;
if (!cdb->make)
@ -190,7 +190,7 @@ DBA_EXISTS_FUNC(cdb)
{
CDB_INFO;
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
if (cdb->make)
return FAILURE; /* database was opened writeonly */
#endif
@ -205,7 +205,7 @@ DBA_DELETE_FUNC(cdb)
}
/* {{{ cdb_file_read */
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
# define cdb_file_read(fildes, buf, size) php_stream_read(fildes, buf, size)
#else
# define cdb_file_read(fildes, buf, size) read(fildes, buf, size)
@ -218,7 +218,7 @@ DBA_DELETE_FUNC(cdb)
/* {{{ cdb_file_lseek
php_stream_seek does not return actual position */
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
zend_off_t cdb_file_lseek(php_stream *fp, zend_off_t offset, int whence) {
php_stream_seek(fp, offset, whence);
return php_stream_tell(fp);
@ -243,7 +243,7 @@ DBA_FIRSTKEY_FUNC(cdb)
char buf[8];
zend_string *key;
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
if (cdb->make)
return NULL; /* database was opened writeonly */
#endif
@ -283,7 +283,7 @@ DBA_NEXTKEY_FUNC(cdb)
char buf[8];
zend_string *key;
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
if (cdb->make)
return NULL; /* database was opened writeonly */
#endif
@ -319,7 +319,7 @@ DBA_SYNC_FUNC(cdb)
DBA_INFO_FUNC(cdb)
{
#if DBA_CDB_BUILTIN
#ifdef DBA_CDB_BUILTIN
if (!strcmp(hnd->name, "cdb")) {
return estrdup(cdb_version());
} else {

View File

@ -188,7 +188,7 @@ DBA_SYNC_FUNC(dbm)
DBA_INFO_FUNC(dbm)
{
#if DBA_GDBM
#ifdef DBA_GDBM
if (!strcmp(DBM_VERSION, "GDBM"))
{
return dba_info_gdbm(hnd, info);

View File

@ -2181,7 +2181,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
ZCSG(hits)++; /* TBFixed: may lose one hit */
persistent_script->dynamic_members.hits++; /* see above */
#else
#if ZEND_ENABLE_ZVAL_LONG64
#ifdef ZEND_ENABLE_ZVAL_LONG64
InterlockedIncrement64(&ZCSG(hits));
InterlockedIncrement64(&persistent_script->dynamic_members.hits);
#else

View File

@ -560,7 +560,7 @@ static int _php_mcast_source_op(
#endif
}
#if RFC3678_API
#ifdef RFC3678_API
static int _php_source_op_to_rfc3678_op(enum source_op sop)
{
switch (sop) {

View File

@ -41,7 +41,7 @@ extern zend_module_entry sockets_module_entry;
#ifdef PHP_WIN32
#include <Winsock2.h>
#else
#if HAVE_SYS_SOCKET_H
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#endif

View File

@ -122,7 +122,7 @@ typedef struct _user_tick_function_entry {
bool calling;
} user_tick_function_entry;
#if HAVE_PUTENV
#ifdef HAVE_PUTENV
typedef struct {
char *putenv_string;
char *previous_value;

View File

@ -48,7 +48,7 @@
# ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
# endif
# if HAVE_SYS_SELECT_H
# ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
# endif
# include <sys/socket.h>

View File

@ -232,7 +232,7 @@ static void _php_free_envp(php_process_env env)
}
/* }}} */
#if HAVE_SYS_WAIT_H
#ifdef HAVE_SYS_WAIT_H
static pid_t waitpid_cached(php_process_handle *proc, int *wait_status, int options)
{
if (proc->has_cached_exit_wait_status) {
@ -544,7 +544,7 @@ static bool is_special_character_present(const zend_string *arg)
return false;
}
/* See https://docs.microsoft.com/en-us/cpp/cpp/parsing-cpp-command-line-arguments and
/* See https://docs.microsoft.com/en-us/cpp/cpp/parsing-cpp-command-line-arguments and
* https://learn.microsoft.com/en-us/archive/blogs/twistylittlepassagesallalike/everyone-quotes-command-line-arguments-the-wrong-way */
static void append_win_escaped_arg(smart_str *str, zend_string *arg, bool is_cmd_argument)
{
@ -1352,7 +1352,7 @@ PHP_FUNCTION(proc_open)
php_error_docref(NULL, E_WARNING, "posix_spawn() failed: %s", strerror(r));
goto exit_fail;
}
#elif HAVE_FORK
#elif defined(HAVE_FORK)
/* the Unix way */
child = fork();
@ -1414,7 +1414,7 @@ PHP_FUNCTION(proc_open)
proc->childHandle = childHandle;
#endif
proc->env = env;
#if HAVE_SYS_WAIT_H
#ifdef HAVE_SYS_WAIT_H
proc->has_cached_exit_wait_status = false;
#endif

View File

@ -43,7 +43,7 @@ typedef struct _php_process_handle {
zend_resource **pipes;
zend_string *command;
php_process_env env;
#if HAVE_SYS_WAIT_H
#ifdef HAVE_SYS_WAIT_H
/* We can only request the status once before it becomes unavailable.
* Cache the result so we can request it multiple times. */
int cached_exit_wait_status_value;

View File

@ -595,23 +595,23 @@ static char *sapi_fcgi_getenv(const char *name, size_t name_len)
static char *_sapi_cgi_putenv(char *name, size_t name_len, char *value)
{
#if !HAVE_SETENV || !HAVE_UNSETENV
#if !defined(HAVE_SETENV) || !defined(HAVE_UNSETENV)
size_t len;
char *buf;
#endif
#if HAVE_SETENV
#ifdef HAVE_SETENV
if (value) {
setenv(name, value, 1);
}
#endif
#if HAVE_UNSETENV
#ifdef HAVE_UNSETENV
if (!value) {
unsetenv(name);
}
#endif
#if !HAVE_SETENV || !HAVE_UNSETENV
#if !defined(HAVE_SETENV) || !defined(HAVE_UNSETENV)
/* if cgi, or fastcgi and not found in fcgi env
check the regular environment
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)
return getenv(name);
}
#endif
#if !HAVE_SETENV
#if !defined(HAVE_SETENV)
if (value) {
len = slprintf(buf, len - 1, "%s=%s", name, value);
putenv(buf);
}
#endif
#if !HAVE_UNSETENV
#if !defined(HAVE_UNSETENV)
if (!value) {
len = slprintf(buf, len - 1, "%s=", name);
putenv(buf);

View File

@ -110,7 +110,7 @@
#define OUTPUT_IS_TTY 1
#define OUTPUT_NOT_TTY 0
#if HAVE_FORK
#ifdef HAVE_FORK
# include <sys/wait.h>
static pid_t php_cli_server_master;
static pid_t *php_cli_server_workers;
@ -2362,7 +2362,7 @@ static void php_cli_server_dtor(php_cli_server *server) /* {{{ */
if (server->router) {
pefree(server->router, 1);
}
#if HAVE_FORK
#ifdef HAVE_FORK
if (php_cli_server_workers_max > 1 &&
php_cli_server_workers &&
getpid() == php_cli_server_master) {
@ -2484,7 +2484,7 @@ static void php_cli_server_startup_workers(void) {
return;
}
#if HAVE_FORK
#ifdef HAVE_FORK
php_cli_server_workers_max = ZEND_ATOL(workers);
if (php_cli_server_workers_max > 1) {
zend_long php_cli_server_worker;

View File

@ -418,7 +418,7 @@ int LSAPI_Postfork_Parent(LSAPI_Request * pReq);
#define LSAPI_LOG_PID (0x10000)
void LSAPI_Log(int flag, const char * fmt, ...)
#if __GNUC__
#ifdef __GNUC__
__attribute__((format(printf, 2, 3)))
#endif
;

View File

@ -100,7 +100,7 @@ old_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-I$phpincludedir"
AC_EGREP_CPP(php_zts_is_enabled,[
#include <main/php_config.h>
#if ZTS
#ifdef ZTS
php_zts_is_enabled
#endif
],[

View File

@ -97,7 +97,7 @@ PHP_FUNCTION(sapi_windows_set_ctrl_handler)
RETURN_THROWS();
}
#if ZTS
#ifdef ZTS
if (!tsrm_is_main_thread()) {
zend_throw_error(NULL, "CTRL events can only be received on the main thread");
RETURN_THROWS();