bug 1400839 use -1 instead of 0 to indicate absent glxtest_pipe fd r=karlt draft
authorsebastian@ifyouwantblood.de
Tue, 19 Sep 2017 11:47:12 +1200
changeset 666600 c31aa7ce731b
parent 666598 30a386ff1192
child 732158 d7ae806d583b
push id80462
push userktomlinson@mozilla.com
push dateMon, 18 Sep 2017 23:50:45 +0000
reviewerskarlt
bugs1400839
milestone57.0a1
bug 1400839 use -1 instead of 0 to indicate absent glxtest_pipe fd r=karlt Englightenment closes fd 0 on child processes and so pipe() can return a zero fd. MozReview-Commit-ID: 5d9xQXgwgfv
widget/GfxInfoX11.cpp
--- a/widget/GfxInfoX11.cpp
+++ b/widget/GfxInfoX11.cpp
@@ -23,17 +23,17 @@
 namespace mozilla {
 namespace widget {
 
 #ifdef DEBUG
 NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug)
 #endif
 
 // these global variables will be set when firing the glxtest process
-int glxtest_pipe = 0;
+int glxtest_pipe = -1;
 pid_t glxtest_pid = 0;
 
 nsresult
 GfxInfo::Init()
 {
     mGLMajorVersion = 0;
     mMajorVersion = 0;
     mMinorVersion = 0;
@@ -50,27 +50,27 @@ GfxInfo::Init()
 }
 
 void
 GfxInfo::GetData()
 {
     // to understand this function, see bug 639842. We retrieve the OpenGL driver information in a
     // separate process to protect against bad drivers.
 
-    // if glxtest_pipe == 0, that means that we already read the information
-    if (!glxtest_pipe)
+    // if glxtest_pipe == -1, that means that we already read the information
+    if (glxtest_pipe == -1)
         return;
 
     enum { buf_size = 1024 };
     char buf[buf_size];
     ssize_t bytesread = read(glxtest_pipe,
                              &buf,
                              buf_size-1); // -1 because we'll append a zero
     close(glxtest_pipe);
-    glxtest_pipe = 0;
+    glxtest_pipe = -1;
 
     // bytesread < 0 would mean that the above read() call failed.
     // This should never happen. If it did, the outcome would be to blacklist anyway.
     if (bytesread < 0)
         bytesread = 0;
 
     // let buf be a zero-terminated string
     buf[bytesread] = 0;