aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-11-06 19:20:37 -0800
committerGuy Harris <guy@alum.mit.edu>2015-11-07 21:52:23 +0000
commit0162e54075bb7ad967a85736b3c8addd53d86de5 (patch)
tree8a621af4c54f0d11b610b6842c9f53aae849e68a
parent24bfb7e35d619c004e0458f38a1d5ae538a898fb (diff)
Clean up includes of unistd.h, fcntl.h, and sys/stat.h.
Have wsutil/file_util.h include them on UN*X, just as it includes io.h on Windows, so we can have a rule of "if you do file operations, include <wsutil/file_util.h> and use the routines in it". Remove includes of unistd.h, fcntl.h, and sys/stat.h that aren't necessary (whether because of the addition of them to wsutil/file_util.h or because they weren't needed in the first place). Change-Id: Ie241dd74deff284e39a5f690a297dbb6e1dc485f Reviewed-on: https://code.wireshark.org/review/11619 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--capchild/capture_sync.c8
-rw-r--r--capinfos.c4
-rw-r--r--capture_opts.c4
-rw-r--r--capture_stop_conditions.c1
-rw-r--r--captype.c4
-rw-r--r--dumpcap.c12
-rw-r--r--epan/addr_resolv.c4
-rw-r--r--epan/disabled_protos.c4
-rw-r--r--epan/dissectors/packet-lmp.c4
-rw-r--r--epan/dissectors/packet-rsvp.c4
-rw-r--r--epan/prefs.c4
-rw-r--r--file.c8
-rw-r--r--fileset.c12
-rw-r--r--mergecap.c8
-rw-r--r--plugins/mate/mate_util.h4
-rw-r--r--randpkt.c8
-rw-r--r--rawshark.c12
-rw-r--r--reordercap.c4
-rw-r--r--ringbuffer.c8
-rw-r--r--text2pcap.c4
-rw-r--r--tfshark.c12
-rw-r--r--tshark.c12
-rw-r--r--ui/capture.c4
-rw-r--r--ui/cli/tap-follow.c4
-rw-r--r--ui/export_object.c8
-rw-r--r--ui/filters.c4
-rw-r--r--ui/gtk/capture_file_dlg.c4
-rw-r--r--ui/gtk/export_sslkeys.c8
-rw-r--r--ui/gtk/fileset_dlg.c4
-rw-r--r--ui/gtk/firewall_dlg.c8
-rw-r--r--ui/gtk/follow_stream.c3
-rw-r--r--ui/gtk/follow_tcp.c4
-rw-r--r--ui/gtk/iax2_analysis.c8
-rw-r--r--ui/gtk/main.c4
-rw-r--r--ui/gtk/packet_panes.c8
-rw-r--r--ui/gtk/rtp_analysis.c8
-rw-r--r--ui/mcast_stream.c3
-rw-r--r--ui/qt/main_window_slots.cpp8
-rw-r--r--ui/rtp_stream.c4
-rw-r--r--ui/text_import.c4
-rw-r--r--ui/traffic_table_ui.c3
-rw-r--r--wiretap/ber.c4
-rw-r--r--wiretap/file_access.c8
-rw-r--r--wiretap/file_wrappers.c7
-rw-r--r--wiretap/stanag4607.c4
-rw-r--r--wiretap/tnef.c4
-rw-r--r--wiretap/wtap.c4
-rw-r--r--wsutil/file_util.h20
-rw-r--r--wsutil/filesystem.c12
-rw-r--r--wsutil/plugins.c4
-rw-r--r--wsutil/tempfile.c8
-rw-r--r--wsutil/u3.c6
52 files changed, 14 insertions, 313 deletions
diff --git a/capchild/capture_sync.c b/capchild/capture_sync.c
index 0b92c57028..460b790099 100644
--- a/capchild/capture_sync.c
+++ b/capchild/capture_sync.c
@@ -29,14 +29,6 @@
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
#include <signal.h>
#ifdef _WIN32
diff --git a/capinfos.c b/capinfos.c
index 73bdf35f22..49fb8db567 100644
--- a/capinfos.c
+++ b/capinfos.c
@@ -63,10 +63,6 @@
#include <locale.h>
#include <errno.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
diff --git a/capture_opts.c b/capture_opts.c
index 4332ce234a..5c6042167e 100644
--- a/capture_opts.c
+++ b/capture_opts.c
@@ -31,10 +31,6 @@
#include <errno.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <glib.h>
#include "capture_opts.h"
diff --git a/capture_stop_conditions.c b/capture_stop_conditions.c
index 4a1d78119d..4a2ccaed2a 100644
--- a/capture_stop_conditions.c
+++ b/capture_stop_conditions.c
@@ -25,7 +25,6 @@
#include <time.h>
#include <string.h>
#include <stdlib.h>
-#include <sys/stat.h>
#include <stdarg.h>
#include "conditions.h"
#include "capture_stop_conditions.h"
diff --git a/captype.c b/captype.c
index 64793fba72..64f22d449b 100644
--- a/captype.c
+++ b/captype.c
@@ -32,10 +32,6 @@
#include <locale.h>
#include <errno.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
diff --git a/dumpcap.c b/dumpcap.c
index 80aadc5246..74801cc86a 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -39,18 +39,6 @@
#include <netinet/in.h>
#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index 51077984ec..35547da0f4 100644
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -65,10 +65,6 @@
* a separate thread, making it, in effect, asynchronous.
*/
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
diff --git a/epan/disabled_protos.c b/epan/disabled_protos.c
index 71bc1b97cb..30df144538 100644
--- a/epan/disabled_protos.c
+++ b/epan/disabled_protos.c
@@ -26,10 +26,6 @@
#include <string.h>
#include <errno.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <glib.h>
#include <wsutil/filesystem.h>
diff --git a/epan/dissectors/packet-lmp.c b/epan/dissectors/packet-lmp.c
index 5257386d21..d6bf8141c8 100644
--- a/epan/dissectors/packet-lmp.c
+++ b/epan/dissectors/packet-lmp.c
@@ -40,10 +40,6 @@
#include "config.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/prefs.h>
diff --git a/epan/dissectors/packet-rsvp.c b/epan/dissectors/packet-rsvp.c
index 2fb50d5e27..80e37e0142 100644
--- a/epan/dissectors/packet-rsvp.c
+++ b/epan/dissectors/packet-rsvp.c
@@ -94,10 +94,6 @@
#include "config.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <epan/packet.h>
#include <epan/expert.h>
#include <epan/exceptions.h>
diff --git a/epan/prefs.c b/epan/prefs.c
index a5393d125d..fa8c88642f 100644
--- a/epan/prefs.c
+++ b/epan/prefs.c
@@ -26,10 +26,6 @@
#include <string.h>
#include <errno.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <glib.h>
#include <stdio.h>
diff --git a/file.c b/file.c
index dfe73e9c43..16972ffdf7 100644
--- a/file.c
+++ b/file.c
@@ -22,10 +22,6 @@
#include <config.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <time.h>
#include <stdlib.h>
@@ -34,10 +30,6 @@
#include <ctype.h>
#include <errno.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
#include <wsutil/tempfile.h>
#include <wsutil/file_util.h>
#include <wsutil/filesystem.h>
diff --git a/fileset.c b/fileset.c
index 4066718ee1..2d022957a5 100644
--- a/fileset.c
+++ b/fileset.c
@@ -22,18 +22,6 @@
#include <config.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
diff --git a/mergecap.c b/mergecap.c
index 16a2085f0f..146864dc89 100644
--- a/mergecap.c
+++ b/mergecap.c
@@ -30,10 +30,6 @@
#include <errno.h>
#include <glib.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
@@ -60,10 +56,6 @@
#include <wiretap/merge.h>
#include <wiretap/pcap-encap.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
#ifdef _WIN32
#include <wsutil/unicode-utils.h>
#endif /* _WIN32 */
diff --git a/plugins/mate/mate_util.h b/plugins/mate/mate_util.h
index 9387c4437a..85beb06dce 100644
--- a/plugins/mate/mate_util.h
+++ b/plugins/mate/mate_util.h
@@ -26,10 +26,6 @@
#define __AVP_H_
#include "epan/proto.h"
#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
/* #define _AVP_DEBUGGING */
diff --git a/randpkt.c b/randpkt.c
index 7a0ecd9741..269aef45a7 100644
--- a/randpkt.c
+++ b/randpkt.c
@@ -23,10 +23,6 @@
#include <config.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
@@ -35,10 +31,6 @@
#include "wsutil/wsgetopt.h"
#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
#include <time.h>
#include <errno.h>
diff --git a/rawshark.c b/rawshark.c
index 0952a7c5ea..78e3e83448 100644
--- a/rawshark.c
+++ b/rawshark.c
@@ -40,24 +40,12 @@
#include <locale.h>
#include <limits.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#include <errno.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
#ifndef HAVE_GETOPT_LONG
#include "wsutil/wsgetopt.h"
#endif
diff --git a/reordercap.c b/reordercap.c
index 3cc3a60765..9939f26987 100644
--- a/reordercap.c
+++ b/reordercap.c
@@ -28,10 +28,6 @@
#include <string.h>
#include <glib.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
diff --git a/ringbuffer.c b/ringbuffer.c
index 4873c34c48..7f0f67d5e7 100644
--- a/ringbuffer.c
+++ b/ringbuffer.c
@@ -44,14 +44,6 @@
#ifdef HAVE_LIBPCAP
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <stdio.h>
#include <string.h>
#include <time.h>
diff --git a/text2pcap.c b/text2pcap.c
index bd41e2acff..89a93a2cc6 100644
--- a/text2pcap.c
+++ b/text2pcap.c
@@ -118,10 +118,6 @@
#include <time.h>
#include <glib.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
diff --git a/tfshark.c b/tfshark.c
index 79ade49198..47e080073b 100644
--- a/tfshark.c
+++ b/tfshark.c
@@ -29,24 +29,12 @@
#include <locale.h>
#include <limits.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#include <errno.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
#ifdef HAVE_LIBZ
#include <zlib.h> /* to get the libz version number */
#endif
diff --git a/tshark.c b/tshark.c
index 002c811b97..8d3d3052bf 100644
--- a/tshark.c
+++ b/tshark.c
@@ -30,28 +30,16 @@
#include <locale.h>
#include <limits.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#include <errno.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
#ifndef _WIN32
#include <signal.h>
#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
#ifdef HAVE_LIBZ
#include <zlib.h> /* to get the libz version number */
#endif
diff --git a/ui/capture.c b/ui/capture.c
index b0721995e4..0a95cf8be9 100644
--- a/ui/capture.c
+++ b/ui/capture.c
@@ -24,10 +24,6 @@
#ifdef HAVE_LIBPCAP
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/ui/cli/tap-follow.c b/ui/cli/tap-follow.c
index 3d4608a533..a436f502f1 100644
--- a/ui/cli/tap-follow.c
+++ b/ui/cli/tap-follow.c
@@ -27,10 +27,6 @@
#include "config.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <stdio.h>
#include <stdlib.h>
diff --git a/ui/export_object.c b/ui/export_object.c
index 3a90994870..65c478ea9c 100644
--- a/ui/export_object.c
+++ b/ui/export_object.c
@@ -26,14 +26,6 @@
#include <string.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <errno.h>
#include <epan/packet_info.h>
diff --git a/ui/filters.c b/ui/filters.c
index 6ed94c5a89..01014798f4 100644
--- a/ui/filters.c
+++ b/ui/filters.c
@@ -26,10 +26,6 @@
#include <string.h>
#include <errno.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <glib.h>
#include <wsutil/file_util.h>
diff --git a/ui/gtk/capture_file_dlg.c b/ui/gtk/capture_file_dlg.c
index 6d94cf796b..c93d5a6b36 100644
--- a/ui/gtk/capture_file_dlg.c
+++ b/ui/gtk/capture_file_dlg.c
@@ -22,10 +22,6 @@
#include "config.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <string.h>
#include <gtk/gtk.h>
diff --git a/ui/gtk/export_sslkeys.c b/ui/gtk/export_sslkeys.c
index a03fa71455..ca3f17515c 100644
--- a/ui/gtk/export_sslkeys.c
+++ b/ui/gtk/export_sslkeys.c
@@ -26,14 +26,6 @@
#include <string.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <wsutil/file_util.h>
#include <wsutil/str_util.h>
diff --git a/ui/gtk/fileset_dlg.c b/ui/gtk/fileset_dlg.c
index 3b612c9401..44407865eb 100644
--- a/ui/gtk/fileset_dlg.c
+++ b/ui/gtk/fileset_dlg.c
@@ -24,10 +24,6 @@
#include <string.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
#include <gtk/gtk.h>
#include <wsutil/filesystem.h>
diff --git a/ui/gtk/firewall_dlg.c b/ui/gtk/firewall_dlg.c
index 5d4ce3cb8a..8ec00efa6c 100644
--- a/ui/gtk/firewall_dlg.c
+++ b/ui/gtk/firewall_dlg.c
@@ -36,14 +36,6 @@
#include <string.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <gtk/gtk.h>
#include <epan/packet.h>
diff --git a/ui/gtk/follow_stream.c b/ui/gtk/follow_stream.c
index 29445fc93c..f30e6648cf 100644
--- a/ui/gtk/follow_stream.c
+++ b/ui/gtk/follow_stream.c
@@ -23,9 +23,6 @@
#include "config.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
#include <string.h>
#include <gtk/gtk.h>
diff --git a/ui/gtk/follow_tcp.c b/ui/gtk/follow_tcp.c
index 1fa5f30ba8..aece6aabd6 100644
--- a/ui/gtk/follow_tcp.c
+++ b/ui/gtk/follow_tcp.c
@@ -25,10 +25,6 @@
#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <gtk/gtk.h>
#include <epan/follow.h>
diff --git a/ui/gtk/iax2_analysis.c b/ui/gtk/iax2_analysis.c
index 5f4178d98a..56a10f9770 100644
--- a/ui/gtk/iax2_analysis.c
+++ b/ui/gtk/iax2_analysis.c
@@ -38,14 +38,6 @@
#include <string.h>
#include <locale.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
#include <gtk/gtk.h>
#include <wsutil/file_util.h>
diff --git a/ui/gtk/main.c b/ui/gtk/main.c
index fc871d718b..29b665c743 100644
--- a/ui/gtk/main.c
+++ b/ui/gtk/main.c
@@ -36,10 +36,6 @@
#include <string.h>
#include <locale.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
diff --git a/ui/gtk/packet_panes.c b/ui/gtk/packet_panes.c
index 3c74b25dcb..6f78f8ef27 100644
--- a/ui/gtk/packet_panes.c
+++ b/ui/gtk/packet_panes.c
@@ -25,14 +25,6 @@
#include "config.h"
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#if GTK_CHECK_VERSION(3,0,0)
diff --git a/ui/gtk/rtp_analysis.c b/ui/gtk/rtp_analysis.c
index 695e405768..2d484ec0ef 100644
--- a/ui/gtk/rtp_analysis.c
+++ b/ui/gtk/rtp_analysis.c
@@ -37,14 +37,6 @@
#include <math.h>
#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
#include <gtk/gtk.h>
#include <wsutil/file_util.h>
diff --git a/ui/mcast_stream.c b/ui/mcast_stream.c
index 04cd9a3567..6d354a4e5d 100644
--- a/ui/mcast_stream.c
+++ b/ui/mcast_stream.c
@@ -28,9 +28,6 @@
*/
#include "config.h"
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
#include <glib.h>
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 6f05c1de21..e4eab4e43a 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -21,14 +21,6 @@
#include <config.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
// Qt 5.5.0 + Visual C++ 2013
#ifdef _MSC_VER
#pragma warning(push)
diff --git a/ui/rtp_stream.c b/ui/rtp_stream.c
index 07c9e81213..01b6198345 100644
--- a/ui/rtp_stream.c
+++ b/ui/rtp_stream.c
@@ -28,10 +28,6 @@
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
#include "file.h"
#include <epan/epan.h>
diff --git a/ui/text_import.c b/ui/text_import.c
index dc103d75e6..d7f4b2dcac 100644
--- a/ui/text_import.c
+++ b/ui/text_import.c
@@ -113,10 +113,6 @@
#include <time.h>
#include <glib.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
#include <errno.h>
#include <assert.h>
diff --git a/ui/traffic_table_ui.c b/ui/traffic_table_ui.c
index 0a98a98de9..b76f15830c 100644
--- a/ui/traffic_table_ui.c
+++ b/ui/traffic_table_ui.c
@@ -41,9 +41,6 @@
#include <errno.h>
#include <stdio.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
#include "wsutil/filesystem.h"
#include "wsutil/file_util.h"
#include "wsutil/tempfile.h"
diff --git a/wiretap/ber.c b/wiretap/ber.c
index 4b79579556..b7467ce3da 100644
--- a/wiretap/ber.c
+++ b/wiretap/ber.c
@@ -21,10 +21,6 @@
#include <errno.h>
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
#include "wtap-int.h"
#include "file_wrappers.h"
#include <wsutil/buffer.h>
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 0ae80a99c9..fad807bd2f 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -23,14 +23,6 @@
#include <string.h>
#include <stdlib.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <errno.h>
#include <wsutil/file_util.h>
diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c
index 92f8f7b961..66c0f5b51c 100644
--- a/wiretap/file_wrappers.c
+++ b/wiretap/file_wrappers.c
@@ -41,15 +41,8 @@
#include "config.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
#include <errno.h>
#include <stdio.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif /* HAVE_FCNTL_H */
#include <string.h>
#include "wtap-int.h"
#include "file_wrappers.h"
diff --git a/wiretap/stanag4607.c b/wiretap/stanag4607.c
index 9aa3105ba3..5636b72dd2 100644
--- a/wiretap/stanag4607.c
+++ b/wiretap/stanag4607.c
@@ -23,10 +23,6 @@
#include <errno.h>
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
#include "wtap-int.h"
#include "file_wrappers.h"
#include <wsutil/buffer.h>
diff --git a/wiretap/tnef.c b/wiretap/tnef.c
index 3db624ea6c..2b6266596b 100644
--- a/wiretap/tnef.c
+++ b/wiretap/tnef.c
@@ -21,10 +21,6 @@
#include <errno.h>
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
#include "wtap-int.h"
#include "file_wrappers.h"
#include <wsutil/buffer.h>
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index f984bfce4d..38be2248dc 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -27,10 +27,6 @@
#include <sys/types.h>
#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef HAVE_LIBZ
#include <zlib.h>
#endif
diff --git a/wsutil/file_util.h b/wsutil/file_util.h
index 833518a9bc..dff51bbe83 100644
--- a/wsutil/file_util.h
+++ b/wsutil/file_util.h
@@ -32,12 +32,20 @@ extern "C" {
#include <glib.h>
#ifdef _WIN32
-#include <io.h>
+#include <io.h> /* for _read(), _write(), etc. */
#include <gmodule.h>
#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h> /* for open() */
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h> /* for read(), write(), close(), etc. */
+#endif
+
#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
+#include <sys/stat.h> /* for stat() and struct stat */
#endif
/*
@@ -59,6 +67,8 @@ extern "C" {
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#endif
+#include <stdio.h>
+
#ifdef _WIN32
/*
@@ -81,8 +91,6 @@ extern "C" {
* removing the target if necessary.
*/
-#include <stdio.h>
-
WS_DLL_PUBLIC int ws_stdio_open (const gchar *filename, int flags, int mode);
WS_DLL_PUBLIC int ws_stdio_rename (const gchar *oldfilename, const gchar *newfilename);
WS_DLL_PUBLIC int ws_stdio_mkdir (const gchar *filename, int mode);
@@ -192,9 +200,7 @@ WS_DLL_PUBLIC void create_app_running_mutex();
#define ws_dir_rewind g_dir_rewind
#define ws_dir_close g_dir_close
-/* XXX - remove include "dirent.h" */
-/* XXX - remove include "direct.h" */
-/* XXX - remove include "sys/stat.h" */
+/* XXX - remove include "sys/stat.h" from files that include this header */
/* XXX - update docs (e.g. README.developer) */
#ifdef __cplusplus
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
index efa5f34041..787ad6ebb4 100644
--- a/wsutil/filesystem.c
+++ b/wsutil/filesystem.c
@@ -36,18 +36,6 @@
#include <glib.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
#ifdef _WIN32
#include <windows.h>
#include <tchar.h>
diff --git a/wsutil/plugins.c b/wsutil/plugins.c
index ab15a1809a..ac3687dff1 100644
--- a/wsutil/plugins.c
+++ b/wsutil/plugins.c
@@ -31,10 +31,6 @@
#include <string.h>
#include <errno.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <glib.h>
#include <gmodule.h>
diff --git a/wsutil/tempfile.c b/wsutil/tempfile.c
index 93bd66fe7a..4be05f8b84 100644
--- a/wsutil/tempfile.c
+++ b/wsutil/tempfile.c
@@ -26,14 +26,6 @@
#include <stdlib.h>
#include <errno.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
diff --git a/wsutil/u3.c b/wsutil/u3.c
index 7d6493659c..04c1c28878 100644
--- a/wsutil/u3.c
+++ b/wsutil/u3.c
@@ -31,11 +31,7 @@
#include <string.h>
#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
+#include <unistd.h> /* getpid */
#endif
#ifdef _WIN32