Failure to use return value of system calls. draft
authorISHIKAWA, Chiaki <ishikawa@yk.rim.or.jp>
Sat, 09 Nov 2019 11:00:08 +0900
changeset 81070 65df23be2f60eb1aac1359891d7a690b060532e9
parent 81069 c0526a9cca00673125f3ba7bea4966aa3b423232
child 81071 5816efa090d438ceb394efc938be18ede0c93963
push id9744
push userishikawa@yk.rim.or.jp
push dateSat, 09 Nov 2019 02:01:06 +0000
treeherdertry-comm-central@56c83244ac0e [default view] [failures only]
Failure to use return value of system calls.
mozilla-M-C-008-failure-to-use-return-value.patch
new file mode 100644
--- /dev/null
+++ b/mozilla-M-C-008-failure-to-use-return-value.patch
@@ -0,0 +1,123 @@
+# HG changeset patch
+# User ISHIKAWA, Chiaki <ishikawa@yk.rim.or.jp>
+# Parent  3ca2ff29ec8002d54de74ebe183d1449b5a28438
+Failure to use return value of system calls.
+
+diff --git a/js/src/ctypes/libffi/src/closures.c b/js/src/ctypes/libffi/src/closures.c
+--- a/js/src/ctypes/libffi/src/closures.c
++++ b/js/src/ctypes/libffi/src/closures.c
+@@ -452,29 +452,36 @@ dlmmap_locked (void *start, size_t lengt
+ 	      flags, execfd, offset);
+   if (ptr == MFAIL)
+     {
+       if (!offset)
+ 	{
+ 	  close (execfd);
+ 	  goto retry_open;
+ 	}
+-      ftruncate (execfd, offset);
++      int err = ftruncate (execfd, offset);
++      // How do we report non-zero err ?
++#define FTRUNCATEFAILED "ftruncate failed\n"
++      if (err < 0) {
++            err = write(2, FTRUNCATEFAILED, strlen(FTRUNCATEFAILED));
++            (void) err;
++      }
+       return MFAIL;
+     }
+   else if (!offset
+ 	   && open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat)
+     open_temp_exec_file_opts_next ();
+ 
+   start = mmap (start, length, prot, flags, execfd, offset);
+ 
+   if (start == MFAIL)
+     {
+       munmap (ptr, length);
+-      ftruncate (execfd, offset);
++      if(ftruncate (execfd, offset) != 0)
++        return MFAIL;
+       return start;
+     }
+ 
+   mmap_exec_offset ((char *)start, length) = (char*)ptr - (char*)start;
+ 
+   execsize += length;
+ 
+   return start;
+diff --git a/media/webrtc/trunk/webrtc/rtc_base/task_queue_libevent.cc b/media/webrtc/trunk/webrtc/rtc_base/task_queue_libevent.cc
+--- a/media/webrtc/trunk/webrtc/rtc_base/task_queue_libevent.cc
++++ b/media/webrtc/trunk/webrtc/rtc_base/task_queue_libevent.cc
+@@ -228,17 +228,22 @@ class TaskQueue::Impl::PostAndReplyTask 
+   ~PostAndReplyTask() override {
+     reply_task_owner_ = nullptr;
+     IgnoreSigPipeSignalOnCurrentThread();
+     // Send a signal to the reply queue that the reply task can run now.
+     // Depending on whether |set_should_run_task()| was called by the
+     // PostAndReplyTask(), the reply task may or may not actually run.
+     // In either case, it will be deleted.
+     char message = kRunReplyTask;
+-    write(reply_pipe_, &message, sizeof(message));
++    int rc = write(reply_pipe_, &message, sizeof(message));
++    if (rc < 0 )  {
++#if DEBUG
++       fprintf(stderr,"{debug} write failed in ~PostAndReplyTask().\n");
++#endif
++    }
+   }
+ 
+  private:
+   bool Run() override {
+     if (!task_->Run())
+       task_.release();
+     reply_task_owner_->set_should_run_task();
+     return true;
+diff --git a/nsprpub/pr/src/md/unix/uxproces.c b/nsprpub/pr/src/md/unix/uxproces.c
+--- a/nsprpub/pr/src/md/unix/uxproces.c
++++ b/nsprpub/pr/src/md/unix/uxproces.c
+@@ -114,17 +114,23 @@ static struct {
+ #ifdef _PR_SHARE_CLONES
+ static int pr_waitpid_daemon_exit;
+ 
+ void
+ _MD_unix_terminate_waitpid_daemon(void)
+ {
+     if (pr_wp.thread) {
+         pr_waitpid_daemon_exit = 1;
+-        write(pr_wp.pipefd[1], "", 1);
++        int err= write(pr_wp.pipefd[1], "", 1);
++        // we need to ignore err since we can't do a thing about it?
++#define WRITE2PIPEFAILED "write to pipe failed.\n"
++        if (err < 0) {
++          err = write(2, WRITE2PIPEFAILED, strlen(WRITE2PIPEFAILED) + 1);
++          (void) err;
++        }
+         PR_JoinThread(pr_wp.thread);
+     }
+ }
+ #endif
+ 
+ static PRStatus _MD_InitProcesses(void);
+ #if !defined(_PR_NATIVE_THREADS)
+ static void pr_InstallSigchldHandler(void);
+@@ -670,17 +676,19 @@ static void pr_SigchldHandler(int sig)
+ 
+     do {
+         rv = write(pr_wp.pipefd[1], "", 1);
+     } while (-1 == rv && EINTR == errno);
+ 
+ #ifdef DEBUG
+     if (-1 == rv && EAGAIN != errno && EWOULDBLOCK != errno) {
+         char *msg = "cannot write to pipe\n";
+-        write(2, msg, strlen(msg) + 1);
++        int err = write(2, msg, strlen(msg) + 1);
++        // we need to ignore err here since we can't do a thing abou this.
++        (void) err;
+         _exit(1);
+     }
+ #endif
+ 
+     errno = errnoCopy;
+ }
+ 
+ static void pr_InstallSigchldHandler()