From cab599120c3ae507838e44b34d23427d3add8f6e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 1 Apr 2023 23:41:07 +0000 Subject: [PATCH] delete redundant `HAVE_STDLIB_H` libssh2 used this standard C89 header unconditionally before this patch. Delete the feature checks and all unnecessary header guards. Closes #913 --- CMakeLists.txt | 7 +------ configure.ac | 2 +- example/direct_tcpip.c | 2 -- example/ssh2_echo.c | 2 -- example/ssh2_exec.c | 2 -- example/subsystem_netconf.c | 2 -- example/tcpip-forward.c | 2 -- example/x11.c | 2 -- os400/libssh2_config.h | 3 --- src/libssh2_config_cmake.h.in | 1 - src/misc.c | 2 -- src/os400qc3.c | 2 -- src/wincng.c | 3 +-- vms/libssh2_config.h | 1 - win32/libssh2_config.h | 1 - 15 files changed, 3 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19dbfaa7..8795d801 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,7 +122,6 @@ set(LIB_SHARED "libssh2_shared") # Must match libssh2_shared_EXPORTS macro in i ## Platform checks check_include_files(unistd.h HAVE_UNISTD_H) check_include_files(inttypes.h HAVE_INTTYPES_H) -check_include_files(stdlib.h HAVE_STDLIB_H) check_include_files(sys/select.h HAVE_SYS_SELECT_H) check_include_files(sys/uio.h HAVE_SYS_UIO_H) @@ -151,11 +150,7 @@ if(HAVE_SYS_TIME_H) else() check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) endif() -if(HAVE_STDLIB_H) - check_symbol_exists(strtoll stdlib.h HAVE_STRTOLL) -else() - check_function_exists(strtoll HAVE_STRTOLL) -endif() +check_symbol_exists(strtoll stdlib.h HAVE_STRTOLL) if (NOT HAVE_STRTOLL) # Try _strtoi64 if strtoll isn't available check_symbol_exists(_strtoi64 stdlib.h HAVE_STRTOI64) diff --git a/configure.ac b/configure.ac index 076eee6f..2f6d7238 100644 --- a/configure.ac +++ b/configure.ac @@ -278,7 +278,7 @@ AM_CONDITIONAL([USE_OSSFUZZ_STATIC], [test -f "$LIB_FUZZING_ENGINE"]) # Checks for header files. # AC_HEADER_STDC -AC_CHECK_HEADERS([errno.h fcntl.h stdio.h stdlib.h unistd.h sys/param.h sys/uio.h]) +AC_CHECK_HEADERS([errno.h fcntl.h stdio.h unistd.h sys/param.h sys/uio.h]) AC_CHECK_HEADERS([sys/select.h sys/socket.h sys/ioctl.h sys/time.h]) AC_CHECK_HEADERS([arpa/inet.h netinet/in.h]) AC_CHECK_HEADERS([sys/un.h], [have_sys_un_h=yes], [have_sys_un_h=no]) diff --git a/example/direct_tcpip.c b/example/direct_tcpip.c index f61b9bb7..75725623 100644 --- a/example/direct_tcpip.c +++ b/example/direct_tcpip.c @@ -23,9 +23,7 @@ #include #include #include -#ifdef HAVE_STDLIB_H #include -#endif #ifdef HAVE_UNISTD_H #include #endif diff --git a/example/ssh2_echo.c b/example/ssh2_echo.c index ae62a7cc..d884532c 100644 --- a/example/ssh2_echo.c +++ b/example/ssh2_echo.c @@ -39,9 +39,7 @@ #include #endif #include -#ifdef HAVE_STDLIB_H #include -#endif #include #include #include diff --git a/example/ssh2_exec.c b/example/ssh2_exec.c index fb250e63..834dcdf8 100644 --- a/example/ssh2_exec.c +++ b/example/ssh2_exec.c @@ -41,9 +41,7 @@ #include #endif #include -#ifdef HAVE_STDLIB_H #include -#endif #include #include #include diff --git a/example/subsystem_netconf.c b/example/subsystem_netconf.c index 4a400593..79034116 100644 --- a/example/subsystem_netconf.c +++ b/example/subsystem_netconf.c @@ -22,9 +22,7 @@ #include #include #include -#ifdef HAVE_STDLIB_H #include -#endif #ifdef HAVE_UNISTD_H #include #endif diff --git a/example/tcpip-forward.c b/example/tcpip-forward.c index c42a6f14..7ec4692c 100644 --- a/example/tcpip-forward.c +++ b/example/tcpip-forward.c @@ -23,9 +23,7 @@ #include #include #include -#ifdef HAVE_STDLIB_H #include -#endif #ifdef HAVE_UNISTD_H #include #endif diff --git a/example/x11.c b/example/x11.c index ecce8871..a58ee075 100644 --- a/example/x11.c +++ b/example/x11.c @@ -38,9 +38,7 @@ #include #include #include -#ifdef HAVE_STDLIB_H #include -#endif #include diff --git a/os400/libssh2_config.h b/os400/libssh2_config.h index ac14da6a..1c07d1f2 100644 --- a/os400/libssh2_config.h +++ b/os400/libssh2_config.h @@ -107,9 +107,6 @@ /* Define to 1 if you have the header file. */ #define HAVE_STDIO_H 1 -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - /* Define to 1 if you have the `strtoll' function. */ #define HAVE_STRTOLL 1 diff --git a/src/libssh2_config_cmake.h.in b/src/libssh2_config_cmake.h.in index 0be020e1..2bca1e4a 100644 --- a/src/libssh2_config_cmake.h.in +++ b/src/libssh2_config_cmake.h.in @@ -38,7 +38,6 @@ /* Headers */ #cmakedefine HAVE_UNISTD_H #cmakedefine HAVE_INTTYPES_H -#cmakedefine HAVE_STDLIB_H #cmakedefine HAVE_SYS_SELECT_H #cmakedefine HAVE_SYS_UIO_H #cmakedefine HAVE_SYS_SOCKET_H diff --git a/src/misc.c b/src/misc.c index 5e07d33c..86990029 100644 --- a/src/misc.c +++ b/src/misc.c @@ -40,9 +40,7 @@ #include "libssh2_priv.h" #include "misc.h" -#ifdef HAVE_STDLIB_H #include -#endif #ifdef HAVE_UNISTD_H #include diff --git a/src/os400qc3.c b/src/os400qc3.c index 89f440ee..420cfad2 100644 --- a/src/os400qc3.c +++ b/src/os400qc3.c @@ -41,9 +41,7 @@ #ifdef LIBSSH2_OS400QC3 /* compile only if we build with OS/400 QC3 library */ -#ifdef HAVE_STDLIB_H #include -#endif #include #include diff --git a/src/wincng.c b/src/wincng.c index ca729900..e17ae454 100644 --- a/src/wincng.c +++ b/src/wincng.c @@ -60,9 +60,8 @@ #include #include -#ifdef HAVE_STDLIB_H #include -#endif + #ifdef HAVE_LIBCRYPT32 #include #endif diff --git a/vms/libssh2_config.h b/vms/libssh2_config.h index 94c81e01..9eac4d71 100644 --- a/vms/libssh2_config.h +++ b/vms/libssh2_config.h @@ -14,7 +14,6 @@ typedef unsigned int socklen_t; /* missing in headers on VMS */ /* Have's */ #define HAVE_UNISTD_H -#define HAVE_STDLIB_H #define HAVE_INTTYPES_H #define HAVE_SYS_TIME_H #define HAVE_SELECT diff --git a/win32/libssh2_config.h b/win32/libssh2_config.h index bc2ab681..da4af839 100644 --- a/win32/libssh2_config.h +++ b/win32/libssh2_config.h @@ -10,7 +10,6 @@ #endif #define HAVE_LIBCRYPT32 -#define HAVE_STDLIB_H #define HAVE_IOCTLSOCKET #define HAVE_SELECT #define HAVE_SNPRINTF