[MPlayer-dev-eng] [PATCH] Remove unnecessary/duplicated includes.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Jan 23 19:32:17 EET 2021


In particular sys/time.h is included in a lot
of places that do not need or need it only
when specific defines are set.
Besides being cleaner this should also be
better for portability, though there is a
risk of it breaking something on some
less common systems.
---
 input/input.c             |  2 ++
 libao2/ao_alsa.c          |  1 -
 libmenu/menu_console.c    | 14 ++++++++++----
 libmpcodecs/vf_filmdint.c |  6 ++----
 mencoder.c                |  1 -
 mplayer.c                 |  3 ---
 stream/freesdp/common.h   |  1 -
 stream/frequencies.c      |  1 -
 stream/librtsp/rtsp.c     |  2 +-
 stream/network.h          |  2 +-
 stream/pnm.c              |  2 +-
 stream/stream_dvb.c       |  1 -
 stream/stream_pvr.c       |  1 -
 stream/tcp.c              |  2 +-
 stream/tv.c               |  1 -
 stream/udp.c              |  2 +-
 16 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/input/input.c b/input/input.c
index e27bbefd7..4bfac0690 100644
--- a/input/input.c
+++ b/input/input.c
@@ -25,7 +25,9 @@
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifdef HAVE_POSIX_SELECT
 #include <sys/time.h>
+#endif
 #include <fcntl.h>
 #include <ctype.h>

diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c
index 36dcc1136..095837f9b 100644
--- a/libao2/ao_alsa.c
+++ b/libao2/ao_alsa.c
@@ -27,7 +27,6 @@
  */

 #include <errno.h>
-#include <sys/time.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <ctype.h>
diff --git a/libmenu/menu_console.c b/libmenu/menu_console.c
index 8bbc42ad6..a037cf8a2 100644
--- a/libmenu/menu_console.c
+++ b/libmenu/menu_console.c
@@ -20,14 +20,20 @@
 #include "mp_msg.h"
 #include "help_mp.h"

+#ifdef HAVE_POSIX_SELECT
+#define RUN_CMD 1
+#else
+#define RUN_CMD 0
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
-#include <sys/time.h>
 #include <sys/types.h>
-#ifndef __MINGW32__
+#if RUN_CMD
 #include <sys/wait.h>
+#include <sys/time.h>
 #endif
 #include <unistd.h>
 #include <errno.h>
@@ -241,7 +247,7 @@ static void draw(menu_t* menu, mp_image_t* mpi) {
 }

 static void check_child(menu_t* menu) {
-#ifndef __MINGW32__
+#if RUN_CMD
   fd_set rfd;
   struct timeval tv;
   int max_fd = mpriv->child_fd[2] > mpriv->child_fd[1] ? mpriv->child_fd[2] :
@@ -295,7 +301,7 @@ static void check_child(menu_t* menu) {
 #define close_pipe(pipe) close(pipe[0]); close(pipe[1])

 static int run_shell_cmd(menu_t* menu, char* cmd) {
-#ifndef __MINGW32__
+#if RUN_CMD
   int in[2],out[2],err[2];

   mp_msg(MSGT_GLOBAL,MSGL_INFO,MSGTR_LIBMENU_ConsoleRun,cmd);
diff --git a/libmpcodecs/vf_filmdint.c b/libmpcodecs/vf_filmdint.c
index 3795170a0..4043f48b5 100644
--- a/libmpcodecs/vf_filmdint.c
+++ b/libmpcodecs/vf_filmdint.c
@@ -19,11 +19,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/time.h>

 #include "config.h"
 #include "mp_msg.h"
 #include "cpudetect.h"
+#include "osdep/timer.h"

 #include "img_format.h"
 #include "mp_image.h"
@@ -927,9 +927,7 @@ static void init(struct vf_priv_s *p, mp_image_t *mpi)

 static inline double get_time(void)
 {
-    struct timeval tv;
-    gettimeofday(&tv, 0);
-    return tv.tv_sec + tv.tv_usec * 1e-6;
+    return GetTimer() * 1e-6;
 }

 static void get_image(struct vf_instance *vf, mp_image_t *mpi)
diff --git a/mencoder.c b/mencoder.c
index 791a276b7..9b7a880f7 100644
--- a/mencoder.c
+++ b/mencoder.c
@@ -50,7 +50,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/time.h>
 #if defined(__MINGW32__) || defined(__CYGWIN__)
 #include <windows.h>
 #endif
diff --git a/mplayer.c b/mplayer.c
index 92d65384f..ee0063e63 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -29,7 +29,6 @@
 #include <unistd.h>
 #include <assert.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 #include <sys/types.h>

 #if defined(__MINGW32__) || defined(__CYGWIN__)
@@ -123,8 +122,6 @@
 #include "sub/subreader.h"
 #include "sub/vobsub.h"
 #include "sub/eosd.h"
-#include "osdep/getch2.h"
-#include "osdep/timer.h"

 #include "udp_sync.h"

diff --git a/stream/freesdp/common.h b/stream/freesdp/common.h
index f276a0755..b453d1e98 100644
--- a/stream/freesdp/common.h
+++ b/stream/freesdp/common.h
@@ -35,7 +35,6 @@
 #  define END_C_DECLS
 #endif /* __cplusplus */

-#include <sys/time.h>
 #include <time.h>

 BEGIN_C_DECLS
diff --git a/stream/frequencies.c b/stream/frequencies.c
index 0ac9e483e..1690892e8 100644
--- a/stream/frequencies.c
+++ b/stream/frequencies.c
@@ -17,7 +17,6 @@
  */

 #include <stdlib.h>
-#include <sys/time.h>

 #include "frequencies.h"

diff --git a/stream/librtsp/rtsp.c b/stream/librtsp/rtsp.c
index 3399b4f20..aeb5a91b0 100644
--- a/stream/librtsp/rtsp.c
+++ b/stream/librtsp/rtsp.c
@@ -39,12 +39,12 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <time.h>
-#include <sys/time.h>
 #include <sys/types.h>
 #include <inttypes.h>
 #if HAVE_WINSOCK2_H
 #include <winsock2.h>
 #else
+#include <sys/time.h>
 #include <sys/socket.h>
 #endif
 #include "libavutil/avstring.h"
diff --git a/stream/network.h b/stream/network.h
index df6f53974..13f4e5c28 100644
--- a/stream/network.h
+++ b/stream/network.h
@@ -24,7 +24,6 @@
 #define MPLAYER_NETWORK_H

 #include <fcntl.h>
-#include <sys/time.h>
 #include <sys/types.h>

 #include "config.h"
@@ -32,6 +31,7 @@
 #include <netdb.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
+#include <sys/time.h>
 #include <arpa/inet.h>
 #endif

diff --git a/stream/pnm.c b/stream/pnm.c
index bdf057b45..2bde7b748 100644
--- a/stream/pnm.c
+++ b/stream/pnm.c
@@ -33,10 +33,10 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <stdlib.h>
-#include <sys/time.h>
 #include <inttypes.h>
 #if !HAVE_WINSOCK2_H
 #include <sys/socket.h>
+#include <sys/time.h>
 //#include <netinet/in.h>
 //#include <netdb.h>
 #else
diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c
index 047b06451..80b93a5e3 100644
--- a/stream/stream_dvb.c
+++ b/stream/stream_dvb.c
@@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 #include <string.h>
 #include <ctype.h>
 #include <sys/ioctl.h>
-#include <sys/time.h>
 #include <poll.h>
 #include <unistd.h>
 #include <fcntl.h>
diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c
index ceb9ee7fe..ecea3fb93 100644
--- a/stream/stream_pvr.c
+++ b/stream/stream_pvr.c
@@ -29,7 +29,6 @@
 #include <unistd.h>
 #include <string.h>
 #include <ctype.h>
-#include <sys/time.h>
 #include <errno.h>
 #include <sys/ioctl.h>
 #include <fcntl.h>
diff --git a/stream/tcp.c b/stream/tcp.c
index c1762eb56..d18124134 100644
--- a/stream/tcp.c
+++ b/stream/tcp.c
@@ -30,7 +30,6 @@
 #include <ctype.h>

 #include <fcntl.h>
-#include <sys/time.h>
 #include <sys/types.h>

 #include "config.h"
@@ -42,6 +41,7 @@
 #include <netdb.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
+#include <sys/time.h>
 #include <arpa/inet.h>
 #else
 #include <winsock2.h>
diff --git a/stream/tv.c b/stream/tv.c
index d14ad6986..6dce1a9b3 100644
--- a/stream/tv.c
+++ b/stream/tv.c
@@ -30,7 +30,6 @@
 #include <unistd.h>
 #include <string.h>
 #include <ctype.h>
-#include <sys/time.h>

 #include "config.h"

diff --git a/stream/udp.c b/stream/udp.c
index 9e0eb6efb..3051cd04c 100644
--- a/stream/udp.c
+++ b/stream/udp.c
@@ -30,13 +30,13 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <sys/types.h>
-#include <sys/time.h>
 #include <ctype.h>

 #if !HAVE_WINSOCK2_H
 #include <netdb.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
+#include <sys/time.h>
 #include <arpa/inet.h>
 #else
 #include <winsock2.h>
--
2.30.0



More information about the MPlayer-dev-eng mailing list