Don't check HAVE_UNISTD_H
authorTom Tromey <tom@tromey.com>
Wed, 26 Sep 2018 11:28:07 +0000 (05:28 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 1 Oct 2018 08:58:23 +0000 (02:58 -0600)
I noticed some spots that were checking HAVE_UNISTD_H.  There is no
need to do this, as <unistd.h> is unconditionally included in many
places in gdb.  This sort of cleanup was done once before, in 2013:

    2013-07-01  Pedro Alves  <palves@redhat.com>

    * defs.h: Don't check HAVE_UNISTD_H before including <unistd.h>.
    (STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO): Delete.
    * tracepoint.c: Don't check HAVE_UNISTD_H before including
    <unistd.h>.

HAVE_UNISTD_H seems to come from gnulib, so there are still mentions
of it in the source.

gdb/ChangeLog
2018-10-01  Tom Tromey  <tom@tromey.com>

* unittests/scoped_mmap-selftests.c: Don't check HAVE_UNISTD_H.
* unittests/scoped_fd-selftests.c: Don't check HAVE_UNISTD_H.
* common/scoped_fd.h: Don't check HAVE_UNISTD_H.

gdb/ChangeLog
gdb/common/scoped_fd.h
gdb/unittests/scoped_fd-selftests.c
gdb/unittests/scoped_mmap-selftests.c

index 3cc68f5be474d5e6cf2605aa305d9a2dd49e2067..b1724a028a93d57e68ad9f4d5bbe0746d2bfb9fa 100644 (file)
@@ -1,3 +1,9 @@
+2018-10-01  Tom Tromey  <tom@tromey.com>
+
+       * unittests/scoped_mmap-selftests.c: Don't check HAVE_UNISTD_H.
+       * unittests/scoped_fd-selftests.c: Don't check HAVE_UNISTD_H.
+       * common/scoped_fd.h: Don't check HAVE_UNISTD_H.
+
 2018-10-01  Tom Tromey  <tom@tromey.com>
 
        * README: Minor change.
index a6a8ab9a3853502e41efab59695b8f16f1a56e2b..c2125bd1afe3de550ffbcf89374640b7f813f4f3 100644 (file)
 #ifndef SCOPED_FD_H
 #define SCOPED_FD_H
 
-#include "config.h"
-
-#ifdef HAVE_UNISTD_H
-
 #include <unistd.h>
 
 /* A smart-pointer-like class to automatically close a file descriptor.  */
@@ -56,5 +52,4 @@ private:
   int m_fd;
 };
 
-#endif /* HAVE_UNISTD_H */
 #endif /* SCOPED_FD_H */
index 4d7454134ac526d67d2f08323a716ed6ee4597d5..d5c0d30abbe87a495d9495fefaa10b7964d3677b 100644 (file)
@@ -21,9 +21,6 @@
 
 #include "common/scoped_fd.h"
 #include "config.h"
-
-#ifdef HAVE_UNISTD_H
-
 #include "selftest.h"
 
 namespace selftests {
@@ -78,13 +75,9 @@ run_tests ()
 } /* namespace scoped_fd */
 } /* namespace selftests */
 
-#endif /* HAVE_UNISTD_H */
-
 void
 _initialize_scoped_fd_selftests ()
 {
-#ifdef HAVE_UNISTD_H
   selftests::register_test ("scoped_fd",
                            selftests::scoped_fd::run_tests);
-#endif
 }
index e9d4afdffc5b91330cd2f92d3f906b4d31f4d101..b181e02f50f935d3efa30adf4189b4411cc22b10 100644 (file)
@@ -22,7 +22,7 @@
 #include "common/scoped_mmap.h"
 #include "config.h"
 
-#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_UNISTD_H)
+#if defined(HAVE_SYS_MMAN_H)
 
 #include "selftest.h"
 #include "common/gdb_unlinker.h"
@@ -132,12 +132,12 @@ run_tests ()
 } /* namespace mmap_file */
 } /* namespace selftests */
 
-#endif /* !defined(HAVE_SYS_MMAN_H) || !defined(HAVE_UNISTD_H) */
+#endif /* !defined(HAVE_SYS_MMAN_H) */
 
 void
 _initialize_scoped_mmap_selftests ()
 {
-#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_UNISTD_H)
+#if defined(HAVE_SYS_MMAN_H)
   selftests::register_test ("scoped_mmap",
                            selftests::scoped_mmap::run_tests);
   selftests::register_test ("mmap_file",