mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Add php_ignore_value() macro to suppress unused return value warnings
from gcc. There are times when we really don't care about the return value and this will cleanly tell gcc.
This commit is contained in:
parent
27dd44db95
commit
75ec1fedc7
4 changed files with 12 additions and 7 deletions
|
@ -390,7 +390,7 @@ PS_WRITE_FUNC(files)
|
|||
/* Truncate file if the amount of new data is smaller than the existing data set. */
|
||||
|
||||
if (vallen < (int)data->st_size) {
|
||||
ftruncate(data->fd, 0);
|
||||
php_ignore_value(ftruncate(data->fd, 0));
|
||||
}
|
||||
|
||||
#if defined(HAVE_PWRITE)
|
||||
|
|
|
@ -2339,7 +2339,7 @@ static void add_sdl_to_cache(const char *fn, const char *uri, time_t t, sdlPtr s
|
|||
}
|
||||
}
|
||||
|
||||
write(f, buf.c, buf.len);
|
||||
php_ignore_value(write(f, buf.c, buf.len));
|
||||
close(f);
|
||||
smart_str_free(&buf);
|
||||
zend_hash_destroy(&tmp_functions);
|
||||
|
|
10
main/main.c
10
main/main.c
|
@ -561,7 +561,7 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC)
|
|||
#ifdef PHP_WIN32
|
||||
php_flock(fd, 2);
|
||||
#endif
|
||||
write(fd, tmp, len);
|
||||
php_ignore_value(write(fd, tmp, len));
|
||||
efree(tmp);
|
||||
efree(error_time_str);
|
||||
close(fd);
|
||||
|
@ -2301,7 +2301,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
|
|||
/* this looks nasty to me */
|
||||
old_cwd_fd = open(".", 0);
|
||||
#else
|
||||
VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1);
|
||||
php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
|
||||
#endif
|
||||
VCWD_CHDIR_FILE(primary_file->filename);
|
||||
}
|
||||
|
@ -2360,7 +2360,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
|
|||
}
|
||||
#else
|
||||
if (old_cwd[0] != '\0') {
|
||||
VCWD_CHDIR(old_cwd);
|
||||
php_ignore_value(VCWD_CHDIR(old_cwd));
|
||||
}
|
||||
free_alloca(old_cwd, use_heap);
|
||||
#endif
|
||||
|
@ -2390,14 +2390,14 @@ PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval **ret
|
|||
PG(during_request_startup) = 0;
|
||||
|
||||
if (primary_file->filename && !(SG(options) & SAPI_OPTION_NO_CHDIR)) {
|
||||
VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1);
|
||||
php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
|
||||
VCWD_CHDIR_FILE(primary_file->filename);
|
||||
}
|
||||
zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, ret, 1, primary_file);
|
||||
} zend_end_try();
|
||||
|
||||
if (old_cwd[0] != '\0') {
|
||||
VCWD_CHDIR(old_cwd);
|
||||
php_ignore_value(VCWD_CHDIR(old_cwd));
|
||||
}
|
||||
|
||||
free_alloca(old_cwd, use_heap);
|
||||
|
|
|
@ -259,6 +259,11 @@ END_EXTERN_C()
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
# define php_ignore_value(x) (({ __typeof__ (x) __x = (x); (void) __x; }))
|
||||
#else
|
||||
# define php_ignore_value(x) ((void) (x))
|
||||
#endif
|
||||
|
||||
/* global variables */
|
||||
#if !defined(PHP_WIN32)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue