From: Guus Sliepen Date: Sat, 19 Apr 2014 11:28:18 +0000 (+0200) Subject: Remove unused functions and #includes. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=4c19d9a203d0ff05ffe680732b4564d0e783d037;p=meshlink Remove unused functions and #includes. --- diff --git a/configure.ac b/configure.ac index b163474a..8b5babd5 100644 --- a/configure.ac +++ b/configure.ac @@ -128,14 +128,8 @@ dnl Checks for header files. dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies. AC_HEADER_STDC -AC_CHECK_HEADERS([stdbool.h syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/uio.h sys/un.h sys/wait.h netdb.h arpa/inet.h dirent.h]) -AC_CHECK_HEADERS([net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h time.h netpacket/packet.h], - [], [], [#include "src/have.h"] -) -AC_CHECK_HEADERS([netinet/if_ether.h netinet/ip.h netinet/ip6.h], - [], [], [#include "src/have.h"] -) -AC_CHECK_HEADERS([netinet/tcp.h netinet/ip_icmp.h netinet/icmp6.h], +AC_CHECK_HEADERS([stdbool.h syslog.h sys/file.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/un.h sys/wait.h netdb.h arpa/inet.h dirent.h]) +AC_CHECK_HEADERS([time.h], [], [], [#include "src/have.h"] ) @@ -150,13 +144,13 @@ AC_STRUCT_TM MeshLink_ATTRIBUTE(__malloc__) MeshLink_ATTRIBUTE(__warn_unused_result__) -AC_CHECK_TYPES([socklen_t, struct ether_header, struct arphdr, struct ether_arp, struct in_addr, struct addrinfo, struct ip, struct icmp, struct in6_addr, struct sockaddr_in6, struct ip6_hdr, struct icmp6_hdr, struct nd_neighbor_solicit, struct nd_opt_hdr], , , +AC_CHECK_TYPES([socklen_t, struct addrinfo, struct sockaddr_in6], , , [#include "src/have.h"] ) dnl Checks for library functions. AC_TYPE_SIGNAL -AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name gettimeofday mlockall putenv random select strdup strerror strsignal strtol system time usleep unsetenv vsyslog writev], +AC_CHECK_FUNCS([asprintf fchmod fork get_current_dir_name gettimeofday random select strdup strerror time usleep], [], [], [#include "src/have.h"] ) diff --git a/src/dropin.c b/src/dropin.c index de920530..1cd06fc1 100644 --- a/src/dropin.c +++ b/src/dropin.c @@ -21,70 +21,6 @@ #include "xalloc.h" -#ifndef HAVE_DAEMON -/* - Replacement for the daemon() function. - - The daemon() function is for programs wishing to detach themselves - from the controlling terminal and run in the background as system - daemons. - - Unless the argument nochdir is non-zero, daemon() changes the - current working directory to the root (``/''). - - Unless the argument noclose is non-zero, daemon() will redirect - standard input, standard output and standard error to /dev/null. -*/ -int daemon(int nochdir, int noclose) { -#ifdef HAVE_FORK - pid_t pid; - int fd; - - pid = fork(); - - /* Check if forking failed */ - if(pid < 0) { - perror("fork"); - exit(-1); - } - - /* If we are the parent, terminate */ - if(pid) - exit(0); - - /* Detach by becoming the new process group leader */ - if(setsid() < 0) { - perror("setsid"); - return -1; - } - - /* Change working directory to the root (to avoid keeping mount - points busy) */ - if(!nochdir) { - chdir("/"); - } - - /* Redirect stdin/out/err to /dev/null */ - if(!noclose) { - fd = open("/dev/null", O_RDWR); - - if(fd < 0) { - perror("opening /dev/null"); - return -1; - } else { - dup2(fd, 0); - dup2(fd, 1); - dup2(fd, 2); - } - } - - return 0; -#else - return -1; -#endif -} -#endif - #ifndef HAVE_GET_CURRENT_DIR_NAME /* Replacement for the GNU get_current_dir_name function: diff --git a/src/dropin.h b/src/dropin.h index fd09ca23..ed6b3856 100644 --- a/src/dropin.h +++ b/src/dropin.h @@ -23,10 +23,6 @@ #include "fake-getaddrinfo.h" #include "fake-getnameinfo.h" -#ifndef HAVE_DAEMON -extern int daemon(int, int); -#endif - #ifndef HAVE_GET_CURRENT_DIR_NAME extern char *get_current_dir_name(void); #endif diff --git a/src/have.h b/src/have.h index c49e506c..07411724 100644 --- a/src/have.h +++ b/src/have.h @@ -89,10 +89,6 @@ #include #endif -#ifdef HAVE_SYS_IOCTL_H -#include -#endif - #ifdef HAVE_SYS_PARAM_H #include #endif @@ -101,10 +97,6 @@ #include #endif -#ifdef HAVE_SYS_UIO_H -#include -#endif - #ifdef HAVE_SYS_UN_H #include #endif @@ -124,42 +116,10 @@ #include #endif -#ifdef HAVE_NET_IF_H -#include -#endif - -#ifdef HAVE_NET_IF_TYPES_H -#include -#endif - -#ifdef HAVE_NETINET_IN_SYSTM_H -#include -#endif - -#ifdef HAVE_NETINET_IN_H -#include -#endif - #ifdef HAVE_ARPA_INET_H #include #endif -#ifdef HAVE_NETINET_IP_H -#include -#endif - -#ifdef HAVE_NETINET_TCP_H -#include -#endif - -#ifdef HAVE_NETINET_IN6_H -#include -#endif - -#ifdef HAVE_NETINET_IP6_H -#include -#endif - #ifdef HAVE_MINGW #define SLASH "\\" #else diff --git a/src/sptps_test.c b/src/sptps_test.c index 33bad0a5..0ff59cb4 100644 --- a/src/sptps_test.c +++ b/src/sptps_test.c @@ -20,6 +20,8 @@ #include "system.h" #ifdef HAVE_LINUX +#include +#include #include #endif