util/{ASCII,UriUtil}, ...: work around -Wtautological-pointer-compare

New in clang 3.6.
This commit is contained in:
Max Kellermann 2014-12-26 13:40:17 +01:00
parent a5049136ff
commit 53f4044890
11 changed files with 52 additions and 0 deletions

1
NEWS
View File

@ -1,4 +1,5 @@
ver 0.18.22 (not yet released) ver 0.18.22 (not yet released)
* fix clang 3.6 warnings
ver 0.18.21 (2014/12/17) ver 0.18.21 (2014/12/17)
* playlist * playlist

View File

@ -112,7 +112,10 @@ db_get_root(void)
Directory * Directory *
db_get_directory(const char *name) db_get_directory(const char *name)
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(name != nullptr); assert(name != nullptr);
#endif
if (db == nullptr) if (db == nullptr)
return nullptr; return nullptr;

View File

@ -26,7 +26,10 @@
bool bool
DecoderPlugin::SupportsSuffix(const char *suffix) const DecoderPlugin::SupportsSuffix(const char *suffix) const
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(suffix != nullptr); assert(suffix != nullptr);
#endif
return suffixes != nullptr && string_array_contains(suffixes, suffix); return suffixes != nullptr && string_array_contains(suffixes, suffix);
@ -35,7 +38,10 @@ DecoderPlugin::SupportsSuffix(const char *suffix) const
bool bool
DecoderPlugin::SupportsMimeType(const char *mime_type) const 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); assert(mime_type != nullptr);
#endif
return mime_types != nullptr && return mime_types != nullptr &&
string_array_contains(mime_types, mime_type); string_array_contains(mime_types, mime_type);

View File

@ -40,7 +40,10 @@ extern "C" {
inline Directory * inline Directory *
Directory::Allocate(const char *path) Directory::Allocate(const char *path)
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(path != nullptr); assert(path != nullptr);
#endif
const size_t path_size = strlen(path) + 1; const size_t path_size = strlen(path) + 1;
Directory *directory = Directory *directory =

View File

@ -155,7 +155,10 @@ InputStream::IsAvailable()
size_t size_t
InputStream::Read(void *ptr, size_t _size, Error &error) 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); assert(ptr != nullptr);
#endif
assert(_size > 0); assert(_size > 0);
return plugin.read(this, ptr, _size, error); return plugin.read(this, ptr, _size, error);
@ -164,7 +167,10 @@ InputStream::Read(void *ptr, size_t _size, Error &error)
size_t size_t
InputStream::LockRead(void *ptr, size_t _size, Error &error) 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); assert(ptr != nullptr);
#endif
assert(_size > 0); assert(_size > 0);
const ScopeLock protect(mutex); const ScopeLock protect(mutex);

View File

@ -78,7 +78,10 @@ SongFilter::Item::Item(unsigned _tag, const char *_value, bool _fold_case)
bool bool
SongFilter::Item::StringMatch(const char *s) const SongFilter::Item::StringMatch(const char *s) const
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(s != nullptr); assert(s != nullptr);
#endif
if (fold_case) { if (fold_case) {
char *p = g_utf8_casefold(s, -1); char *p = g_utf8_casefold(s, -1);

View File

@ -79,7 +79,10 @@ GetFSCharset()
std::string std::string
PathToUTF8(const char *path_fs) PathToUTF8(const char *path_fs)
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(path_fs != nullptr); assert(path_fs != nullptr);
#endif
if (fs_charset.empty()) if (fs_charset.empty())
return std::string(path_fs); return std::string(path_fs);
@ -109,7 +112,10 @@ PathToUTF8(const char *path_fs)
char * char *
PathFromUTF8(const char *path_utf8) PathFromUTF8(const char *path_utf8)
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(path_utf8 != nullptr); assert(path_utf8 != nullptr);
#endif
if (fs_charset.empty()) if (fs_charset.empty())
return g_strdup(path_utf8); return g_strdup(path_utf8);

View File

@ -25,7 +25,10 @@
const char * const char *
PathTraits::GetBaseUTF8(const char *p) PathTraits::GetBaseUTF8(const char *p)
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr); assert(p != nullptr);
#endif
const char *slash = strrchr(p, SEPARATOR_UTF8); const char *slash = strrchr(p, SEPARATOR_UTF8);
return slash != nullptr return slash != nullptr
@ -36,7 +39,10 @@ PathTraits::GetBaseUTF8(const char *p)
std::string std::string
PathTraits::GetParentUTF8(const char *p) PathTraits::GetParentUTF8(const char *p)
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr); assert(p != nullptr);
#endif
const char *slash = strrchr(p, SEPARATOR_UTF8); const char *slash = strrchr(p, SEPARATOR_UTF8);
return slash != nullptr return slash != nullptr

View File

@ -77,7 +77,10 @@ TagBuilder::Commit()
inline void inline void
TagBuilder::AddItemInternal(TagType type, const char *value, size_t length) 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); assert(value != nullptr);
#endif
assert(length > 0); assert(length > 0);
char *p = FixTagString(value, length); char *p = FixTagString(value, length);
@ -98,7 +101,10 @@ TagBuilder::AddItemInternal(TagType type, const char *value, size_t length)
void void
TagBuilder::AddItem(TagType type, const char *value, size_t length) 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); assert(value != nullptr);
#endif
if (length == 0 || ignore_tag_items[type]) if (length == 0 || ignore_tag_items[type])
return; return;
@ -109,7 +115,10 @@ TagBuilder::AddItem(TagType type, const char *value, size_t length)
void void
TagBuilder::AddItem(TagType type, const char *value) TagBuilder::AddItem(TagType type, const char *value)
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(value != nullptr); assert(value != nullptr);
#endif
AddItem(type, value, strlen(value)); AddItem(type, value, strlen(value));
} }

View File

@ -43,8 +43,11 @@ gcc_pure gcc_nonnull_all
static inline bool static inline bool
StringEqualsCaseASCII(const char *a, const char *b) 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(a != nullptr);
assert(b != nullptr); assert(b != nullptr);
#endif
/* note: strcasecmp() depends on the locale, but for ASCII-only /* note: strcasecmp() depends on the locale, but for ASCII-only
strings, it's safe to use */ strings, it's safe to use */
@ -55,8 +58,11 @@ gcc_pure gcc_nonnull_all
static inline bool static inline bool
StringEqualsCaseASCII(const char *a, const char *b, size_t n) 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(a != nullptr);
assert(b != nullptr); assert(b != nullptr);
#endif
/* note: strcasecmp() depends on the locale, but for ASCII-only /* note: strcasecmp() depends on the locale, but for ASCII-only
strings, it's safe to use */ strings, it's safe to use */

View File

@ -128,8 +128,11 @@ uri_remove_auth(const char *uri)
bool bool
uri_is_child(const char *parent, const char *child) 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(parent != nullptr);
assert(child != nullptr); assert(child != nullptr);
#endif
const size_t parent_length = strlen(parent); const size_t parent_length = strlen(parent);
return memcmp(parent, child, parent_length) == 0 && return memcmp(parent, child, parent_length) == 0 &&