ericmckean / seccompsandbox

Automatically exported from code.google.com/p/seccompsandbox
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

The return value of NOINTR_SYS is ignored #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
clang complains "error: expression result unused [-Wunused-value]" in a couple 
places while building the seccomp sandbox.

I've listed the places below. Instead of silencing the compiler, you probably 
want to log an error. I don't know how logging works in the seccomp sandbox.

Index: mutex.h
===================================================================
--- mutex.h (revision 153)
+++ mutex.h (working copy)
@@ -124,7 +124,7 @@
         #else
         #error Unsupported target platform
         #endif
-        NOINTR_SYS(sys.futex(mutex, FUTEX_WAKE, 1, 0));
+        (void)NOINTR_SYS(sys.futex(mutex, FUTEX_WAKE, 1, 0));
         return rc;
       }

Index: sandbox.cc
===================================================================
--- sandbox.cc  (revision 153)
+++ sandbox.cc  (working copy)
@@ -244,8 +244,8 @@
         status_ = STATUS_AVAILABLE;
       }
       int rc;
-      NOINTR_SYS(sys.waitpid(pid, &rc, 0));
-      NOINTR_SYS(sys.close(fds[0]));
+      (void)NOINTR_SYS(sys.waitpid(pid, &rc, 0));
+      (void)NOINTR_SYS(sys.close(fds[0]));
       return status_ != STATUS_UNSUPPORTED;
   }
 }
@@ -349,7 +349,7 @@
   // Take a snapshot of the current memory mappings. These mappings will be
   // off-limits to all future mmap(), munmap(), mremap(), and mprotect() calls.
   snapshotMemoryMappings(processFdPub_, proc_self_maps_);
-  NOINTR_SYS(sys.close(proc_self_maps_));
+  (void)NOINTR_SYS(sys.close(proc_self_maps_));
   proc_self_maps_ = -1;

   // Creating the trusted thread enables sandboxing
Index: trusted_process.cc
===================================================================
--- trusted_process.cc  (revision 153)
+++ trusted_process.cc  (working copy)
@@ -118,8 +118,8 @@
       nextThread = currentThread->mem->newSecureMem;
       goto newThreadCreated;
     } else if (header.sysnum == __NR_exit) {
-      NOINTR_SYS(sys.close(iter->second.fdPub));
-      NOINTR_SYS(sys.close(iter->second.fd));
+      (void)NOINTR_SYS(sys.close(iter->second.fdPub));
+      (void)NOINTR_SYS(sys.close(iter->second.fd));
       SecureMem::Args* secureMem = currentThread->mem;
       threads.erase(iter);
       secureMemPool_.push_back(secureMem);

Original issue reported on code.google.com by thakis@google.com on 26 Jan 2011 at 4:05

GoogleCodeExporter commented 9 years ago
Fixed in http://codereview.chromium.org/7134059/

Original comment by markus@chromium.org on 9 Jun 2011 at 10:35