From 0162e54075bb7ad967a85736b3c8addd53d86de5 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 6 Nov 2015 19:20:37 -0800 Subject: 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 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 Reviewed-by: Guy Harris --- wsutil/file_util.h | 20 +++++++++++++------- wsutil/filesystem.c | 12 ------------ wsutil/plugins.c | 4 ---- wsutil/tempfile.c | 8 -------- wsutil/u3.c | 6 +----- 5 files changed, 14 insertions(+), 36 deletions(-) (limited to 'wsutil') 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 #ifdef _WIN32 -#include +#include /* for _read(), _write(), etc. */ #include #endif +#ifdef HAVE_FCNTL_H +#include /* for open() */ +#endif + +#ifdef HAVE_UNISTD_H +#include /* for read(), write(), close(), etc. */ +#endif + #ifdef HAVE_SYS_STAT_H -#include +#include /* for stat() and struct stat */ #endif /* @@ -59,6 +67,8 @@ extern "C" { #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) #endif +#include + #ifdef _WIN32 /* @@ -81,8 +91,6 @@ extern "C" { * removing the target if necessary. */ -#include - 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 -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef HAVE_FCNTL_H -#include -#endif - -#ifdef HAVE_SYS_STAT_H -#include -#endif - #ifdef _WIN32 #include #include 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 #include -#ifdef HAVE_UNISTD_H -#include -#endif - #include #include 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 #include -#ifdef HAVE_FCNTL_H -#include -#endif - -#ifdef HAVE_UNISTD_H -#include -#endif - #ifdef HAVE_WINDOWS_H #include #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 #ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef HAVE_FCNTL_H -#include +#include /* getpid */ #endif #ifdef _WIN32 -- cgit v1.2.3