mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Resolve clang-tidy readability-bool-conversion warnings
... In files included by Kernel/Process.cpp and Kernel/Thread.cpp
This commit is contained in:
parent
10d0cac73c
commit
22feb9d47b
Notes:
sideshowbarker
2024-07-18 01:08:10 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/22feb9d47b9 Pull-request: https://github.com/SerenityOS/serenity/pull/10737 Reviewed-by: https://github.com/BenWiederhake Reviewed-by: https://github.com/PeterBindels-TomTom Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/dascandy Reviewed-by: https://github.com/trflynn89
12 changed files with 26 additions and 25 deletions
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
if (previous_data != nullptr) {
|
||||
__builtin_memcpy(m_data, previous_data, previous_size_bytes);
|
||||
if (previous_size % 8)
|
||||
if ((previous_size % 8) != 0)
|
||||
set_range(previous_size, 8 - previous_size % 8, default_value);
|
||||
kfree_sized(previous_data, previous_size_bytes);
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
return count;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool is_null() const { return !m_data; }
|
||||
[[nodiscard]] bool is_null() const { return m_data == nullptr; }
|
||||
|
||||
[[nodiscard]] const u8* data() const { return m_data; }
|
||||
|
||||
|
@ -279,7 +279,7 @@ public:
|
|||
size_t trailing_bits = size() % 32;
|
||||
for (size_t i = 0; i < trailing_bits; ++i) {
|
||||
if (!get(first_trailing_bit + i)) {
|
||||
if (!free_chunks)
|
||||
if (free_chunks == 0)
|
||||
*start_of_free_chunks = first_trailing_bit + i;
|
||||
if (++free_chunks >= min_length)
|
||||
return min(free_chunks, max_length);
|
||||
|
@ -313,7 +313,7 @@ public:
|
|||
}
|
||||
|
||||
found_range_size = max_region_size;
|
||||
if (max_region_size) {
|
||||
if (max_region_size != 0) {
|
||||
return max_region_start;
|
||||
}
|
||||
return {};
|
||||
|
|
|
@ -118,7 +118,7 @@ public:
|
|||
return data()[i];
|
||||
}
|
||||
|
||||
[[nodiscard]] bool is_empty() const { return !m_size; }
|
||||
[[nodiscard]] bool is_empty() const { return m_size == 0; }
|
||||
[[nodiscard]] size_t size() const { return m_size; }
|
||||
|
||||
[[nodiscard]] u8* data() { return m_inline ? m_inline_buffer : m_outline_buffer; }
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
m_size = 0;
|
||||
}
|
||||
|
||||
bool is_empty() const { return !m_size; }
|
||||
bool is_empty() const { return m_size == 0; }
|
||||
size_t size() const { return m_size; }
|
||||
|
||||
size_t capacity() const { return Capacity; }
|
||||
|
|
|
@ -181,7 +181,7 @@ public:
|
|||
swap(a.m_collection_data, b.m_collection_data);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool is_empty() const { return !m_size; }
|
||||
[[nodiscard]] bool is_empty() const { return m_size == 0; }
|
||||
[[nodiscard]] size_t size() const { return m_size; }
|
||||
[[nodiscard]] size_t capacity() const { return m_capacity; }
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
{
|
||||
if (length() != other.length())
|
||||
return false;
|
||||
return !__builtin_memcmp(characters(), other.characters(), length());
|
||||
return __builtin_memcmp(characters(), other.characters(), length()) == 0;
|
||||
}
|
||||
|
||||
unsigned hash() const
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
explicit StringView(String&&) = delete;
|
||||
explicit StringView(FlyString&&) = delete;
|
||||
|
||||
[[nodiscard]] constexpr bool is_null() const { return !m_characters; }
|
||||
[[nodiscard]] constexpr bool is_null() const { return m_characters == nullptr; }
|
||||
[[nodiscard]] constexpr bool is_empty() const { return m_length == 0; }
|
||||
|
||||
[[nodiscard]] constexpr char const* characters_without_null_termination() const { return m_characters; }
|
||||
|
@ -151,18 +151,18 @@ public:
|
|||
constexpr bool operator==(const char* cstring) const
|
||||
{
|
||||
if (is_null())
|
||||
return !cstring;
|
||||
return cstring == nullptr;
|
||||
if (!cstring)
|
||||
return false;
|
||||
// NOTE: `m_characters` is not guaranteed to be null-terminated, but `cstring` is.
|
||||
const char* cp = cstring;
|
||||
for (size_t i = 0; i < m_length; ++i) {
|
||||
if (!*cp)
|
||||
if (*cp == '\0')
|
||||
return false;
|
||||
if (m_characters[i] != *(cp++))
|
||||
return false;
|
||||
}
|
||||
return !*cp;
|
||||
return *cp == '\0';
|
||||
}
|
||||
|
||||
constexpr bool operator!=(const char* cstring) const
|
||||
|
@ -180,7 +180,7 @@ public:
|
|||
return false;
|
||||
if (length() != other.length())
|
||||
return false;
|
||||
return !__builtin_memcmp(m_characters, other.m_characters, m_length);
|
||||
return __builtin_memcmp(m_characters, other.m_characters, m_length) == 0;
|
||||
}
|
||||
|
||||
constexpr bool operator!=(StringView other) const
|
||||
|
|
|
@ -50,7 +50,7 @@ inline bool is_leap_year(int year)
|
|||
|
||||
inline int days_in_year(int year)
|
||||
{
|
||||
return 365 + is_leap_year(year);
|
||||
return 365 + (is_leap_year(year) ? 1 : 0);
|
||||
}
|
||||
|
||||
inline int years_to_days_since_epoch(int year)
|
||||
|
@ -163,7 +163,7 @@ public:
|
|||
// Rounds towards -inf (it was the easiest to implement).
|
||||
[[nodiscard]] timeval to_timeval() const;
|
||||
|
||||
[[nodiscard]] bool is_zero() const { return !m_seconds && !m_nanoseconds; }
|
||||
[[nodiscard]] bool is_zero() const { return (m_seconds == 0) && (m_nanoseconds == 0); }
|
||||
[[nodiscard]] bool is_negative() const { return m_seconds < 0; }
|
||||
|
||||
bool operator==(const Time& other) const { return this->m_seconds == other.m_seconds && this->m_nanoseconds == other.m_nanoseconds; }
|
||||
|
|
|
@ -15,7 +15,7 @@ class TypedTransfer {
|
|||
public:
|
||||
static void move(T* destination, T* source, size_t count)
|
||||
{
|
||||
if (!count)
|
||||
if (count == 0)
|
||||
return;
|
||||
|
||||
if constexpr (Traits<T>::is_trivial()) {
|
||||
|
@ -29,13 +29,11 @@ public:
|
|||
else
|
||||
new (&destination[count - i - 1]) T(std::move(source[count - i - 1]));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static size_t copy(T* destination, const T* source, size_t count)
|
||||
{
|
||||
if (!count)
|
||||
if (count == 0)
|
||||
return 0;
|
||||
|
||||
if constexpr (Traits<T>::is_trivial()) {
|
||||
|
@ -55,7 +53,7 @@ public:
|
|||
|
||||
static bool compare(const T* a, const T* b, size_t count)
|
||||
{
|
||||
if (!count)
|
||||
if (count == 0)
|
||||
return true;
|
||||
|
||||
if constexpr (Traits<T>::is_trivial())
|
||||
|
|
|
@ -20,7 +20,6 @@ class Userspace {
|
|||
public:
|
||||
Userspace() = default;
|
||||
|
||||
operator bool() const { return m_ptr; }
|
||||
operator FlatPtr() const { return (FlatPtr)m_ptr; }
|
||||
|
||||
// Disable default implementations that would use surprising integer promotion.
|
||||
|
@ -36,6 +35,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
explicit operator bool() const { return m_ptr != 0; }
|
||||
|
||||
FlatPtr ptr() const { return m_ptr; }
|
||||
T unsafe_userspace_ptr() const { return (T)m_ptr; }
|
||||
#else
|
||||
|
@ -44,6 +45,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
explicit operator bool() const { return m_ptr != nullptr; }
|
||||
|
||||
T ptr() const { return m_ptr; }
|
||||
#endif
|
||||
|
||||
|
|
|
@ -520,7 +520,7 @@ public:
|
|||
|
||||
ErrorOr<void> try_append(StorageType const* values, size_t count)
|
||||
{
|
||||
if (!count)
|
||||
if (count == 0)
|
||||
return {};
|
||||
TRY(try_grow_capacity(size() + count));
|
||||
TypedTransfer<StorageType>::copy(slot(m_size), values, count);
|
||||
|
@ -569,7 +569,7 @@ public:
|
|||
|
||||
ErrorOr<void> try_prepend(StorageType const* values, size_t count)
|
||||
{
|
||||
if (!count)
|
||||
if (count == 0)
|
||||
return {};
|
||||
TRY(try_grow_capacity(size() + count));
|
||||
TypedTransfer<StorageType>::move(slot(count), slot(0), m_size);
|
||||
|
@ -645,7 +645,7 @@ public:
|
|||
if (new_size == size())
|
||||
return;
|
||||
|
||||
if (!new_size) {
|
||||
if (new_size == 0) {
|
||||
if (keep_capacity)
|
||||
clear_with_capacity();
|
||||
else
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
|
||||
bool is_null() const
|
||||
{
|
||||
return !unsafe_ptr<void>();
|
||||
return unsafe_ptr<void>() == nullptr;
|
||||
}
|
||||
|
||||
void revoke()
|
||||
|
|
Loading…
Reference in a new issue