rasmus                                   Mon, 16 May 2011 16:58:02 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=311099

Log:
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.

Changed paths:
    U   php/php-src/branches/PHP_5_4/ext/session/mod_files.c
    U   php/php-src/branches/PHP_5_4/ext/soap/php_sdl.c
    U   php/php-src/branches/PHP_5_4/main/main.c
    U   php/php-src/branches/PHP_5_4/main/php.h
    U   php/php-src/trunk/ext/session/mod_files.c
    U   php/php-src/trunk/ext/soap/php_sdl.c
    U   php/php-src/trunk/main/main.c
    U   php/php-src/trunk/main/php.h

Modified: php/php-src/branches/PHP_5_4/ext/session/mod_files.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/session/mod_files.c        2011-05-16 
16:06:08 UTC (rev 311098)
+++ php/php-src/branches/PHP_5_4/ext/session/mod_files.c        2011-05-16 
16:58:02 UTC (rev 311099)
@@ -390,7 +390,7 @@
        /* 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)

Modified: php/php-src/branches/PHP_5_4/ext/soap/php_sdl.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/soap/php_sdl.c     2011-05-16 16:06:08 UTC 
(rev 311098)
+++ php/php-src/branches/PHP_5_4/ext/soap/php_sdl.c     2011-05-16 16:58:02 UTC 
(rev 311099)
@@ -2339,7 +2339,7 @@
                }
        }

-       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);

Modified: php/php-src/branches/PHP_5_4/main/main.c
===================================================================
--- php/php-src/branches/PHP_5_4/main/main.c    2011-05-16 16:06:08 UTC (rev 
311098)
+++ php/php-src/branches/PHP_5_4/main/main.c    2011-05-16 16:58:02 UTC (rev 
311099)
@@ -561,7 +561,7 @@
 #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 @@
                        /* 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 @@
        }
 #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 @@
                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);

Modified: php/php-src/branches/PHP_5_4/main/php.h
===================================================================
--- php/php-src/branches/PHP_5_4/main/php.h     2011-05-16 16:06:08 UTC (rev 
311098)
+++ php/php-src/branches/PHP_5_4/main/php.h     2011-05-16 16:58:02 UTC (rev 
311099)
@@ -259,6 +259,11 @@
 # 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)

Modified: php/php-src/trunk/ext/session/mod_files.c
===================================================================
--- php/php-src/trunk/ext/session/mod_files.c   2011-05-16 16:06:08 UTC (rev 
311098)
+++ php/php-src/trunk/ext/session/mod_files.c   2011-05-16 16:58:02 UTC (rev 
311099)
@@ -390,7 +390,7 @@
        /* 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)

Modified: php/php-src/trunk/ext/soap/php_sdl.c
===================================================================
--- php/php-src/trunk/ext/soap/php_sdl.c        2011-05-16 16:06:08 UTC (rev 
311098)
+++ php/php-src/trunk/ext/soap/php_sdl.c        2011-05-16 16:58:02 UTC (rev 
311099)
@@ -2339,7 +2339,7 @@
                }
        }

-       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);

Modified: php/php-src/trunk/main/main.c
===================================================================
--- php/php-src/trunk/main/main.c       2011-05-16 16:06:08 UTC (rev 311098)
+++ php/php-src/trunk/main/main.c       2011-05-16 16:58:02 UTC (rev 311099)
@@ -561,7 +561,7 @@
 #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 @@
                        /* 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 @@
        }
 #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 @@
                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);

Modified: php/php-src/trunk/main/php.h
===================================================================
--- php/php-src/trunk/main/php.h        2011-05-16 16:06:08 UTC (rev 311098)
+++ php/php-src/trunk/main/php.h        2011-05-16 16:58:02 UTC (rev 311099)
@@ -259,6 +259,11 @@
 # 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)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to