From 53f40448901ffe0d953c81939d031c63cdf3779a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 26 Dec 2014 13:40:17 +0100 Subject: util/{ASCII,UriUtil}, ...: work around -Wtautological-pointer-compare New in clang 3.6. --- src/DatabaseGlue.cxx | 3 +++ src/DecoderPlugin.cxx | 6 ++++++ src/Directory.cxx | 3 +++ src/InputStream.cxx | 6 ++++++ src/SongFilter.cxx | 3 +++ src/fs/Charset.cxx | 6 ++++++ src/fs/Traits.cxx | 6 ++++++ src/tag/TagBuilder.cxx | 9 +++++++++ src/util/ASCII.hxx | 6 ++++++ src/util/UriUtil.cxx | 3 +++ 10 files changed, 51 insertions(+) (limited to 'src') diff --git a/src/DatabaseGlue.cxx b/src/DatabaseGlue.cxx index fb41b40b7..50deaf48e 100644 --- a/src/DatabaseGlue.cxx +++ b/src/DatabaseGlue.cxx @@ -112,7 +112,10 @@ db_get_root(void) Directory * db_get_directory(const char *name) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(name != nullptr); +#endif if (db == nullptr) return nullptr; diff --git a/src/DecoderPlugin.cxx b/src/DecoderPlugin.cxx index 77ed90882..5170555f5 100644 --- a/src/DecoderPlugin.cxx +++ b/src/DecoderPlugin.cxx @@ -26,7 +26,10 @@ bool DecoderPlugin::SupportsSuffix(const char *suffix) const { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(suffix != nullptr); +#endif return suffixes != nullptr && string_array_contains(suffixes, suffix); @@ -35,7 +38,10 @@ DecoderPlugin::SupportsSuffix(const char *suffix) const bool DecoderPlugin::SupportsMimeType(const char *mime_type) const { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(mime_type != nullptr); +#endif return mime_types != nullptr && string_array_contains(mime_types, mime_type); diff --git a/src/Directory.cxx b/src/Directory.cxx index b2942588e..238bd149c 100644 --- a/src/Directory.cxx +++ b/src/Directory.cxx @@ -40,7 +40,10 @@ extern "C" { inline Directory * Directory::Allocate(const char *path) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(path != nullptr); +#endif const size_t path_size = strlen(path) + 1; Directory *directory = diff --git a/src/InputStream.cxx b/src/InputStream.cxx index 28a0aad1a..73b581d2d 100644 --- a/src/InputStream.cxx +++ b/src/InputStream.cxx @@ -155,7 +155,10 @@ InputStream::IsAvailable() size_t InputStream::Read(void *ptr, size_t _size, Error &error) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(ptr != nullptr); +#endif assert(_size > 0); return plugin.read(this, ptr, _size, error); @@ -164,7 +167,10 @@ InputStream::Read(void *ptr, size_t _size, Error &error) size_t InputStream::LockRead(void *ptr, size_t _size, Error &error) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(ptr != nullptr); +#endif assert(_size > 0); const ScopeLock protect(mutex); diff --git a/src/SongFilter.cxx b/src/SongFilter.cxx index 235dfe7a0..01f9d8bb2 100644 --- a/src/SongFilter.cxx +++ b/src/SongFilter.cxx @@ -78,7 +78,10 @@ SongFilter::Item::Item(unsigned _tag, const char *_value, bool _fold_case) bool SongFilter::Item::StringMatch(const char *s) const { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(s != nullptr); +#endif if (fold_case) { char *p = g_utf8_casefold(s, -1); diff --git a/src/fs/Charset.cxx b/src/fs/Charset.cxx index dad5779f9..0b598ef46 100644 --- a/src/fs/Charset.cxx +++ b/src/fs/Charset.cxx @@ -79,7 +79,10 @@ GetFSCharset() std::string PathToUTF8(const char *path_fs) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(path_fs != nullptr); +#endif if (fs_charset.empty()) return std::string(path_fs); @@ -109,7 +112,10 @@ PathToUTF8(const char *path_fs) char * PathFromUTF8(const char *path_utf8) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(path_utf8 != nullptr); +#endif if (fs_charset.empty()) return g_strdup(path_utf8); diff --git a/src/fs/Traits.cxx b/src/fs/Traits.cxx index 2c3ce075b..47cb5aee3 100644 --- a/src/fs/Traits.cxx +++ b/src/fs/Traits.cxx @@ -25,7 +25,10 @@ const char * PathTraits::GetBaseUTF8(const char *p) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(p != nullptr); +#endif const char *slash = strrchr(p, SEPARATOR_UTF8); return slash != nullptr @@ -36,7 +39,10 @@ PathTraits::GetBaseUTF8(const char *p) std::string PathTraits::GetParentUTF8(const char *p) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(p != nullptr); +#endif const char *slash = strrchr(p, SEPARATOR_UTF8); return slash != nullptr diff --git a/src/tag/TagBuilder.cxx b/src/tag/TagBuilder.cxx index 25e5cc24b..083b43d69 100644 --- a/src/tag/TagBuilder.cxx +++ b/src/tag/TagBuilder.cxx @@ -77,7 +77,10 @@ TagBuilder::Commit() inline void TagBuilder::AddItemInternal(TagType type, const char *value, size_t length) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(value != nullptr); +#endif assert(length > 0); char *p = FixTagString(value, length); @@ -98,7 +101,10 @@ TagBuilder::AddItemInternal(TagType type, const char *value, size_t length) void TagBuilder::AddItem(TagType type, const char *value, size_t length) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(value != nullptr); +#endif if (length == 0 || ignore_tag_items[type]) return; @@ -109,7 +115,10 @@ TagBuilder::AddItem(TagType type, const char *value, size_t length) void TagBuilder::AddItem(TagType type, const char *value) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(value != nullptr); +#endif AddItem(type, value, strlen(value)); } diff --git a/src/util/ASCII.hxx b/src/util/ASCII.hxx index cd26d9dec..9f7147338 100644 --- a/src/util/ASCII.hxx +++ b/src/util/ASCII.hxx @@ -43,8 +43,11 @@ gcc_pure gcc_nonnull_all static inline bool StringEqualsCaseASCII(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 /* note: strcasecmp() depends on the locale, but for ASCII-only strings, it's safe to use */ @@ -55,8 +58,11 @@ gcc_pure gcc_nonnull_all static inline bool StringEqualsCaseASCII(const char *a, const char *b, size_t n) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(a != nullptr); assert(b != nullptr); +#endif /* note: strcasecmp() depends on the locale, but for ASCII-only strings, it's safe to use */ diff --git a/src/util/UriUtil.cxx b/src/util/UriUtil.cxx index 1783fbca5..6dd5a42e1 100644 --- a/src/util/UriUtil.cxx +++ b/src/util/UriUtil.cxx @@ -128,8 +128,11 @@ uri_remove_auth(const char *uri) bool uri_is_child(const char *parent, const char *child) { +#if !CLANG_CHECK_VERSION(3,6) + /* disabled on clang due to -Wtautological-pointer-compare */ assert(parent != nullptr); assert(child != nullptr); +#endif const size_t parent_length = strlen(parent); return memcmp(parent, child, parent_length) == 0 && -- cgit v1.2.3