From 55772e1133039419f6c14f5b241c798c0a9453cf Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Tue, 28 Jan 2025 20:33:26 -0500 Subject: [PATCH] chore: remove unused ARCH::vsnprintf --- cmake/Libraries.cmake | 3 +- src/lib/arch/CMakeLists.txt | 3 +- src/lib/arch/IArchString.h | 10 +---- src/lib/arch/unix/ArchStringUnix.cpp | 1 - src/lib/arch/vsnprintf.h | 55 ------------------------ src/lib/arch/win32/ArchStringWindows.cpp | 6 +-- src/lib/config.h.in | 4 +- 7 files changed, 5 insertions(+), 77 deletions(-) delete mode 100644 src/lib/arch/vsnprintf.h diff --git a/cmake/Libraries.cmake b/cmake/Libraries.cmake index cfcf52dae..cb6dc1649 100644 --- a/cmake/Libraries.cmake +++ b/cmake/Libraries.cmake @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2024 Deskflow Developers +# SPDX-FileCopyrightText: 2024 - 2025 Deskflow Developers # SPDX-FileCopyrightText: 2024 Symless Ltd # SPDX-License-Identifier: MIT @@ -124,7 +124,6 @@ macro(configure_unix_libs) check_function_exists(gmtime_r HAVE_GMTIME_R) check_function_exists(nanosleep HAVE_NANOSLEEP) check_function_exists(sigwait HAVE_POSIX_SIGWAIT) - check_function_exists(vsnprintf HAVE_VSNPRINTF) check_function_exists(inet_aton HAVE_INET_ATON) # For some reason, the check_function_exists macro doesn't detect the diff --git a/src/lib/arch/CMakeLists.txt b/src/lib/arch/CMakeLists.txt index 7e8dbcea5..77589603b 100644 --- a/src/lib/arch/CMakeLists.txt +++ b/src/lib/arch/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2024 Chris Rizzitello +# SPDX-FileCopyrightText: 2024 - 2025 Chris Rizzitello # SPDX-FileCopyrightText: 2012 - 2024 Symless Ltd # SPDX-FileCopyrightText: 2009 - 2012 Nick Bolton # SPDX-License-Identifier: MIT @@ -78,7 +78,6 @@ add_library(arch STATIC ${PLATFORM_CODE} IArchSystem.h IArchTime.h multibyte.h - vsnprintf.h XArch.h ) diff --git a/src/lib/arch/IArchString.h b/src/lib/arch/IArchString.h index 4aef966d9..529b39cb4 100644 --- a/src/lib/arch/IArchString.h +++ b/src/lib/arch/IArchString.h @@ -1,5 +1,6 @@ /* * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception @@ -44,15 +45,6 @@ public: //! @name manipulators //@{ - //! printf() to limited size buffer with va_list - /*! - This method is equivalent to vsprintf() except it will not write - more than \c n bytes to the buffer, returning -1 if the output - was truncated and the number of bytes written not including the - trailing NUL otherwise. - */ - virtual int vsnprintf(char *str, int size, const char *fmt, va_list ap); - //! Convert multibyte string to wide character string virtual int convStringMBToWC(wchar_t *, const char *, uint32_t n, bool *errors); diff --git a/src/lib/arch/unix/ArchStringUnix.cpp b/src/lib/arch/unix/ArchStringUnix.cpp index 84828a332..1ade10aa0 100644 --- a/src/lib/arch/unix/ArchStringUnix.cpp +++ b/src/lib/arch/unix/ArchStringUnix.cpp @@ -14,7 +14,6 @@ // #include "arch/multibyte.h" -#include "arch/vsnprintf.h" ArchStringUnix::ArchStringUnix() { diff --git a/src/lib/arch/vsnprintf.h b/src/lib/arch/vsnprintf.h deleted file mode 100644 index cdd7f8004..000000000 --- a/src/lib/arch/vsnprintf.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. - * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#pragma once - -#include "arch/IArchString.h" - -#if HAVE_VSNPRINTF - -#if !defined(ARCH_VSNPRINTF) -#define ARCH_VSNPRINTF vsnprintf -#endif - -int IArchString::vsnprintf(char *str, int size, const char *fmt, va_list ap) -{ - int n = ::ARCH_VSNPRINTF(str, size, fmt, ap); - if (n > size) { - n = -1; - } - return n; -} - -#elif SYSAPI_UNIX // !HAVE_VSNPRINTF - -#include - -int IArchString::vsnprintf(char *str, int size, const char *fmt, va_list ap) -{ - static FILE *bitbucket = fopen("/dev/null", "w"); - if (bitbucket == NULL) { - // uh oh - if (size > 0) { - str[0] = '\0'; - } - return 0; - } else { - // count the characters using the bitbucket - int n = vfprintf(bitbucket, fmt, ap); - if (n + 1 <= size) { - // it'll fit so print it into str - vsprintf(str, fmt, ap); - } - return n; - } -} - -#else // !HAVE_VSNPRINTF && !SYSAPI_UNIX - -#error vsnprintf not implemented - -#endif // !HAVE_VSNPRINTF diff --git a/src/lib/arch/win32/ArchStringWindows.cpp b/src/lib/arch/win32/ArchStringWindows.cpp index 2b222c29f..2c720e597 100644 --- a/src/lib/arch/win32/ArchStringWindows.cpp +++ b/src/lib/arch/win32/ArchStringWindows.cpp @@ -1,5 +1,6 @@ /* * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception @@ -15,11 +16,6 @@ // ArchStringWindows // -#include "arch/multibyte.h" -#define HAVE_VSNPRINTF 1 -#define ARCH_VSNPRINTF _vsnprintf -#include "arch/vsnprintf.h" - ArchStringWindows::ArchStringWindows() { } diff --git a/src/lib/config.h.in b/src/lib/config.h.in index 55e5b3f22..4b975ddc4 100644 --- a/src/lib/config.h.in +++ b/src/lib/config.h.in @@ -1,5 +1,6 @@ /* * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2009 Symless Ltd. * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception */ @@ -63,9 +64,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@ -/* Define to 1 if you have the `vsnprintf` function. */ -#cmakedefine HAVE_VSNPRINTF @HAVE_VSNPRINTF@ - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_WCHAR_H @HAVE_WCHAR_H@