Various cleanups (#1099)

* cmake: remove atomic checks

All this stuff was replaced with std::atomic

Fixes: 9bcba812af

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* cmake: remove vsnprintf checks

Available since C++11

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* clang-tidy: const ref conversions

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* clang-tidy: handle self assignment

Found with bugprone-unhandled-self-assignment,cert-oop54-cpp

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* clang-tidy: remove wrong forward declarations

Found with bugprone-forward-declaration-namespace

Signed-off-by: Rosen Penev <rosenp@gmail.com>

---------

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2023-08-05 08:31:46 -07:00 committed by GitHub
parent c0e9428218
commit 868f4eef3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 8 additions and 107 deletions

View File

@ -34,53 +34,6 @@ if(NOT ${SIZEOF_DOUBLE} EQUAL 8)
message(FATAL_ERROR "TagLib requires that double is 64-bit wide.")
endif()
# Determine which kind of atomic operations your compiler supports.
check_cxx_source_compiles("
int main() {
volatile int x;
__sync_add_and_fetch(&x, 1);
int y = __sync_sub_and_fetch(&x, 1);
return 0;
}
" HAVE_GCC_ATOMIC)
if(NOT HAVE_GCC_ATOMIC)
check_cxx_source_compiles("
#include <libkern/OSAtomic.h>
int main() {
volatile int32_t x;
OSAtomicIncrement32Barrier(&x);
int32_t y = OSAtomicDecrement32Barrier(&x);
return 0;
}
" HAVE_MAC_ATOMIC)
if(NOT HAVE_MAC_ATOMIC)
check_cxx_source_compiles("
#include <windows.h>
int main() {
volatile LONG x;
InterlockedIncrement(&x);
LONG y = InterlockedDecrement(&x);
return 0;
}
" HAVE_WIN_ATOMIC)
if(NOT HAVE_WIN_ATOMIC)
check_cxx_source_compiles("
#include <ia64intrin.h>
int main() {
volatile int x;
__sync_add_and_fetch(&x, 1);
int y = __sync_sub_and_fetch(&x, 1);
return 0;
}
" HAVE_IA64_ATOMIC)
endif()
endif()
endif()
# Determine which kind of byte swap functions your compiler supports.
check_cxx_source_compiles("
@ -140,32 +93,6 @@ if(NOT HAVE_GCC_BYTESWAP)
endif()
endif()
# Determine whether your compiler supports some safer version of vsprintf.
check_cxx_source_compiles("
#include <cstdio>
#include <cstdarg>
int main() {
char buf[20];
va_list args;
vsnprintf(buf, 20, \"%d\", args);
return 0;
}
" HAVE_VSNPRINTF)
if(NOT HAVE_VSNPRINTF)
check_cxx_source_compiles("
#include <cstdio>
#include <cstdarg>
int main() {
char buf[20];
va_list args;
vsprintf_s(buf, \"%d\", args);
return 0;
}
" HAVE_VSPRINTF_S)
endif()
# Determine whether your compiler supports ISO _strdup.
check_cxx_source_compiles("

View File

@ -10,16 +10,6 @@
#cmakedefine HAVE_MAC_BYTESWAP 1
#cmakedefine HAVE_OPENBSD_BYTESWAP 1
/* Defined if your compiler supports some atomic operations */
#cmakedefine HAVE_GCC_ATOMIC 1
#cmakedefine HAVE_MAC_ATOMIC 1
#cmakedefine HAVE_WIN_ATOMIC 1
#cmakedefine HAVE_IA64_ATOMIC 1
/* Defined if your compiler supports some safer version of vsprintf */
#cmakedefine HAVE_VSNPRINTF 1
#cmakedefine HAVE_VSPRINTF_S 1
/* Defined if your compiler supports ISO _strdup */
#cmakedefine HAVE_ISO_STRDUP 1

View File

@ -34,8 +34,6 @@ namespace TagLib {
namespace FLAC {
class File;
//! An implementation of audio property reading for FLAC
/*!

View File

@ -64,7 +64,8 @@ namespace TagLib {
};
struct AtomData {
AtomData(AtomDataType type, ByteVector data) : type(type), locale(0), data(data) {}
AtomData(AtomDataType type, const ByteVector &data) :
type(type), locale(0), data(data) { }
AtomDataType type;
int locale;
ByteVector data;

View File

@ -85,7 +85,8 @@ namespace TagLib {
* Single entry of time stamp and lyrics text.
*/
struct SynchedText {
SynchedText(unsigned int ms, String str) : time(ms), text(str) {}
SynchedText(unsigned int ms, const String &str) :
time(ms), text(str) { }
unsigned int time;
String text;
};

View File

@ -44,7 +44,6 @@ namespace TagLib {
class Header;
class ExtendedHeader;
class Footer;
typedef List<Frame *> FrameList;
typedef Map<ByteVector, FrameList> FrameListMap;

View File

@ -189,6 +189,9 @@ T &Map<Key, T>::operator[](const Key &key)
template <class Key, class T>
Map<Key, T> &Map<Key, T>::operator=(const Map<Key, T> &m)
{
if (this == &m)
return *this;
Map<Key, T>(m).swap(*this);
return *this;
}

View File

@ -179,25 +179,7 @@ namespace TagLib
char buf[BufferSize];
int length;
#if defined(HAVE_VSNPRINTF)
length = vsnprintf(buf, BufferSize, format, args);
#elif defined(HAVE_VSPRINTF_S)
length = vsprintf_s(buf, format, args);
#else
// The last resort. May cause a buffer overflow.
length = vsprintf(buf, format, args);
if(length >= BufferSize) {
debug("Utils::formatString() - Buffer overflow! Returning an empty string.");
length = -1;
}
#endif
length = std::vsnprintf(buf, BufferSize, format, args);
va_end(args);