]> granicus.if.org Git - php/commitdiff
Add php_ignore_value() macro to suppress unused return value warnings
authorRasmus Lerdorf <rasmus@php.net>
Mon, 16 May 2011 16:58:02 +0000 (16:58 +0000)
committerRasmus Lerdorf <rasmus@php.net>
Mon, 16 May 2011 16:58:02 +0000 (16:58 +0000)
from gcc. There are times when we really don't care about the return
value and this will cleanly tell gcc.

ext/session/mod_files.c
ext/soap/php_sdl.c
main/main.c
main/php.h

index 0627414b7a9b38e4c005f35352365fe3ae492214..c3c35093c3558d792aec647345780593628b18d9 100644 (file)
@@ -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)
index 580990ba51005da74e41b516d39047d4297c0be2..f1c4b7109e6691d224e9e959bc4664d56da9722a 100644 (file)
@@ -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);
index b8f89badad726a7ac03c62bcba68d33d59586913..9a068dfbaef39734e2d9dd5507d4c15409b95af4 100644 (file)
@@ -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);
index d338462eaef1f523f29a5d833d02b132ee45c259..278d6390fbb3462ceffcf42700a2458350372795 100644 (file)
@@ -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)