workaround warning messages regarding 'warn_unused_return_value' when
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Tue, 22 Mar 2005 14:59:46 +0000 (14:59 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Tue, 22 Mar 2005 14:59:46 +0000 (14:59 +0000)
using _FORTIFY_SOURCE.

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1954 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/lib/getvservervdir.c
util-vserver/lib_internal/coreassert.h
util-vserver/lib_internal/matchlist-initmanually.c
util-vserver/lib_internal/matchlist-printid.c
util-vserver/lib_internal/util-exitlikeprocess.c
util-vserver/lib_internal/util-io.h

index 8ac43fd..754ae15 100644 (file)
@@ -47,7 +47,7 @@ getDir(char *dir, bool physical)
     dir = 0;
 
   if (fchdir(fd)==-1) {
-    write(2, "FATAL error: failed to restore directory\n", 41);
+    if (write(2, "FATAL error: failed to restore directory\n", 41)!=41) { /*...*/ }
     abort();
   }
   close(fd);
index 1dc7eeb..c53306d 100644 (file)
 #  error Do not use <coreassert.h> outside of testenvironemnts!
 #endif
 
+#include "lib_internal/util-io.h"
+
 #include <assert.h>
 #include <unistd.h>
 
 #undef assert
 #define ASSERT_STRX(X) #X
 #define ASSERT_STR(X)  ASSERT_STRX(X)
-#define ASSERT_WRITE(X)        write(2, (X), sizeof(X)-1)
+#define ASSERT_WRITE(X)        Vwrite(2, (X), sizeof(X)-1)
 #define assert(X)                                      \
   (!(X)) ?                                             \
   ASSERT_WRITE(__FILE__ ":" ASSERT_STR(__LINE__)       \
index 8f29abb..8fffe73 100644 (file)
@@ -170,7 +170,7 @@ MatchList_initManually(struct MatchList *list,
   
   if (Global_getVerbosity()>=1) {
     WRITE_MSG(1, "Initializing exclude-list for ");
-    (void)write(1, vdir, len);
+    Vwrite(1, vdir, len);
     if (vserver!=0) {
       WRITE_MSG(1, " (");
       WRITE_STR(1, vserver->name);
index 36b0742..7402562 100644 (file)
@@ -28,11 +28,11 @@ MatchList_printId(struct MatchList const *l, int fd)
 {
   if (l->id.l>0) {
     WRITE_MSG(fd, "'");
-    (void)write(fd, l->id.d, l->id.l);
+    Vwrite(fd, l->id.d, l->id.l);
     WRITE_MSG(1, "'");
   }
   else if (l->root.l>0) {
-    write(fd, l->root.d, l->root.l);
+    Vwrite(fd, l->root.d, l->root.l);
   }
   else
     WRITE_MSG(fd, "???");
index 4a94eb1..5c45020 100644 (file)
@@ -56,10 +56,10 @@ exitLikeProcess(int pid, char const *cmd, int ret)
       WRITE_MSG(2, "command '");
       WRITE_STR(2, cmd);
       WRITE_MSG(2, "' (pid ");
-      write    (2, buf, l);
+      Vwrite   (2, buf, l);
       WRITE_MSG(2, ") exited with signal ");
       l = utilvserver_fmt_uint(buf, WTERMSIG(status));      
-      write    (2, buf, l);
+      Vwrite   (2, buf, l);
       WRITE_MSG(2, "; following it...\n");
     }
 
@@ -74,14 +74,14 @@ exitLikeProcess(int pid, char const *cmd, int ret)
     size_t             l = utilvserver_fmt_uint(buf, WTERMSIG(status));
 
     WRITE_MSG(2, "Unexpected status ");
-    write    (2, buf, l);
+    Vwrite   (2, buf, l);
     WRITE_MSG(2, " from '");
     if (cmd) {
       WRITE_STR(2, cmd);
       WRITE_MSG(2, " (pid ");
     }
     l = utilvserver_fmt_uint(buf, pid);
-    write    (2, buf, l);
+    Vwrite   (2, buf, l);
     if (cmd) WRITE_MSG(2, ")\n");
     else     WRITE_MSG(2, "\n");
 
index d4519e7..4f364b8 100644 (file)
 #include <string.h>
 
 inline static void UNUSED
+Vwrite(int fd, char const *buf, size_t len)
+{
+  if (write(fd,buf,len)==-1) { /**/ }
+}
+
+inline static void UNUSED
 writeStr(int fd, char const *cmd)
 {
-  (void)write(fd, cmd, strlen(cmd));
+  Vwrite(fd, cmd, strlen(cmd));
 }
 
-#define WRITE_MSG(FD,X)                (void)(write(FD,X,sizeof(X)-1))
+#define WRITE_MSG(FD,X)                Vwrite(FD,X,sizeof(X)-1)
 #define WRITE_STR(FD,X)                writeStr(FD,X)