From: Rasmus Lerdorf Date: Mon, 16 May 2011 16:58:02 +0000 (+0000) Subject: Add php_ignore_value() macro to suppress unused return value warnings X-Git-Tag: php-5.5.0alpha1~2092 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=22b689a3f9c0babc1b6f29bdfd4722cf74d2ff6e;p=php 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. --- diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 0627414b7a..c3c35093c3 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -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) diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c index 580990ba51..f1c4b7109e 100644 --- a/ext/soap/php_sdl.c +++ b/ext/soap/php_sdl.c @@ -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); diff --git a/main/main.c b/main/main.c index b8f89badad..9a068dfbae 100644 --- a/main/main.c +++ b/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); diff --git a/main/php.h b/main/php.h index d338462eae..278d6390fb 100644 --- a/main/php.h +++ b/main/php.h @@ -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)