]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Use STDERR_FILENO/STDOUT_FILENO constants
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 24 May 2020 08:27:36 +0000 (10:27 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 24 May 2020 18:49:09 +0000 (20:49 +0200)
src/ccache.cpp
src/execute.cpp

index cae3f35f4a8f266d9dca308bc1923250fabb7882..846e23b76c9f6523c4a27fcaae8c6df53b0e58fc 100644 (file)
@@ -725,7 +725,7 @@ send_cached_stderr(const char* path_stderr)
 {
   int fd_stderr = open(path_stderr, O_RDONLY | O_BINARY);
   if (fd_stderr != -1) {
-    copy_fd(fd_stderr, 2);
+    copy_fd(fd_stderr, STDERR_FILENO);
     close(fd_stderr);
   }
 }
@@ -913,7 +913,7 @@ to_cache(Context& ctx,
     int fd = open(tmp_stderr.c_str(), O_RDONLY | O_BINARY);
     if (fd != -1) {
       // We can output stderr immediately instead of rerunning the compiler.
-      copy_fd(fd, 2);
+      copy_fd(fd, STDERR_FILENO);
       close(fd);
     }
 
@@ -1892,7 +1892,8 @@ initialize(Context& ctx, int argc, const char* const* argv)
 static void
 set_up_uncached_err()
 {
-  int uncached_fd = dup(2); // The file descriptor is intentionally leaked.
+  int uncached_fd =
+    dup(STDERR_FILENO); // The file descriptor is intentionally leaked.
   if (uncached_fd == -1) {
     cc_log("dup(2) failed: %s", strerror(errno));
     failed(STATS_ERROR);
index b9ad4d823fee7b0095fe1fbe9a6ed82e25c16857..ec1fd2894e02cd2530e08e66189da19b3e0d1519 100644 (file)
@@ -259,9 +259,9 @@ execute(const char* const* argv, int fd_out, int fd_err, pid_t* pid)
 
   if (*pid == 0) {
     // Child.
-    dup2(fd_out, 1);
+    dup2(fd_out, STDOUT_FILENO);
     close(fd_out);
-    dup2(fd_err, 2);
+    dup2(fd_err, STDERR_FILENO);
     close(fd_err);
     x_exit(execv(argv[0], const_cast<char* const*>(argv)));
   }