Compilation errors on Ubuntu 8.10 Intrepid Ibex

Igor Sysoev is at rambler-co.ru
Tue Nov 11 09:35:36 MSK 2008


On Mon, Nov 10, 2008 at 02:27:43PM -0800, Eric Benson wrote:

> Whether it is gcc's bug because cast to void does not suppress the compiler warning, or it is glibc's bug because it declares write() with attribute warn_unused_result, you are unlikely to see a change from either in the near future. The best course is to take it as an opportunity to do some paranoid error checking in these cases. In most cases, there is some better action to be taken when write() fails. In the worst case, such as trying to write a log entry to a full file system, it is better to exit() with non-zero status than to silently continue running. This is why the attribute was added to the declaration of write(). Most projects do not use -Werror, so they only see added compiler output instead of termination of the build process. I agree that it seems like an awfully big change that might adversely affect many mature software projects. However, there is virtually no case when it is correct to ignore an exceptional condition in write().

I believe, that many prefer that server continues to serve site even its log
filesystem is full. So there is no way how to handle write() error while
logging another error except to ignore it.

Here is the new preliminary patch to test work-around.


-- 
Igor Sysoev
http://sysoev.ru/en/
-------------- next part --------------
Index: src/os/unix/ngx_files.h
===================================================================
--- src/os/unix/ngx_files.h	(revision 1618)
+++ src/os/unix/ngx_files.h	(working copy)
@@ -99,7 +99,12 @@
 #define ngx_read_fd              read
 #define ngx_read_fd_n            "read()"
 
-#define ngx_write_fd             write
+static ngx_inline ssize_t
+ngx_write_fd(ngx_fd_t fd, void *buf, size_t n)
+{
+    return write(fd, buf, n);
+}
+
 #define ngx_write_fd_n           "write()"
 
 #define ngx_linefeed(p)          *p++ = LF;
Index: src/core/ngx_conf_file.c
===================================================================
--- src/core/ngx_conf_file.c	(revision 1618)
+++ src/core/ngx_conf_file.c	(working copy)
@@ -936,7 +936,8 @@
             continue;
         }
 
-        ngx_write_fd(file[i].fd, file[i].buffer, file[i].pos - file[i].buffer);
+        (void) ngx_write_fd(file[i].fd, file[i].buffer,
+                            file[i].pos - file[i].buffer);
     }
 }
 
Index: src/core/nginx.c
===================================================================
--- src/core/nginx.c	(revision 1618)
+++ src/core/nginx.c	(working copy)
@@ -240,22 +240,24 @@
     }
 
     if (ngx_show_version) {
-        ngx_write_fd(ngx_stderr_fileno, "nginx version: " NGINX_VER CRLF,
-                     sizeof("nginx version: " NGINX_VER CRLF) - 1);
+        (void) ngx_write_fd(ngx_stderr_fileno,
+                            "nginx version: " NGINX_VER CRLF,
+                            sizeof("nginx version: " NGINX_VER CRLF) - 1);
 
         if (ngx_show_configure) {
 #ifdef NGX_COMPILER
-            ngx_write_fd(ngx_stderr_fileno, "built by " NGX_COMPILER CRLF,
-                         sizeof("built by " NGX_COMPILER CRLF) - 1);
+            (void) ngx_write_fd(ngx_stderr_fileno,
+                                "built by " NGX_COMPILER CRLF,
+                                sizeof("built by " NGX_COMPILER CRLF) - 1);
 #endif
 
 #ifndef __WATCOMC__
 
             /* OpenWatcomC could not build the long NGX_CONFIGURE string */
 
-            ngx_write_fd(ngx_stderr_fileno,
-                        "configure arguments: " NGX_CONFIGURE CRLF,
-                        sizeof("configure arguments :" NGX_CONFIGURE CRLF) - 1);
+            (void) ngx_write_fd(ngx_stderr_fileno,
+                       "configure arguments: " NGX_CONFIGURE CRLF,
+                       sizeof("configure arguments :" NGX_CONFIGURE CRLF) - 1);
 #endif
         }
 
Index: src/core/ngx_log.c
===================================================================
--- src/core/ngx_log.c	(revision 1618)
+++ src/core/ngx_log.c	(working copy)
@@ -158,7 +158,7 @@
 
     ngx_linefeed(p);
 
-    ngx_write_fd(log->file->fd, errstr, p - errstr);
+    (void) ngx_write_fd(log->file->fd, errstr, p - errstr);
 }
 
 
Index: src/core/ngx_cycle.c
===================================================================
--- src/core/ngx_cycle.c	(revision 1618)
+++ src/core/ngx_cycle.c	(working copy)
@@ -1020,8 +1020,8 @@
         }
 
         if (file[i].buffer && file[i].pos - file[i].buffer != 0) {
-            ngx_write_fd(file[i].fd, file[i].buffer,
-                         file[i].pos - file[i].buffer);
+            (void) ngx_write_fd(file[i].fd, file[i].buffer,
+                                file[i].pos - file[i].buffer);
             file[i].pos = file[i].buffer;
         }
 


More information about the nginx mailing list