From 95f84afd338a9333b2fcf05dc171ce1dad6fbe7c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 26 Dec 2014 14:28:01 +0100 Subject: [PATCH] fs/Traits, ...: work around -Wtautological-pointer-compare New in clang 3.6. --- src/Idle.cxx | 3 +++ src/SongLoader.cxx | 3 +++ src/db/plugins/simple/SimpleDatabasePlugin.cxx | 5 ++++- src/fs/Traits.hxx | 16 ++++++++++++++++ src/lib/icu/Collate.cxx | 6 ++++++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/Idle.cxx b/src/Idle.cxx index 8fe672200..0b66065de 100644 --- a/src/Idle.cxx +++ b/src/Idle.cxx @@ -76,7 +76,10 @@ idle_get_names(void) unsigned idle_parse_name(const char *name) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(name != nullptr); +#endif for (unsigned i = 0; idle_names[i] != nullptr; ++i) if (StringEqualsCaseASCII(name, idle_names[i])) diff --git a/src/SongLoader.cxx b/src/SongLoader.cxx index c766a16a9..43e57e93b 100644 --- a/src/SongLoader.cxx +++ b/src/SongLoader.cxx @@ -77,7 +77,10 @@ SongLoader::LoadFile(const char *path_utf8, Error &error) const DetachedSong * SongLoader::LoadSong(const char *uri_utf8, Error &error) const { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(uri_utf8 != nullptr); +#endif if (memcmp(uri_utf8, "file:///", 8) == 0) /* absolute path */ diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index 7b1886f1c..a0472462a 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -435,9 +435,12 @@ SimpleDatabase::Save(Error &error) bool SimpleDatabase::Mount(const char *uri, Database *db, Error &error) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(uri != nullptr); - assert(*uri != 0); assert(db != nullptr); +#endif + assert(*uri != 0); ScopeDatabaseLock protect; diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx index 77317e1ee..1af8f8672 100644 --- a/src/fs/Traits.hxx +++ b/src/fs/Traits.hxx @@ -57,7 +57,11 @@ struct PathTraitsFS { gcc_pure gcc_nonnull_all static const_pointer FindLastSeparator(const_pointer p) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(p != nullptr); +#endif + #ifdef WIN32 const_pointer pos = p + GetLength(p); while (p != pos && !IsSeparator(*pos)) @@ -77,7 +81,11 @@ struct PathTraitsFS { gcc_pure gcc_nonnull_all static bool IsAbsolute(const_pointer p) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(p != nullptr); +#endif + #ifdef WIN32 if (IsDrive(p) && IsSeparator(p[2])) return true; @@ -147,7 +155,11 @@ struct PathTraitsUTF8 { gcc_pure gcc_nonnull_all static const_pointer FindLastSeparator(const_pointer p) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(p != nullptr); +#endif + return strrchr(p, SEPARATOR); } @@ -160,7 +172,11 @@ struct PathTraitsUTF8 { gcc_pure gcc_nonnull_all static bool IsAbsolute(const_pointer p) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(p != nullptr); +#endif + #ifdef WIN32 if (IsDrive(p) && IsSeparator(p[2])) return true; diff --git a/src/lib/icu/Collate.cxx b/src/lib/icu/Collate.cxx index b8560a4d8..17b536b37 100644 --- a/src/lib/icu/Collate.cxx +++ b/src/lib/icu/Collate.cxx @@ -121,8 +121,11 @@ gcc_pure int IcuCollate(const char *a, const char *b) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(a != nullptr); assert(b != nullptr); +#endif #ifdef HAVE_ICU assert(collator != nullptr); @@ -159,7 +162,10 @@ IcuCaseFold(const char *src) { #ifdef HAVE_ICU assert(collator != nullptr); +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(src != nullptr); +#endif const auto u = UCharFromUTF8(src); if (u.IsNull())