mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
AK: Make Vector use size_t for its size and capacity
This commit is contained in:
parent
9c6f7d3e7d
commit
ceec1a7d38
Notes:
sideshowbarker
2024-07-19 09:04:32 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/ceec1a7d38d
@ -50,10 +50,10 @@ void FileSystemPath::canonicalize()
|
||||
if (!is_absolute_path)
|
||||
parts.prepend(".");
|
||||
|
||||
int approximate_canonical_length = 0;
|
||||
size_t approximate_canonical_length = 0;
|
||||
Vector<String> canonical_parts;
|
||||
|
||||
for (int i = 0; i < parts.size(); ++i) {
|
||||
for (size_t i = 0; i < parts.size(); ++i) {
|
||||
auto& part = parts[i];
|
||||
if (is_absolute_path || i != 0) {
|
||||
if (part == ".")
|
||||
@ -75,7 +75,7 @@ void FileSystemPath::canonicalize()
|
||||
}
|
||||
|
||||
StringBuilder dirname_builder(approximate_canonical_length);
|
||||
for (int i = 0; i < canonical_parts.size() - 1; ++i) {
|
||||
for (size_t i = 0; i < canonical_parts.size() - 1; ++i) {
|
||||
auto& canonical_part = canonical_parts[i];
|
||||
if (is_absolute_path || i != 0)
|
||||
dirname_builder.append('/');
|
||||
@ -90,7 +90,7 @@ void FileSystemPath::canonicalize()
|
||||
m_extension = name_parts[1];
|
||||
|
||||
StringBuilder builder(approximate_canonical_length);
|
||||
for (int i = 0; i < canonical_parts.size(); ++i) {
|
||||
for (size_t i = 0; i < canonical_parts.size(); ++i) {
|
||||
auto& canonical_part = canonical_parts[i];
|
||||
if (is_absolute_path || i != 0)
|
||||
builder.append('/');
|
||||
|
@ -101,7 +101,7 @@ class OwnPtr;
|
||||
template<typename T>
|
||||
class WeakPtr;
|
||||
|
||||
template<typename T, int inline_capacity = 0>
|
||||
template<typename T, size_t inline_capacity = 0>
|
||||
class Vector;
|
||||
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ URL URL::complete_url(const String& string) const
|
||||
|
||||
bool document_url_ends_in_slash = path()[path().length() - 1] == '/';
|
||||
|
||||
for (int i = 0; i < fspath.parts().size(); ++i) {
|
||||
for (size_t i = 0; i < fspath.parts().size(); ++i) {
|
||||
if (i == fspath.parts().size() - 1 && !document_url_ends_in_slash)
|
||||
break;
|
||||
builder.append(fspath.parts()[i]);
|
||||
|
103
AK/Vector.h
103
AK/Vector.h
@ -28,6 +28,7 @@
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/Traits.h>
|
||||
#include <AK/kmalloc.h>
|
||||
@ -63,28 +64,28 @@ public:
|
||||
--m_index;
|
||||
return *this;
|
||||
}
|
||||
VectorIterator operator-(int value) { return { m_vector, m_index - value }; }
|
||||
VectorIterator operator+(int value) { return { m_vector, m_index + value }; }
|
||||
VectorIterator operator-(size_t value) { return { m_vector, m_index - value }; }
|
||||
VectorIterator operator+(size_t value) { return { m_vector, m_index + value }; }
|
||||
VectorIterator& operator=(const VectorIterator& other)
|
||||
{
|
||||
m_index = other.m_index;
|
||||
return *this;
|
||||
}
|
||||
ElementType& operator*() { return m_vector[m_index]; }
|
||||
int operator-(const VectorIterator& other) { return m_index - other.m_index; }
|
||||
size_t operator-(const VectorIterator& other) { return m_index - other.m_index; }
|
||||
|
||||
bool is_end() const { return m_index == m_vector.size(); }
|
||||
int index() const { return m_index; }
|
||||
size_t index() const { return m_index; }
|
||||
|
||||
private:
|
||||
friend VectorType;
|
||||
VectorIterator(VectorType& vector, int index)
|
||||
VectorIterator(VectorType& vector, size_t index)
|
||||
: m_vector(vector)
|
||||
, m_index(index)
|
||||
{
|
||||
}
|
||||
VectorType& m_vector;
|
||||
int m_index { 0 };
|
||||
size_t m_index { 0 };
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@ -130,7 +131,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, int inline_capacity>
|
||||
template<typename T, size_t inline_capacity>
|
||||
class Vector {
|
||||
public:
|
||||
Vector()
|
||||
@ -159,7 +160,7 @@ public:
|
||||
{
|
||||
if constexpr (inline_capacity > 0) {
|
||||
if (!m_outline_buffer) {
|
||||
for (int i = 0; i < m_size; ++i) {
|
||||
for (size_t i = 0; i < m_size; ++i) {
|
||||
new (&inline_buffer()[i]) T(move(other.inline_buffer()[i]));
|
||||
other.inline_buffer()[i].~T();
|
||||
}
|
||||
@ -177,7 +178,7 @@ public:
|
||||
m_size = other.size();
|
||||
}
|
||||
|
||||
template<int other_inline_capacity>
|
||||
template<size_t other_inline_capacity>
|
||||
Vector(const Vector<T, other_inline_capacity>& other)
|
||||
{
|
||||
ensure_capacity(other.size());
|
||||
@ -195,7 +196,7 @@ public:
|
||||
m_outline_buffer = other.m_outline_buffer;
|
||||
if constexpr (inline_capacity > 0) {
|
||||
if (!m_outline_buffer) {
|
||||
for (int i = 0; i < m_size; ++i) {
|
||||
for (size_t i = 0; i < m_size; ++i) {
|
||||
new (&inline_buffer()[i]) T(move(other.inline_buffer()[i]));
|
||||
other.inline_buffer()[i].~T();
|
||||
}
|
||||
@ -220,7 +221,7 @@ public:
|
||||
|
||||
void clear_with_capacity()
|
||||
{
|
||||
for (int i = 0; i < m_size; ++i)
|
||||
for (size_t i = 0; i < m_size; ++i)
|
||||
data()[i].~T();
|
||||
m_size = 0;
|
||||
}
|
||||
@ -239,7 +240,7 @@ public:
|
||||
|
||||
bool contains_slow(const T& value) const
|
||||
{
|
||||
for (int i = 0; i < size(); ++i) {
|
||||
for (size_t i = 0; i < size(); ++i) {
|
||||
if (at(i) == value)
|
||||
return true;
|
||||
}
|
||||
@ -249,8 +250,8 @@ public:
|
||||
// NOTE: Vector::is_null() exists for the benefit of String::copy().
|
||||
bool is_null() const { return false; }
|
||||
bool is_empty() const { return size() == 0; }
|
||||
int size() const { return m_size; }
|
||||
int capacity() const { return m_capacity; }
|
||||
size_t size() const { return m_size; }
|
||||
size_t capacity() const { return m_capacity; }
|
||||
|
||||
T* data()
|
||||
{
|
||||
@ -265,19 +266,19 @@ public:
|
||||
return m_outline_buffer;
|
||||
}
|
||||
|
||||
const T& at(int i) const
|
||||
const T& at(size_t i) const
|
||||
{
|
||||
ASSERT(i >= 0 && i < m_size);
|
||||
return data()[i];
|
||||
}
|
||||
T& at(int i)
|
||||
T& at(size_t i)
|
||||
{
|
||||
ASSERT(i >= 0 && i < m_size);
|
||||
return data()[i];
|
||||
}
|
||||
|
||||
const T& operator[](int i) const { return at(i); }
|
||||
T& operator[](int i) { return at(i); }
|
||||
const T& operator[](size_t i) const { return at(i); }
|
||||
T& operator[](size_t i) { return at(i); }
|
||||
|
||||
const T& first() const { return at(0); }
|
||||
T& first() { return at(0); }
|
||||
@ -302,21 +303,21 @@ public:
|
||||
return value;
|
||||
}
|
||||
|
||||
T take(int index)
|
||||
T take(size_t index)
|
||||
{
|
||||
T value = move(at(index));
|
||||
remove(index);
|
||||
return value;
|
||||
}
|
||||
|
||||
void unstable_remove(int index)
|
||||
void unstable_remove(size_t index)
|
||||
{
|
||||
ASSERT(index < m_size);
|
||||
swap(at(index), at(m_size - 1));
|
||||
take_last();
|
||||
}
|
||||
|
||||
void remove(int index)
|
||||
void remove(size_t index)
|
||||
{
|
||||
ASSERT(index < m_size);
|
||||
|
||||
@ -324,7 +325,7 @@ public:
|
||||
TypedTransfer<T>::copy(slot(index), slot(index + 1), m_size - index - 1);
|
||||
} else {
|
||||
at(index).~T();
|
||||
for (int i = index + 1; i < m_size; ++i) {
|
||||
for (size_t i = index + 1; i < m_size; ++i) {
|
||||
new (slot(i - 1)) T(move(at(i)));
|
||||
at(i).~T();
|
||||
}
|
||||
@ -333,7 +334,7 @@ public:
|
||||
--m_size;
|
||||
}
|
||||
|
||||
void insert(int index, T&& value)
|
||||
void insert(size_t index, T&& value)
|
||||
{
|
||||
ASSERT(index <= size());
|
||||
if (index == size())
|
||||
@ -343,7 +344,7 @@ public:
|
||||
if constexpr (Traits<T>::is_trivial()) {
|
||||
TypedTransfer<T>::move(slot(index + 1), slot(index), m_size - index - 1);
|
||||
} else {
|
||||
for (int i = size() - 1; i > index; --i) {
|
||||
for (size_t i = size() - 1; i > index; --i) {
|
||||
new (slot(i)) T(move(at(i - 1)));
|
||||
at(i - 1).~T();
|
||||
}
|
||||
@ -351,15 +352,15 @@ public:
|
||||
new (slot(index)) T(move(value));
|
||||
}
|
||||
|
||||
void insert(int index, const T& value)
|
||||
void insert(size_t index, const T& value)
|
||||
{
|
||||
insert(index, T(value));
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
void insert_before_matching(T&& value, C callback, int first_index = 0, int* inserted_index = nullptr)
|
||||
void insert_before_matching(T&& value, C callback, size_t first_index = 0, size_t* inserted_index = nullptr)
|
||||
{
|
||||
for (int i = first_index; i < size(); ++i) {
|
||||
for (size_t i = first_index; i < size(); ++i) {
|
||||
if (callback(at(i))) {
|
||||
insert(i, move(value));
|
||||
if (inserted_index)
|
||||
@ -383,7 +384,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<int other_inline_capacity>
|
||||
template<size_t other_inline_capacity>
|
||||
Vector& operator=(const Vector<T, other_inline_capacity>& other)
|
||||
{
|
||||
clear();
|
||||
@ -416,7 +417,7 @@ public:
|
||||
template<typename Callback>
|
||||
void remove_first_matching(Callback callback)
|
||||
{
|
||||
for (int i = 0; i < size(); ++i) {
|
||||
for (size_t i = 0; i < size(); ++i) {
|
||||
if (callback(at(i))) {
|
||||
remove(i);
|
||||
return;
|
||||
@ -427,7 +428,7 @@ public:
|
||||
template<typename Callback>
|
||||
void remove_all_matching(Callback callback)
|
||||
{
|
||||
for (int i = 0; i < size();) {
|
||||
for (size_t i = 0; i < size();) {
|
||||
if (callback(at(i))) {
|
||||
remove(i);
|
||||
} else {
|
||||
@ -491,7 +492,7 @@ public:
|
||||
auto other_size = other.size();
|
||||
grow_capacity(size() + other_size);
|
||||
|
||||
for (int i = size() + other_size - 1; i >= other.size(); --i) {
|
||||
for (size_t i = size() + other_size - 1; i >= other.size(); --i) {
|
||||
new (slot(i)) T(move(at(i - other_size)));
|
||||
at(i - other_size).~T();
|
||||
}
|
||||
@ -501,7 +502,7 @@ public:
|
||||
m_size += other_size;
|
||||
}
|
||||
|
||||
void append(const T* values, int count)
|
||||
void append(const T* values, size_t count)
|
||||
{
|
||||
if (!count)
|
||||
return;
|
||||
@ -510,24 +511,24 @@ public:
|
||||
m_size += count;
|
||||
}
|
||||
|
||||
void grow_capacity(int needed_capacity)
|
||||
void grow_capacity(size_t needed_capacity)
|
||||
{
|
||||
if (m_capacity >= needed_capacity)
|
||||
return;
|
||||
ensure_capacity(padded_capacity(needed_capacity));
|
||||
}
|
||||
|
||||
void ensure_capacity(int needed_capacity)
|
||||
void ensure_capacity(size_t needed_capacity)
|
||||
{
|
||||
if (m_capacity >= needed_capacity)
|
||||
return;
|
||||
int new_capacity = needed_capacity;
|
||||
size_t new_capacity = needed_capacity;
|
||||
auto* new_buffer = (T*)kmalloc(new_capacity * sizeof(T));
|
||||
|
||||
if constexpr (Traits<T>::is_trivial()) {
|
||||
TypedTransfer<T>::copy(new_buffer, data(), m_size);
|
||||
} else {
|
||||
for (int i = 0; i < m_size; ++i) {
|
||||
for (size_t i = 0; i < m_size; ++i) {
|
||||
new (&new_buffer[i]) T(move(at(i)));
|
||||
at(i).~T();
|
||||
}
|
||||
@ -538,7 +539,7 @@ public:
|
||||
m_capacity = new_capacity;
|
||||
}
|
||||
|
||||
void shrink(int new_size)
|
||||
void shrink(size_t new_size)
|
||||
{
|
||||
ASSERT(new_size <= size());
|
||||
if (new_size == size())
|
||||
@ -549,18 +550,18 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = new_size; i < size(); ++i)
|
||||
for (size_t i = new_size; i < size(); ++i)
|
||||
at(i).~T();
|
||||
m_size = new_size;
|
||||
}
|
||||
|
||||
void resize(int new_size)
|
||||
void resize(size_t new_size)
|
||||
{
|
||||
if (new_size <= size())
|
||||
return shrink(new_size);
|
||||
|
||||
ensure_capacity(new_size);
|
||||
for (int i = size(); i < new_size; ++i)
|
||||
for (size_t i = size(); i < new_size; ++i)
|
||||
new (slot(i)) T;
|
||||
m_size = new_size;
|
||||
}
|
||||
@ -576,7 +577,7 @@ public:
|
||||
template<typename Finder>
|
||||
ConstIterator find(Finder finder) const
|
||||
{
|
||||
for (int i = 0; i < m_size; ++i) {
|
||||
for (size_t i = 0; i < m_size; ++i) {
|
||||
if (finder(at(i)))
|
||||
return ConstIterator(*this, i);
|
||||
}
|
||||
@ -586,7 +587,7 @@ public:
|
||||
template<typename Finder>
|
||||
Iterator find(Finder finder)
|
||||
{
|
||||
for (int i = 0; i < m_size; ++i) {
|
||||
for (size_t i = 0; i < m_size; ++i) {
|
||||
if (finder(at(i)))
|
||||
return Iterator(*this, i);
|
||||
}
|
||||
@ -603,13 +604,13 @@ public:
|
||||
return find([&](auto& other) { return value == other; });
|
||||
}
|
||||
|
||||
int find_first_index(const T& value)
|
||||
Optional<size_t> find_first_index(const T& value)
|
||||
{
|
||||
for (int i = 0; i < m_size; ++i) {
|
||||
for (size_t i = 0; i < m_size; ++i) {
|
||||
if (value == at(i))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
return {};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -618,13 +619,13 @@ private:
|
||||
m_capacity = inline_capacity;
|
||||
}
|
||||
|
||||
static int padded_capacity(int capacity)
|
||||
static size_t padded_capacity(size_t capacity)
|
||||
{
|
||||
return max(int(4), capacity + (capacity / 4) + 4);
|
||||
return max(static_cast<size_t>(4), capacity + (capacity / 4) + 4);
|
||||
}
|
||||
|
||||
T* slot(int i) { return &data()[i]; }
|
||||
const T* slot(int i) const { return &data()[i]; }
|
||||
T* slot(size_t i) { return &data()[i]; }
|
||||
const T* slot(size_t i) const { return &data()[i]; }
|
||||
|
||||
T* inline_buffer()
|
||||
{
|
||||
@ -637,8 +638,8 @@ private:
|
||||
return reinterpret_cast<const T*>(m_inline_buffer_storage);
|
||||
}
|
||||
|
||||
int m_size { 0 };
|
||||
int m_capacity { 0 };
|
||||
size_t m_size { 0 };
|
||||
size_t m_capacity { 0 };
|
||||
|
||||
alignas(T) u8 m_inline_buffer_storage[sizeof(T) * inline_capacity];
|
||||
T* m_outline_buffer { nullptr };
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
void go_forward();
|
||||
|
||||
bool can_go_back() { return m_current > 0; }
|
||||
bool can_go_forward() { return m_current + 1 < m_items.size(); }
|
||||
bool can_go_forward() { return m_current + 1 < static_cast<int>(m_items.size()); }
|
||||
|
||||
void clear();
|
||||
|
||||
|
@ -138,7 +138,8 @@ void DisplayPropertiesWidget::create_frame()
|
||||
|
||||
auto wallpaper_model = wallpaper_list->model();
|
||||
auto find_first_wallpaper_index = m_wallpapers.find_first_index(m_selected_wallpaper);
|
||||
auto wallpaper_index_in_model = wallpaper_model->index(find_first_wallpaper_index, wallpaper_list->model_column());
|
||||
ASSERT(find_first_wallpaper_index.has_value());
|
||||
auto wallpaper_index_in_model = wallpaper_model->index(find_first_wallpaper_index.value(), wallpaper_list->model_column());
|
||||
if (wallpaper_model->is_valid(wallpaper_index_in_model))
|
||||
wallpaper_list->selection().set(wallpaper_index_in_model);
|
||||
|
||||
@ -164,7 +165,8 @@ void DisplayPropertiesWidget::create_frame()
|
||||
|
||||
auto resolution_model = resolution_list->model();
|
||||
auto find_first_resolution_index = m_resolutions.find_first_index(m_selected_resolution);
|
||||
auto resolution_index_in_model = resolution_model->index(find_first_resolution_index, resolution_list->model_column());
|
||||
ASSERT(find_first_resolution_index.has_value());
|
||||
auto resolution_index_in_model = resolution_model->index(find_first_resolution_index.value(), resolution_list->model_column());
|
||||
if (resolution_model->is_valid(resolution_index_in_model))
|
||||
resolution_list->selection().set(resolution_index_in_model);
|
||||
|
||||
|
@ -101,7 +101,7 @@ private:
|
||||
ViewMode m_view_mode { Invalid };
|
||||
|
||||
NonnullRefPtr<GUI::FileSystemModel> m_model;
|
||||
int m_path_history_position { 0 };
|
||||
size_t m_path_history_position { 0 };
|
||||
Vector<String> m_path_history;
|
||||
void add_path_to_history(const StringView& path);
|
||||
|
||||
|
@ -182,7 +182,7 @@ String get_duplicate_name(const String& path, int duplicate_count)
|
||||
FileSystemPath fsp(path);
|
||||
StringBuilder duplicated_name;
|
||||
duplicated_name.append('/');
|
||||
for (int i = 0; i < fsp.parts().size() - 1; ++i) {
|
||||
for (size_t i = 0; i < fsp.parts().size() - 1; ++i) {
|
||||
duplicated_name.appendf("%s/", fsp.parts()[i].characters());
|
||||
}
|
||||
auto prev_duplicate_tag = String::format("(%d)", duplicate_count);
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
void go_forward();
|
||||
|
||||
bool can_go_back() { return m_current_history_item > 0; }
|
||||
bool can_go_forward() { return m_current_history_item + 1 < m_items.size(); }
|
||||
bool can_go_forward() { return m_current_history_item + 1 < static_cast<int>(m_items.size()); }
|
||||
|
||||
void clear();
|
||||
|
||||
|
@ -94,7 +94,7 @@ GUI::ModelIndex ManualModel::parent_index(const GUI::ModelIndex& index) const
|
||||
return create_index(row, 0, parent);
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
for (int row = 0; row < parent->parent()->children().size(); row++) {
|
||||
for (size_t row = 0; row < parent->parent()->children().size(); row++) {
|
||||
ManualNode* child_at_row = &parent->parent()->children()[row];
|
||||
if (child_at_row == parent)
|
||||
return create_index(row, 0, parent);
|
||||
|
@ -241,7 +241,7 @@ void IRCClient::send_whois(const String& nick)
|
||||
void IRCClient::handle(const Message& msg)
|
||||
{
|
||||
#ifdef IRC_DEBUG
|
||||
printf("IRCClient::execute: prefix='%s', command='%s', arguments=%d\n",
|
||||
printf("IRCClient::execute: prefix='%s', command='%s', arguments=%zu\n",
|
||||
msg.prefix.characters(),
|
||||
msg.command.characters(),
|
||||
msg.arguments.size());
|
||||
@ -463,7 +463,7 @@ IRCChannel& IRCClient::ensure_channel(const String& name)
|
||||
|
||||
void IRCClient::handle_ping(const Message& msg)
|
||||
{
|
||||
if (msg.arguments.size() < 0)
|
||||
if (msg.arguments.size() < 1)
|
||||
return;
|
||||
m_log->add_message(0, "", "Ping? Pong!");
|
||||
send_pong(msg.arguments[0]);
|
||||
@ -646,7 +646,7 @@ void IRCClient::unregister_subwindow(IRCWindow& subwindow)
|
||||
if (subwindow.type() == IRCWindow::Server) {
|
||||
m_server_subwindow = &subwindow;
|
||||
}
|
||||
for (int i = 0; i < m_windows.size(); ++i) {
|
||||
for (size_t i = 0; i < m_windows.size(); ++i) {
|
||||
if (m_windows.at(i) == &subwindow) {
|
||||
m_windows.remove(i);
|
||||
break;
|
||||
|
@ -84,13 +84,13 @@ public:
|
||||
const IRCWindow& window_at(int index) const { return *m_windows.at(index); }
|
||||
IRCWindow& window_at(int index) { return *m_windows.at(index); }
|
||||
|
||||
int window_index(const IRCWindow& window) const
|
||||
size_t window_index(const IRCWindow& window) const
|
||||
{
|
||||
for (int i = 0; i < m_windows.size(); ++i) {
|
||||
for (size_t i = 0; i < m_windows.size(); ++i) {
|
||||
if (m_windows[i] == &window)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
void did_part_from_channel(Badge<IRCChannel>, IRCChannel&);
|
||||
|
@ -226,11 +226,11 @@ Audio::Sample AudioEngine::noise() const
|
||||
Audio::Sample AudioEngine::recorded_sample(size_t note)
|
||||
{
|
||||
int t = m_pos[note];
|
||||
if (t >= m_recorded_sample.size())
|
||||
if (t >= static_cast<int>(m_recorded_sample.size()))
|
||||
return 0;
|
||||
double w_left = m_recorded_sample[t].left;
|
||||
double w_right = m_recorded_sample[t].right;
|
||||
if (t + 1 < m_recorded_sample.size()) {
|
||||
if (t + 1 < static_cast<int>(m_recorded_sample.size())) {
|
||||
double t_fraction = m_pos[note] - t;
|
||||
w_left += (m_recorded_sample[t + 1].left - m_recorded_sample[t].left) * t_fraction;
|
||||
w_right += (m_recorded_sample[t + 1].right - m_recorded_sample[t].right) * t_fraction;
|
||||
|
@ -70,7 +70,7 @@ void WaveEditor::paint_event(GUI::PaintEvent& event)
|
||||
painter.set_pixel({ prev_x, left_prev_y }, left_wave_colors[RecordedSample]);
|
||||
painter.set_pixel({ prev_x, right_prev_y }, right_wave_colors[RecordedSample]);
|
||||
|
||||
for (int x = 1; x < recorded_sample.size(); ++x) {
|
||||
for (size_t x = 1; x < recorded_sample.size(); ++x) {
|
||||
int left_y = sample_to_y(recorded_sample[x].left);
|
||||
int right_y = sample_to_y(recorded_sample[x].right);
|
||||
|
||||
|
@ -62,8 +62,8 @@ private:
|
||||
void remove_dead_buffers();
|
||||
|
||||
bool m_paused { true };
|
||||
int m_next_ptr { 0 };
|
||||
int m_last_seek { 0 };
|
||||
size_t m_next_ptr { 0 };
|
||||
size_t m_last_seek { 0 };
|
||||
float m_total_length { 0 };
|
||||
OwnPtr<Audio::WavLoader> m_loader { nullptr };
|
||||
NonnullRefPtr<Audio::ClientConnection> m_connection;
|
||||
|
@ -62,7 +62,7 @@ Vector<char const*> PowerDialog::show()
|
||||
PowerDialog::PowerDialog()
|
||||
: GUI::Dialog(nullptr)
|
||||
{
|
||||
Gfx::Rect rect({ 0, 0, 180, 180 + ((options.size() - 3) * 16) });
|
||||
Gfx::Rect rect({ 0, 0, 180, 180 + ((static_cast<int>(options.size()) - 3) * 16) });
|
||||
rect.center_within(GUI::Desktop::the().rect());
|
||||
set_rect(rect);
|
||||
set_resizable(false);
|
||||
@ -83,7 +83,7 @@ PowerDialog::PowerDialog()
|
||||
header->set_font(Gfx::Font::default_bold_font());
|
||||
|
||||
int selected = -1;
|
||||
for (int i = 0; i < options.size(); i++) {
|
||||
for (size_t i = 0; i < options.size(); i++) {
|
||||
auto action = options[i];
|
||||
auto radio = main->add<GUI::RadioButton>();
|
||||
radio->set_enabled(action.enabled);
|
||||
|
@ -62,7 +62,7 @@ void TextWidget::paint_event(GUI::PaintEvent& event)
|
||||
if (frame_thickness() > 0)
|
||||
indent = font().glyph_width('x') / 2;
|
||||
|
||||
for (int i = 0; i < m_lines.size(); i++) {
|
||||
for (size_t i = 0; i < m_lines.size(); i++) {
|
||||
auto& line = m_lines[i];
|
||||
|
||||
auto text_rect = frame_inner_rect();
|
||||
|
@ -146,7 +146,7 @@ public:
|
||||
return {};
|
||||
}
|
||||
|
||||
for (int row = 0; row < node.parent->parent->children.size(); ++row) {
|
||||
for (size_t row = 0; row < node.parent->parent->children.size(); ++row) {
|
||||
if (node.parent->parent->children[row].ptr() == node.parent)
|
||||
return create_index(row, 0, node.parent);
|
||||
}
|
||||
@ -260,7 +260,7 @@ void Project::rebuild_tree()
|
||||
ProjectTreeNode* current = root.ptr();
|
||||
StringBuilder partial_path;
|
||||
|
||||
for (int i = 0; i < path.parts().size(); ++i) {
|
||||
for (size_t i = 0; i < path.parts().size(); ++i) {
|
||||
auto& part = path.parts().at(i);
|
||||
if (part == ".")
|
||||
continue;
|
||||
|
@ -143,7 +143,7 @@ void TerminalWrapper::run_command(const String& command)
|
||||
auto parts = command.split(' ');
|
||||
ASSERT(!parts.is_empty());
|
||||
const char** args = (const char**) calloc(parts.size() + 1, sizeof(const char*));
|
||||
for (int i = 0; i < parts.size(); i++) {
|
||||
for (size_t i = 0; i < parts.size(); i++) {
|
||||
args[i] = parts[i].characters();
|
||||
}
|
||||
rc = execvp(args[0], const_cast<char**>(args));
|
||||
|
@ -358,7 +358,7 @@ int main(int argc, char** argv)
|
||||
wrappers.append(&child);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
for (int i = 0; i < wrappers.size(); ++i) {
|
||||
for (size_t i = 0; i < wrappers.size(); ++i) {
|
||||
if (g_current_editor_wrapper.ptr() == wrappers[i]) {
|
||||
if (i == wrappers.size() - 1)
|
||||
wrappers[0]->editor().set_focus(true);
|
||||
|
@ -263,7 +263,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
builder.append('(');
|
||||
for (int i = 0; i < parameters.size(); ++i) {
|
||||
for (size_t i = 0; i < parameters.size(); ++i) {
|
||||
auto& parameter = parameters[i];
|
||||
builder.append("const ");
|
||||
builder.append(parameter.type);
|
||||
@ -273,7 +273,7 @@ int main(int argc, char** argv)
|
||||
builder.append(", ");
|
||||
}
|
||||
builder.append(") : ");
|
||||
for (int i = 0; i < parameters.size(); ++i) {
|
||||
for (size_t i = 0; i < parameters.size(); ++i) {
|
||||
auto& parameter = parameters[i];
|
||||
builder.append("m_");
|
||||
builder.append(parameter.name);
|
||||
@ -310,9 +310,9 @@ int main(int argc, char** argv)
|
||||
dbg() << " " << parameter.type << " " << parameter.name << " = " << initial_value << ";";
|
||||
|
||||
if (parameter.type == "Vector<Gfx::Rect>") {
|
||||
dbg() << " int " << parameter.name << "_size = 0;";
|
||||
dbg() << " u64 " << parameter.name << "_size = 0;";
|
||||
dbg() << " stream >> " << parameter.name << "_size;";
|
||||
dbg() << " for (int i = 0; i < " << parameter.name << "_size; ++i) {";
|
||||
dbg() << " for (size_t i = 0; i < " << parameter.name << "_size; ++i) {";
|
||||
dbg() << " Gfx::Rect rect;";
|
||||
dbg() << " if (!decoder.decode(rect))";
|
||||
dbg() << " return nullptr;";
|
||||
@ -325,7 +325,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
StringBuilder builder;
|
||||
for (int i = 0; i < parameters.size(); ++i) {
|
||||
for (size_t i = 0; i < parameters.size(); ++i) {
|
||||
auto& parameter = parameters[i];
|
||||
builder.append(parameter.name);
|
||||
if (i != parameters.size() - 1)
|
||||
@ -355,7 +355,7 @@ int main(int argc, char** argv)
|
||||
dbg() << " stream << m_" << parameter.name << ".width();";
|
||||
dbg() << " stream << m_" << parameter.name << ".height();";
|
||||
} else if (parameter.type == "Vector<Gfx::Rect>") {
|
||||
dbg() << " stream << m_" << parameter.name << ".size();";
|
||||
dbg() << " stream << (u64)m_" << parameter.name << ".size();";
|
||||
dbg() << " for (auto& rect : m_" << parameter.name << ") {";
|
||||
dbg() << " stream << rect.x();";
|
||||
dbg() << " stream << rect.y();";
|
||||
|
@ -64,7 +64,7 @@ GUI::ModelIndex RemoteObjectGraphModel::parent_index(const GUI::ModelIndex& inde
|
||||
|
||||
// NOTE: If the parent has no parent, it's a root, so we have to look among the remote roots.
|
||||
if (!remote_object.parent->parent) {
|
||||
for (int row = 0; row < m_process.roots().size(); ++row) {
|
||||
for (size_t row = 0; row < m_process.roots().size(); ++row) {
|
||||
if (&m_process.roots()[row] == remote_object.parent)
|
||||
return create_index(row, 0, remote_object.parent);
|
||||
}
|
||||
@ -72,7 +72,7 @@ GUI::ModelIndex RemoteObjectGraphModel::parent_index(const GUI::ModelIndex& inde
|
||||
return {};
|
||||
}
|
||||
|
||||
for (int row = 0; row < remote_object.parent->parent->children.size(); ++row) {
|
||||
for (size_t row = 0; row < remote_object.parent->parent->children.size(); ++row) {
|
||||
if (&remote_object.parent->parent->children[row] == remote_object.parent)
|
||||
return create_index(row, 0, remote_object.parent);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ void RemoteProcess::handle_get_all_objects_response(const JsonObject& response)
|
||||
remote_objects.append(move(remote_object));
|
||||
}
|
||||
|
||||
for (int i = 0; i < remote_objects.size(); ++i) {
|
||||
for (size_t i = 0; i < remote_objects.size(); ++i) {
|
||||
auto& remote_object = remote_objects.ptr_at(i);
|
||||
auto* parent = objects_by_address.get(remote_object->parent_address).value_or(nullptr);
|
||||
if (!parent) {
|
||||
|
@ -108,7 +108,7 @@ void Profile::rebuild_tree()
|
||||
Vector<NonnullRefPtr<ProfileNode>> roots;
|
||||
|
||||
auto find_or_create_root = [&roots](const String& symbol, u32 address, u32 offset, u64 timestamp) -> ProfileNode& {
|
||||
for (int i = 0; i < roots.size(); ++i) {
|
||||
for (size_t i = 0; i < roots.size(); ++i) {
|
||||
auto& root = roots[i];
|
||||
if (root->symbol() == symbol) {
|
||||
return root;
|
||||
@ -152,12 +152,12 @@ void Profile::rebuild_tree()
|
||||
auto for_each_frame = [&]<typename Callback>(Callback callback)
|
||||
{
|
||||
if (!m_inverted) {
|
||||
for (int i = 0; i < sample.frames.size(); ++i) {
|
||||
for (size_t i = 0; i < sample.frames.size(); ++i) {
|
||||
if (callback(sample.frames.at(i)) == IterationDecision::Break)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
for (int i = sample.frames.size() - 1; i >= 0; --i) {
|
||||
for (size_t i = sample.frames.size() - 1; i >= 0; --i) {
|
||||
if (callback(sample.frames.at(i)) == IterationDecision::Break)
|
||||
break;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
|
||||
ProfileNode& find_or_create_child(const String& symbol, u32 address, u32 offset, u64 timestamp)
|
||||
{
|
||||
for (int i = 0; i < m_children.size(); ++i) {
|
||||
for (size_t i = 0; i < m_children.size(); ++i) {
|
||||
auto& child = m_children[i];
|
||||
if (child->symbol() == symbol) {
|
||||
return child;
|
||||
|
@ -62,7 +62,7 @@ GUI::ModelIndex ProfileModel::parent_index(const GUI::ModelIndex& index) const
|
||||
|
||||
// NOTE: If the parent has no parent, it's a root, so we have to look among the roots.
|
||||
if (!node.parent()->parent()) {
|
||||
for (int row = 0; row < m_profile.roots().size(); ++row) {
|
||||
for (size_t row = 0; row < m_profile.roots().size(); ++row) {
|
||||
if (m_profile.roots()[row].ptr() == node.parent()) {
|
||||
return create_index(row, index.column(), node.parent());
|
||||
}
|
||||
@ -71,7 +71,7 @@ GUI::ModelIndex ProfileModel::parent_index(const GUI::ModelIndex& index) const
|
||||
return {};
|
||||
}
|
||||
|
||||
for (int row = 0; row < node.parent()->parent()->children().size(); ++row) {
|
||||
for (size_t row = 0; row < node.parent()->parent()->children().size(); ++row) {
|
||||
if (node.parent()->parent()->children()[row].ptr() == node.parent())
|
||||
return create_index(row, index.column(), node.parent());
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ void VBForm::keydown_event(GUI::KeyEvent& event)
|
||||
update();
|
||||
return;
|
||||
}
|
||||
int selected_widget_index = 0;
|
||||
size_t selected_widget_index = 0;
|
||||
for (; selected_widget_index < m_widgets.size(); ++selected_widget_index) {
|
||||
if (&m_widgets[selected_widget_index] == *m_selected_widgets.begin())
|
||||
break;
|
||||
|
@ -183,8 +183,8 @@ void Field::set_face(Face face)
|
||||
template<typename Callback>
|
||||
void Square::for_each_neighbor(Callback callback)
|
||||
{
|
||||
int r = row;
|
||||
int c = column;
|
||||
size_t r = row;
|
||||
size_t c = column;
|
||||
if (r > 0) // Up
|
||||
callback(field->square(r - 1, c));
|
||||
if (c > 0) // Left
|
||||
@ -217,7 +217,7 @@ void Field::reset()
|
||||
|
||||
m_squares.resize(max(m_squares.size(), rows() * columns()));
|
||||
|
||||
for (int i = rows() * columns(); i < m_squares.size(); ++i) {
|
||||
for (int i = rows() * columns(); i < static_cast<int>(m_squares.size()); ++i) {
|
||||
auto& square = m_squares[i];
|
||||
square->button->set_visible(false);
|
||||
square->label->set_visible(false);
|
||||
@ -230,12 +230,12 @@ void Field::reset()
|
||||
mines.set(location);
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (int r = 0; r < rows(); ++r) {
|
||||
for (int c = 0; c < columns(); ++c) {
|
||||
size_t i = 0;
|
||||
for (size_t r = 0; r < rows(); ++r) {
|
||||
for (size_t c = 0; c < columns(); ++c) {
|
||||
if (!m_squares[i])
|
||||
m_squares[i] = make<Square>();
|
||||
Gfx::Rect rect = { frame_thickness() + c * square_size(), frame_thickness() + r * square_size(), square_size(), square_size() };
|
||||
Gfx::Rect rect = { frame_thickness() + static_cast<int>(c) * square_size(), frame_thickness() + static_cast<int>(r) * square_size(), square_size(), square_size() };
|
||||
auto& square = this->square(r, c);
|
||||
square.field = this;
|
||||
square.row = r;
|
||||
@ -276,10 +276,10 @@ void Field::reset()
|
||||
}
|
||||
}
|
||||
|
||||
for (int r = 0; r < rows(); ++r) {
|
||||
for (int c = 0; c < columns(); ++c) {
|
||||
for (size_t r = 0; r < rows(); ++r) {
|
||||
for (size_t c = 0; c < columns(); ++c) {
|
||||
auto& square = this->square(r, c);
|
||||
int number = 0;
|
||||
size_t number = 0;
|
||||
square.for_each_neighbor([&number](auto& neighbor) {
|
||||
number += neighbor.has_mine;
|
||||
});
|
||||
@ -380,7 +380,7 @@ void Field::on_square_chorded(Square& square)
|
||||
return;
|
||||
if (!square.number)
|
||||
return;
|
||||
int adjacent_flags = 0;
|
||||
size_t adjacent_flags = 0;
|
||||
square.for_each_neighbor([&](auto& neighbor) {
|
||||
if (neighbor.has_flag)
|
||||
++adjacent_flags;
|
||||
@ -461,8 +461,8 @@ void Field::game_over()
|
||||
|
||||
void Field::reveal_mines()
|
||||
{
|
||||
for (int r = 0; r < rows(); ++r) {
|
||||
for (int c = 0; c < columns(); ++c) {
|
||||
for (size_t r = 0; r < rows(); ++r) {
|
||||
for (size_t c = 0; c < columns(); ++c) {
|
||||
auto& square = this->square(r, c);
|
||||
if (square.has_mine && !square.has_flag) {
|
||||
square.button->set_visible(false);
|
||||
@ -490,7 +490,7 @@ void Field::set_chord_preview(Square& square, bool chord_preview)
|
||||
});
|
||||
}
|
||||
|
||||
void Field::set_field_size(int rows, int columns, size_t mine_count)
|
||||
void Field::set_field_size(size_t rows, size_t columns, size_t mine_count)
|
||||
{
|
||||
if (m_rows == rows && m_columns == columns && m_mine_count == mine_count)
|
||||
return;
|
||||
@ -526,6 +526,6 @@ Square::~Square()
|
||||
template<typename Callback>
|
||||
void Field::for_each_square(Callback callback)
|
||||
{
|
||||
for (int i = 0; i < rows() * columns(); ++i)
|
||||
for (size_t i = 0; i < rows() * columns(); ++i)
|
||||
callback(*m_squares[i]);
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ public:
|
||||
bool has_mine { false };
|
||||
bool has_flag { false };
|
||||
bool is_considering { false };
|
||||
int row { 0 };
|
||||
int column { 0 };
|
||||
int number { 0 };
|
||||
size_t row { 0 };
|
||||
size_t column { 0 };
|
||||
size_t number { 0 };
|
||||
RefPtr<SquareButton> button;
|
||||
RefPtr<SquareLabel> label;
|
||||
|
||||
@ -63,13 +63,13 @@ public:
|
||||
Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function<void(Gfx::Size)> on_size_changed);
|
||||
virtual ~Field() override;
|
||||
|
||||
int rows() const { return m_rows; }
|
||||
int columns() const { return m_columns; }
|
||||
size_t rows() const { return m_rows; }
|
||||
size_t columns() const { return m_columns; }
|
||||
size_t mine_count() const { return m_mine_count; }
|
||||
int square_size() const { return 15; }
|
||||
bool is_single_chording() const { return m_single_chording; }
|
||||
|
||||
void set_field_size(int rows, int columns, size_t mine_count);
|
||||
void set_field_size(size_t rows, size_t columns, size_t mine_count);
|
||||
void set_single_chording(bool new_val);
|
||||
|
||||
void reset();
|
||||
@ -87,8 +87,8 @@ private:
|
||||
void set_chord_preview(Square&, bool);
|
||||
void set_flag(Square&, bool);
|
||||
|
||||
Square& square(int row, int column) { return *m_squares[row * columns() + column]; }
|
||||
const Square& square(int row, int column) const { return *m_squares[row * columns() + column]; }
|
||||
Square& square(size_t row, size_t column) { return *m_squares[row * columns() + column]; }
|
||||
const Square& square(size_t row, size_t column) const { return *m_squares[row * columns() + column]; }
|
||||
|
||||
void flood_fill(Square&);
|
||||
void on_square_clicked_impl(Square&, bool);
|
||||
@ -103,10 +103,10 @@ private:
|
||||
};
|
||||
void set_face(Face);
|
||||
|
||||
int m_rows { 0 };
|
||||
int m_columns { 0 };
|
||||
size_t m_rows { 0 };
|
||||
size_t m_columns { 0 };
|
||||
size_t m_mine_count { 0 };
|
||||
int m_unswept_empties { 0 };
|
||||
size_t m_unswept_empties { 0 };
|
||||
Vector<OwnPtr<Square>> m_squares;
|
||||
RefPtr<Gfx::Bitmap> m_mine_bitmap;
|
||||
RefPtr<Gfx::Bitmap> m_flag_bitmap;
|
||||
@ -120,8 +120,8 @@ private:
|
||||
GUI::Label& m_flag_label;
|
||||
GUI::Label& m_time_label;
|
||||
RefPtr<Core::Timer> m_timer;
|
||||
int m_time_elapsed { 0 };
|
||||
int m_flags_left { 0 };
|
||||
size_t m_time_elapsed { 0 };
|
||||
size_t m_flags_left { 0 };
|
||||
Face m_face { Face::Default };
|
||||
bool m_chord_preview { false };
|
||||
bool m_first_click { true };
|
||||
|
@ -66,7 +66,7 @@ void SnakeGame::reset()
|
||||
|
||||
bool SnakeGame::is_available(const Coordinate& coord)
|
||||
{
|
||||
for (int i = 0; i < m_tail.size(); ++i) {
|
||||
for (size_t i = 0; i < m_tail.size(); ++i) {
|
||||
if (m_tail[i] == coord)
|
||||
return false;
|
||||
}
|
||||
@ -134,7 +134,7 @@ void SnakeGame::timer_event(Core::TimerEvent&)
|
||||
|
||||
dirty_cells.append(m_head);
|
||||
|
||||
for (int i = 0; i < m_tail.size(); ++i) {
|
||||
for (size_t i = 0; i < m_tail.size(); ++i) {
|
||||
if (m_head == m_tail[i]) {
|
||||
game_over();
|
||||
return;
|
||||
|
@ -81,7 +81,7 @@ private:
|
||||
Coordinate m_fruit;
|
||||
int m_fruit_type { 0 };
|
||||
|
||||
int m_length { 0 };
|
||||
size_t m_length { 0 };
|
||||
unsigned m_score { 0 };
|
||||
String m_score_text;
|
||||
unsigned m_high_score { 0 };
|
||||
|
@ -668,15 +668,15 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, u8* buffer, FileDes
|
||||
|
||||
const int block_size = fs().block_size();
|
||||
|
||||
int first_block_logical_index = offset / block_size;
|
||||
int last_block_logical_index = (offset + count) / block_size;
|
||||
size_t first_block_logical_index = offset / block_size;
|
||||
size_t last_block_logical_index = (offset + count) / block_size;
|
||||
if (last_block_logical_index >= m_block_list.size())
|
||||
last_block_logical_index = m_block_list.size() - 1;
|
||||
|
||||
int offset_into_first_block = offset % block_size;
|
||||
|
||||
ssize_t nread = 0;
|
||||
int remaining_count = min((off_t)count, (off_t)size() - offset);
|
||||
size_t remaining_count = min((off_t)count, (off_t)size() - offset);
|
||||
u8* out = buffer;
|
||||
|
||||
#ifdef EXT2_DEBUG
|
||||
@ -685,7 +685,7 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, u8* buffer, FileDes
|
||||
|
||||
u8 block[max_block_size];
|
||||
|
||||
for (int bi = first_block_logical_index; remaining_count && bi <= last_block_logical_index; ++bi) {
|
||||
for (size_t bi = first_block_logical_index; remaining_count && bi <= last_block_logical_index; ++bi) {
|
||||
auto block_index = m_block_list[bi];
|
||||
ASSERT(block_index);
|
||||
bool success = fs().read_block(block_index, block, description);
|
||||
@ -694,8 +694,8 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, u8* buffer, FileDes
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
int offset_into_block = (bi == first_block_logical_index) ? offset_into_first_block : 0;
|
||||
int num_bytes_to_copy = min(block_size - offset_into_block, remaining_count);
|
||||
size_t offset_into_block = (bi == first_block_logical_index) ? offset_into_first_block : 0;
|
||||
size_t num_bytes_to_copy = min(block_size - offset_into_block, remaining_count);
|
||||
memcpy(out, block + offset_into_block, num_bytes_to_copy);
|
||||
remaining_count -= num_bytes_to_copy;
|
||||
nread += num_bytes_to_copy;
|
||||
@ -712,8 +712,8 @@ KResult Ext2FSInode::resize(u64 new_size)
|
||||
return KSuccess;
|
||||
|
||||
u64 block_size = fs().block_size();
|
||||
int blocks_needed_before = ceil_div(old_size, block_size);
|
||||
int blocks_needed_after = ceil_div(new_size, block_size);
|
||||
size_t blocks_needed_before = ceil_div(old_size, block_size);
|
||||
size_t blocks_needed_after = ceil_div(new_size, block_size);
|
||||
|
||||
#ifdef EXT2_DEBUG
|
||||
dbgprintf("Ext2FSInode::resize(): blocks needed before (size was %Q): %d\n", old_size, blocks_needed_before);
|
||||
@ -777,7 +777,7 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const u8* data, Fi
|
||||
}
|
||||
}
|
||||
|
||||
const ssize_t block_size = fs().block_size();
|
||||
const size_t block_size = fs().block_size();
|
||||
u64 old_size = size();
|
||||
u64 new_size = max(static_cast<u64>(offset) + count, (u64)size());
|
||||
|
||||
@ -793,17 +793,17 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const u8* data, Fi
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
int first_block_logical_index = offset / block_size;
|
||||
int last_block_logical_index = (offset + count) / block_size;
|
||||
size_t first_block_logical_index = offset / block_size;
|
||||
size_t last_block_logical_index = (offset + count) / block_size;
|
||||
if (last_block_logical_index >= m_block_list.size())
|
||||
last_block_logical_index = m_block_list.size() - 1;
|
||||
|
||||
int offset_into_first_block = offset % block_size;
|
||||
size_t offset_into_first_block = offset % block_size;
|
||||
|
||||
int last_logical_block_index_in_file = new_size / block_size;
|
||||
size_t last_logical_block_index_in_file = new_size / block_size;
|
||||
|
||||
ssize_t nwritten = 0;
|
||||
int remaining_count = min((off_t)count, (off_t)new_size - offset);
|
||||
size_t remaining_count = min((off_t)count, (off_t)new_size - offset);
|
||||
const u8* in = data;
|
||||
|
||||
#ifdef EXT2_DEBUG
|
||||
@ -811,9 +811,9 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const u8* data, Fi
|
||||
#endif
|
||||
|
||||
auto buffer_block = ByteBuffer::create_uninitialized(block_size);
|
||||
for (int bi = first_block_logical_index; remaining_count && bi <= last_block_logical_index; ++bi) {
|
||||
int offset_into_block = (bi == first_block_logical_index) ? offset_into_first_block : 0;
|
||||
int num_bytes_to_copy = min(block_size - offset_into_block, remaining_count);
|
||||
for (size_t bi = first_block_logical_index; remaining_count && bi <= last_block_logical_index; ++bi) {
|
||||
size_t offset_into_block = (bi == first_block_logical_index) ? offset_into_first_block : 0;
|
||||
size_t num_bytes_to_copy = min(block_size - offset_into_block, remaining_count);
|
||||
|
||||
ByteBuffer block;
|
||||
if (offset_into_block != 0 || num_bytes_to_copy != block_size) {
|
||||
@ -828,8 +828,8 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const u8* data, Fi
|
||||
|
||||
memcpy(block.data() + offset_into_block, in, num_bytes_to_copy);
|
||||
if (bi == last_logical_block_index_in_file && num_bytes_to_copy < block_size) {
|
||||
int padding_start = new_size % block_size;
|
||||
int padding_bytes = block_size - padding_start;
|
||||
size_t padding_start = new_size % block_size;
|
||||
size_t padding_bytes = block_size - padding_start;
|
||||
#ifdef EXT2_DEBUG
|
||||
dbg() << "Ext2FS: Padding last block of file with zero x " << padding_bytes << " (new_size=" << new_size << ", offset_into_block=" << offset_into_block << ", num_bytes_to_copy=" << num_bytes_to_copy << ")";
|
||||
#endif
|
||||
@ -905,7 +905,7 @@ bool Ext2FSInode::write_directory(const Vector<FS::DirectoryEntry>& entries)
|
||||
auto directory_data = ByteBuffer::create_uninitialized(occupied_size);
|
||||
|
||||
BufferStream stream(directory_data);
|
||||
for (int i = 0; i < entries.size(); ++i) {
|
||||
for (size_t i = 0; i < entries.size(); ++i) {
|
||||
auto& entry = entries[i];
|
||||
|
||||
int record_length = EXT2_DIR_REC_LEN(entry.name_length);
|
||||
@ -1087,7 +1087,7 @@ Ext2FS::BlockIndex Ext2FS::allocate_block(GroupIndex preferred_group_index)
|
||||
return block_index;
|
||||
}
|
||||
|
||||
Vector<Ext2FS::BlockIndex> Ext2FS::allocate_blocks(GroupIndex preferred_group_index, int count)
|
||||
Vector<Ext2FS::BlockIndex> Ext2FS::allocate_blocks(GroupIndex preferred_group_index, size_t count)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
#ifdef EXT2_DEBUG
|
||||
@ -1424,7 +1424,7 @@ KResultOr<NonnullRefPtr<Inode>> Ext2FS::create_inode(InodeIdentifier parent_id,
|
||||
dbgprintf("Ext2FS: Adding inode '%s' (mode %o) to parent directory %u:\n", name.characters(), mode, parent_inode->identifier().index());
|
||||
#endif
|
||||
|
||||
auto needed_blocks = ceil_div(size, block_size());
|
||||
size_t needed_blocks = ceil_div(size, block_size());
|
||||
if ((size_t)needed_blocks > super_block().s_free_blocks_count) {
|
||||
dbg() << "Ext2FS: create_inode: not enough free blocks";
|
||||
return KResult(-ENOSPC);
|
||||
|
@ -135,7 +135,7 @@ private:
|
||||
|
||||
BlockIndex first_block_index() const;
|
||||
InodeIndex find_a_free_inode(GroupIndex preferred_group, off_t expected_size);
|
||||
Vector<BlockIndex> allocate_blocks(GroupIndex preferred_group_index, int count);
|
||||
Vector<BlockIndex> allocate_blocks(GroupIndex preferred_group_index, size_t count);
|
||||
BlockIndex allocate_block(GroupIndex preferred_group_index);
|
||||
GroupIndex group_index_from_inode(InodeIndex) const;
|
||||
GroupIndex group_index_from_block_index(BlockIndex) const;
|
||||
|
@ -145,7 +145,7 @@ static inline int to_fd(const InodeIdentifier& identifier)
|
||||
return (identifier.index() & 0xff) - FI_MaxStaticFileIndex;
|
||||
}
|
||||
|
||||
static inline int to_sys_index(const InodeIdentifier& identifier)
|
||||
static inline size_t to_sys_index(const InodeIdentifier& identifier)
|
||||
{
|
||||
ASSERT(to_proc_parent_directory(identifier) == PDI_Root_sys);
|
||||
ASSERT(to_proc_file_type(identifier) == FI_Root_sys_variable);
|
||||
@ -1271,7 +1271,7 @@ bool ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)
|
||||
break;
|
||||
|
||||
case FI_Root_sys:
|
||||
for (int i = 1; i < sys_variables().size(); ++i) {
|
||||
for (size_t i = 1; i < sys_variables().size(); ++i) {
|
||||
auto& variable = sys_variables()[i];
|
||||
callback({ variable.name.characters(), variable.name.length(), sys_var_to_identifier(fsid(), i), 0 });
|
||||
}
|
||||
@ -1356,7 +1356,7 @@ RefPtr<Inode> ProcFSInode::lookup(StringView name)
|
||||
}
|
||||
|
||||
if (proc_file_type == FI_Root_sys) {
|
||||
for (int i = 1; i < sys_variables().size(); ++i) {
|
||||
for (size_t i = 1; i < sys_variables().size(); ++i) {
|
||||
auto& variable = sys_variables()[i];
|
||||
if (name == variable.name)
|
||||
return fs().get_inode(sys_var_to_identifier(fsid(), i));
|
||||
|
@ -93,7 +93,7 @@ KResult VFS::unmount(InodeIdentifier guest_inode_id)
|
||||
LOCKER(m_lock);
|
||||
dbg() << "VFS: unmount called with inode " << guest_inode_id;
|
||||
|
||||
for (int i = 0; i < m_mounts.size(); ++i) {
|
||||
for (size_t i = 0; i < m_mounts.size(); ++i) {
|
||||
auto& mount = m_mounts.at(i);
|
||||
if (mount.guest() == guest_inode_id) {
|
||||
auto result = mount.guest_fs().prepare_to_unmount();
|
||||
@ -788,7 +788,7 @@ KResultOr<NonnullRefPtr<Custody>> VFS::resolve_path(StringView path, Custody& ba
|
||||
|
||||
NonnullRefPtr<Custody> custody = path[0] == '/' ? current_root : base;
|
||||
|
||||
for (int i = 0; i < parts.size(); ++i) {
|
||||
for (size_t i = 0; i < parts.size(); ++i) {
|
||||
Custody& parent = custody;
|
||||
auto parent_metadata = parent.inode().metadata();
|
||||
if (!parent_metadata.is_directory())
|
||||
|
@ -128,7 +128,7 @@ KResult IPv4Socket::bind(const sockaddr* user_address, socklen_t address_size)
|
||||
return protocol_bind();
|
||||
}
|
||||
|
||||
KResult IPv4Socket::listen(int backlog)
|
||||
KResult IPv4Socket::listen(size_t backlog)
|
||||
{
|
||||
int rc = allocate_local_port_if_needed();
|
||||
if (rc < 0)
|
||||
@ -138,7 +138,7 @@ KResult IPv4Socket::listen(int backlog)
|
||||
m_role = Role::Listener;
|
||||
|
||||
#ifdef IPV4_SOCKET_DEBUG
|
||||
kprintf("IPv4Socket{%p} listening with backlog=%d\n", this, backlog);
|
||||
kprintf("IPv4Socket{%p} listening with backlog=%zu\n", this, backlog);
|
||||
#endif
|
||||
|
||||
return protocol_listen();
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
virtual void close() override;
|
||||
virtual KResult bind(const sockaddr*, socklen_t) override;
|
||||
virtual KResult connect(FileDescription&, const sockaddr*, socklen_t, ShouldBlock = ShouldBlock::Yes) override;
|
||||
virtual KResult listen(int) override;
|
||||
virtual KResult listen(size_t) override;
|
||||
virtual void get_local_address(sockaddr*, socklen_t*) override;
|
||||
virtual void get_peer_address(sockaddr*, socklen_t*) override;
|
||||
virtual void attach(FileDescription&) override;
|
||||
|
@ -192,7 +192,7 @@ KResult LocalSocket::connect(FileDescription& description, const sockaddr* addre
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
KResult LocalSocket::listen(int backlog)
|
||||
KResult LocalSocket::listen(size_t backlog)
|
||||
{
|
||||
LOCKER(lock());
|
||||
if (type() != SOCK_STREAM)
|
||||
@ -200,7 +200,7 @@ KResult LocalSocket::listen(int backlog)
|
||||
set_backlog(backlog);
|
||||
m_connect_side_role = m_role = Role::Listener;
|
||||
#ifdef DEBUG_LOCAL_SOCKET
|
||||
kprintf("LocalSocket{%p} listening with backlog=%d\n", this, backlog);
|
||||
kprintf("LocalSocket{%p} listening with backlog=%zu\n", this, backlog);
|
||||
#endif
|
||||
return KSuccess;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
// ^Socket
|
||||
virtual KResult bind(const sockaddr*, socklen_t) override;
|
||||
virtual KResult connect(FileDescription&, const sockaddr*, socklen_t, ShouldBlock = ShouldBlock::Yes) override;
|
||||
virtual KResult listen(int) override;
|
||||
virtual KResult listen(size_t) override;
|
||||
virtual void get_local_address(sockaddr*, socklen_t*) override;
|
||||
virtual void get_peer_address(sockaddr*, socklen_t*) override;
|
||||
virtual void attach(FileDescription&) override;
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
|
||||
virtual KResult bind(const sockaddr*, socklen_t) = 0;
|
||||
virtual KResult connect(FileDescription&, const sockaddr*, socklen_t, ShouldBlock) = 0;
|
||||
virtual KResult listen(int) = 0;
|
||||
virtual KResult listen(size_t) = 0;
|
||||
virtual void get_local_address(sockaddr*, socklen_t*) = 0;
|
||||
virtual void get_peer_address(sockaddr*, socklen_t*) = 0;
|
||||
virtual bool is_local() const { return false; }
|
||||
@ -138,8 +138,8 @@ protected:
|
||||
|
||||
KResult queue_connection_from(NonnullRefPtr<Socket>);
|
||||
|
||||
int backlog() const { return m_backlog; }
|
||||
void set_backlog(int backlog) { m_backlog = backlog; }
|
||||
size_t backlog() const { return m_backlog; }
|
||||
void set_backlog(size_t backlog) { m_backlog = backlog; }
|
||||
|
||||
virtual const char* class_name() const override { return "Socket"; }
|
||||
|
||||
@ -160,7 +160,7 @@ private:
|
||||
int m_domain { 0 };
|
||||
int m_type { 0 };
|
||||
int m_protocol { 0 };
|
||||
int m_backlog { 0 };
|
||||
size_t m_backlog { 0 };
|
||||
SetupState m_setup_state { SetupState::Unstarted };
|
||||
bool m_connected { false };
|
||||
bool m_shut_down_for_reading { false };
|
||||
|
@ -255,7 +255,7 @@ bool Process::deallocate_region(Region& region)
|
||||
InterruptDisabler disabler;
|
||||
if (m_region_lookup_cache.region == ®ion)
|
||||
m_region_lookup_cache.region = nullptr;
|
||||
for (int i = 0; i < m_regions.size(); ++i) {
|
||||
for (size_t i = 0; i < m_regions.size(); ++i) {
|
||||
if (&m_regions[i] == ®ion) {
|
||||
m_regions.unstable_remove(i);
|
||||
return true;
|
||||
@ -956,7 +956,7 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
|
||||
|
||||
disown_all_shared_buffers();
|
||||
|
||||
for (int i = 0; i < m_fds.size(); ++i) {
|
||||
for (size_t i = 0; i < m_fds.size(); ++i) {
|
||||
auto& daf = m_fds[i];
|
||||
if (daf.description && daf.flags & FD_CLOEXEC) {
|
||||
daf.description->close();
|
||||
@ -1522,7 +1522,7 @@ RefPtr<FileDescription> Process::file_description(int fd) const
|
||||
{
|
||||
if (fd < 0)
|
||||
return nullptr;
|
||||
if (fd < m_fds.size())
|
||||
if (static_cast<size_t>(fd) < m_fds.size())
|
||||
return m_fds[fd].description.ptr();
|
||||
return nullptr;
|
||||
}
|
||||
@ -1531,7 +1531,7 @@ int Process::fd_flags(int fd) const
|
||||
{
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
if (fd < m_fds.size())
|
||||
if (static_cast<size_t>(fd) < m_fds.size())
|
||||
return m_fds[fd].flags;
|
||||
return -1;
|
||||
}
|
||||
@ -3189,6 +3189,8 @@ int Process::sys$bind(int sockfd, const sockaddr* address, socklen_t address_len
|
||||
|
||||
int Process::sys$listen(int sockfd, int backlog)
|
||||
{
|
||||
if (backlog < 0)
|
||||
return -EINVAL;
|
||||
auto description = file_description(sockfd);
|
||||
if (!description)
|
||||
return -EBADF;
|
||||
@ -4761,7 +4763,7 @@ int Process::sys$unveil(const Syscall::SC_unveil_params* user_params)
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_unveiled_paths.size(); ++i) {
|
||||
for (size_t i = 0; i < m_unveiled_paths.size(); ++i) {
|
||||
auto& unveiled_path = m_unveiled_paths[i];
|
||||
if (unveiled_path.path == path.value()) {
|
||||
if (new_permissions & ~unveiled_path.permissions)
|
||||
|
@ -122,7 +122,7 @@ void SharedBuffer::share_with(pid_t peer_pid)
|
||||
void SharedBuffer::deref_for_process(Process& process)
|
||||
{
|
||||
LOCKER(shared_buffers().lock());
|
||||
for (int i = 0; i < m_refs.size(); ++i) {
|
||||
for (size_t i = 0; i < m_refs.size(); ++i) {
|
||||
auto& ref = m_refs[i];
|
||||
if (ref.pid == process.pid()) {
|
||||
ref.count--;
|
||||
@ -150,7 +150,7 @@ void SharedBuffer::deref_for_process(Process& process)
|
||||
void SharedBuffer::disown(pid_t pid)
|
||||
{
|
||||
LOCKER(shared_buffers().lock());
|
||||
for (int i = 0; i < m_refs.size(); ++i) {
|
||||
for (size_t i = 0; i < m_refs.size(); ++i) {
|
||||
auto& ref = m_refs[i];
|
||||
if (ref.pid == pid) {
|
||||
#ifdef SHARED_BUFFER_DEBUG
|
||||
|
@ -644,7 +644,7 @@ u32 Thread::make_userspace_stack_for_main_thread(Vector<String> arguments, Vecto
|
||||
|
||||
SmapDisabler disabler;
|
||||
|
||||
for (int i = 0; i < arguments.size(); ++i) {
|
||||
for (size_t i = 0; i < arguments.size(); ++i) {
|
||||
argv[i] = bufptr;
|
||||
memcpy(bufptr, arguments[i].characters(), arguments[i].length());
|
||||
bufptr += arguments[i].length();
|
||||
@ -652,7 +652,7 @@ u32 Thread::make_userspace_stack_for_main_thread(Vector<String> arguments, Vecto
|
||||
}
|
||||
argv[arguments.size()] = nullptr;
|
||||
|
||||
for (int i = 0; i < environment.size(); ++i) {
|
||||
for (size_t i = 0; i < environment.size(); ++i) {
|
||||
env[i] = bufptr;
|
||||
memcpy(bufptr, environment[i].characters(), environment[i].length());
|
||||
bufptr += environment[i].length();
|
||||
|
@ -108,7 +108,7 @@ Range RangeAllocator::allocate_anywhere(size_t size, size_t alignment)
|
||||
size_t offset_from_effective_base = 0;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < m_available_ranges.size(); ++i) {
|
||||
for (size_t i = 0; i < m_available_ranges.size(); ++i) {
|
||||
auto& available_range = m_available_ranges[i];
|
||||
// FIXME: This check is probably excluding some valid candidates when using a large alignment.
|
||||
if (available_range.size() < (effective_size + alignment))
|
||||
@ -142,7 +142,7 @@ Range RangeAllocator::allocate_specific(VirtualAddress base, size_t size)
|
||||
return {};
|
||||
|
||||
Range allocated_range(base, size);
|
||||
for (int i = 0; i < m_available_ranges.size(); ++i) {
|
||||
for (size_t i = 0; i < m_available_ranges.size(); ++i) {
|
||||
auto& available_range = m_available_ranges[i];
|
||||
if (!available_range.contains(base, size))
|
||||
continue;
|
||||
@ -181,7 +181,7 @@ void RangeAllocator::deallocate(Range range)
|
||||
},
|
||||
&nearby_index);
|
||||
|
||||
int inserted_index = 0;
|
||||
size_t inserted_index = 0;
|
||||
if (existing_range) {
|
||||
existing_range->m_size += range.size();
|
||||
inserted_index = nearby_index;
|
||||
|
@ -116,7 +116,7 @@ next_entry:
|
||||
String line(s, Chomp);
|
||||
auto parts = line.split(':', true);
|
||||
if (parts.size() != 4) {
|
||||
fprintf(stderr, "getgrent(): Malformed entry on line %u: '%s' has %u parts\n", __grdb_line_number, line.characters(), parts.size());
|
||||
fprintf(stderr, "getgrent(): Malformed entry on line %u: '%s' has %zu parts\n", __grdb_line_number, line.characters(), parts.size());
|
||||
goto next_entry;
|
||||
}
|
||||
auto& e_name = parts[0];
|
||||
@ -133,7 +133,7 @@ next_entry:
|
||||
__grdb_entry->gr_gid = e_gid;
|
||||
__grdb_entry->gr_name = __grdb_entry->name_buffer;
|
||||
__grdb_entry->gr_passwd = __grdb_entry->passwd_buffer;
|
||||
for (ssize_t i = 0; i < members.size(); ++i) {
|
||||
for (size_t i = 0; i < members.size(); ++i) {
|
||||
__grdb_entry->members[i] = __grdb_entry->members_buffer[i];
|
||||
strcpy(__grdb_entry->members_buffer[i], members[i].characters());
|
||||
}
|
||||
|
@ -48,14 +48,14 @@ void ArgsParser::parse(int argc, char** argv)
|
||||
|
||||
int index_of_found_long_option = -1;
|
||||
|
||||
for (int i = 0; i < m_options.size(); i++) {
|
||||
for (size_t i = 0; i < m_options.size(); i++) {
|
||||
auto& opt = m_options[i];
|
||||
if (opt.long_name) {
|
||||
option long_opt {
|
||||
opt.long_name,
|
||||
opt.requires_argument ? required_argument : no_argument,
|
||||
&index_of_found_long_option,
|
||||
i
|
||||
static_cast<int>(i)
|
||||
};
|
||||
long_options.append(long_opt);
|
||||
}
|
||||
@ -107,7 +107,7 @@ void ArgsParser::parse(int argc, char** argv)
|
||||
int values_left = argc - optind;
|
||||
int num_values_for_arg[m_positional_args.size()];
|
||||
int total_values_required = 0;
|
||||
for (int i = 0; i < m_positional_args.size(); i++) {
|
||||
for (size_t i = 0; i < m_positional_args.size(); i++) {
|
||||
auto& arg = m_positional_args[i];
|
||||
num_values_for_arg[i] = arg.min_values;
|
||||
total_values_required += arg.min_values;
|
||||
@ -117,7 +117,7 @@ void ArgsParser::parse(int argc, char** argv)
|
||||
print_usage_and_exit();
|
||||
int extra_values_to_distribute = values_left - total_values_required;
|
||||
|
||||
for (int i = 0; i < m_positional_args.size(); i++) {
|
||||
for (size_t i = 0; i < m_positional_args.size(); i++) {
|
||||
auto& arg = m_positional_args[i];
|
||||
int extra_values_to_this_arg = min(arg.max_values - arg.min_values, extra_values_to_distribute);
|
||||
num_values_for_arg[i] += extra_values_to_this_arg;
|
||||
@ -131,7 +131,7 @@ void ArgsParser::parse(int argc, char** argv)
|
||||
print_usage_and_exit();
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_positional_args.size(); i++) {
|
||||
for (size_t i = 0; i < m_positional_args.size(); i++) {
|
||||
auto& arg = m_positional_args[i];
|
||||
for (int j = 0; j < num_values_for_arg[i]; j++) {
|
||||
const char* value = argv[optind++];
|
||||
|
@ -296,7 +296,7 @@ void EventLoop::pump(WaitMode mode)
|
||||
events = move(m_queued_events);
|
||||
}
|
||||
|
||||
for (int i = 0; i < events.size(); ++i) {
|
||||
for (size_t i = 0; i < events.size(); ++i) {
|
||||
auto& queued_event = events.at(i);
|
||||
#ifndef __clang__
|
||||
ASSERT(queued_event.event);
|
||||
|
@ -60,7 +60,7 @@ int IODevice::read(u8* buffer, int length)
|
||||
return read_buffer.size();
|
||||
}
|
||||
|
||||
ByteBuffer IODevice::read(int max_size)
|
||||
ByteBuffer IODevice::read(size_t max_size)
|
||||
{
|
||||
if (m_fd < 0)
|
||||
return {};
|
||||
@ -68,8 +68,8 @@ ByteBuffer IODevice::read(int max_size)
|
||||
return {};
|
||||
auto buffer = ByteBuffer::create_uninitialized(max_size);
|
||||
auto* buffer_ptr = (char*)buffer.data();
|
||||
int remaining_buffer_space = buffer.size();
|
||||
int taken_from_buffered = 0;
|
||||
size_t remaining_buffer_space = buffer.size();
|
||||
size_t taken_from_buffered = 0;
|
||||
if (!m_buffered_data.is_empty()) {
|
||||
taken_from_buffered = min(remaining_buffer_space, m_buffered_data.size());
|
||||
memcpy(buffer_ptr, m_buffered_data.data(), taken_from_buffered);
|
||||
@ -171,7 +171,7 @@ ByteBuffer IODevice::read_all()
|
||||
return ByteBuffer::copy(data.data(), data.size());
|
||||
}
|
||||
|
||||
ByteBuffer IODevice::read_line(int max_size)
|
||||
ByteBuffer IODevice::read_line(size_t max_size)
|
||||
{
|
||||
if (m_fd < 0)
|
||||
return {};
|
||||
@ -189,7 +189,7 @@ ByteBuffer IODevice::read_line(int max_size)
|
||||
return buffer;
|
||||
}
|
||||
auto line = ByteBuffer::create_uninitialized(max_size + 1);
|
||||
int line_index = 0;
|
||||
size_t line_index = 0;
|
||||
while (line_index < max_size) {
|
||||
u8 ch = m_buffered_data[line_index];
|
||||
line[line_index++] = ch;
|
||||
|
@ -58,8 +58,8 @@ public:
|
||||
|
||||
int read(u8* buffer, int length);
|
||||
|
||||
ByteBuffer read(int max_size);
|
||||
ByteBuffer read_line(int max_size);
|
||||
ByteBuffer read(size_t max_size);
|
||||
ByteBuffer read_line(size_t max_size);
|
||||
ByteBuffer read_all();
|
||||
|
||||
bool write(const u8*, int size);
|
||||
|
@ -102,7 +102,7 @@ void Object::insert_child_before(Object& new_child, Object& before_child)
|
||||
|
||||
void Object::remove_child(Object& object)
|
||||
{
|
||||
for (int i = 0; i < m_children.size(); ++i) {
|
||||
for (size_t i = 0; i < m_children.size(); ++i) {
|
||||
if (m_children.ptr_at(i).ptr() == &object) {
|
||||
// NOTE: We protect the child so it survives the handling of ChildRemoved.
|
||||
NonnullRefPtr<Object> protector = object;
|
||||
|
@ -222,7 +222,7 @@ void AbstractTableView::update_headers()
|
||||
|
||||
AbstractTableView::ColumnData& AbstractTableView::column_data(int column) const
|
||||
{
|
||||
if (column >= m_column_data.size())
|
||||
if (static_cast<size_t>(column) >= m_column_data.size())
|
||||
m_column_data.resize(column + 1);
|
||||
return m_column_data.at(column);
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ void BoxLayout::run(Widget& widget)
|
||||
if (should_log)
|
||||
dbgprintf("BoxLayout: Starting with available size: %s\n", available_size.to_string().characters());
|
||||
|
||||
int last_entry_with_automatic_size = -1;
|
||||
Optional<size_t> last_entry_with_automatic_size;
|
||||
|
||||
for (int i = 0; i < m_entries.size(); ++i) {
|
||||
for (size_t i = 0; i < m_entries.size(); ++i) {
|
||||
auto& entry = m_entries[i];
|
||||
if (entry.type == Entry::Type::Spacer) {
|
||||
++number_of_visible_entries;
|
||||
@ -123,7 +123,7 @@ void BoxLayout::run(Widget& widget)
|
||||
int current_x = margins().left();
|
||||
int current_y = margins().top();
|
||||
|
||||
for (int i = 0; i < m_entries.size(); ++i) {
|
||||
for (size_t i = 0; i < m_entries.size(); ++i) {
|
||||
auto& entry = m_entries[i];
|
||||
if (entry.type == Entry::Type::Spacer) {
|
||||
current_x += automatic_size.width();
|
||||
@ -141,7 +141,7 @@ void BoxLayout::run(Widget& widget)
|
||||
}
|
||||
ASSERT(entry.widget);
|
||||
|
||||
if (i == last_entry_with_automatic_size) {
|
||||
if (last_entry_with_automatic_size.has_value() && i == last_entry_with_automatic_size.value()) {
|
||||
rect.set_size(automatic_size_for_last_entry);
|
||||
} else {
|
||||
rect.set_size(automatic_size);
|
||||
|
@ -74,7 +74,7 @@ void ColumnsView::paint_event(PaintEvent& event)
|
||||
|
||||
int column_x = 0;
|
||||
|
||||
for (int i = 0; i < m_columns.size(); i++) {
|
||||
for (size_t i = 0; i < m_columns.size(); i++) {
|
||||
auto& column = m_columns[i];
|
||||
auto* next_column = i + 1 == m_columns.size() ? nullptr : &m_columns[i + 1];
|
||||
|
||||
|
@ -72,8 +72,8 @@ void CppSyntaxHighlighter::highlight_matching_token_pair()
|
||||
Backward,
|
||||
};
|
||||
|
||||
auto find_span_of_type = [&](int i, CppToken::Type type, CppToken::Type not_type, Direction direction) {
|
||||
int nesting_level = 0;
|
||||
auto find_span_of_type = [&](auto i, CppToken::Type type, CppToken::Type not_type, Direction direction) -> Optional<size_t> {
|
||||
size_t nesting_level = 0;
|
||||
bool forward = direction == Direction::Forward;
|
||||
for (forward ? ++i : --i; forward ? (i < document.spans().size()) : (i >= 0); forward ? ++i : --i) {
|
||||
auto& span = document.spans().at(i);
|
||||
@ -85,7 +85,7 @@ void CppSyntaxHighlighter::highlight_matching_token_pair()
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return {};
|
||||
};
|
||||
|
||||
auto make_buddies = [&](int index0, int index1) {
|
||||
@ -114,15 +114,15 @@ void CppSyntaxHighlighter::highlight_matching_token_pair()
|
||||
{ CppToken::Type::LeftBracket, CppToken::Type::RightBracket },
|
||||
};
|
||||
|
||||
for (int i = 0; i < document.spans().size(); ++i) {
|
||||
for (size_t i = 0; i < document.spans().size(); ++i) {
|
||||
auto& span = const_cast<GUI::TextDocumentSpan&>(document.spans().at(i));
|
||||
auto token_type = (CppToken::Type)((uintptr_t)span.data);
|
||||
|
||||
for (auto& pair : pairs) {
|
||||
if (token_type == pair.open && span.range.start() == m_editor->cursor()) {
|
||||
auto buddy = find_span_of_type(i, pair.close, pair.open, Direction::Forward);
|
||||
if (buddy != -1)
|
||||
make_buddies(i, buddy);
|
||||
if (buddy.has_value())
|
||||
make_buddies(i, buddy.value());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -133,8 +133,8 @@ void CppSyntaxHighlighter::highlight_matching_token_pair()
|
||||
for (auto& pair : pairs) {
|
||||
if (token_type == pair.close && right_of_end == m_editor->cursor()) {
|
||||
auto buddy = find_span_of_type(i, pair.open, pair.close, Direction::Backward);
|
||||
if (buddy != -1)
|
||||
make_buddies(i, buddy);
|
||||
if (buddy.has_value())
|
||||
make_buddies(i, buddy.value());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ ModelIndex FileSystemModel::Node::index(const FileSystemModel& model, int column
|
||||
{
|
||||
if (!parent)
|
||||
return {};
|
||||
for (int row = 0; row < parent->children.size(); ++row) {
|
||||
for (size_t row = 0; row < parent->children.size(); ++row) {
|
||||
if (&parent->children[row] == this)
|
||||
return model.create_index(row, column, const_cast<Node*>(this));
|
||||
}
|
||||
@ -169,7 +169,7 @@ ModelIndex FileSystemModel::index(const StringView& path, int column) const
|
||||
const Node* node = m_root;
|
||||
if (canonical_path.string() == "/")
|
||||
return m_root->index(*this, column);
|
||||
for (int i = 0; i < canonical_path.parts().size(); ++i) {
|
||||
for (size_t i = 0; i < canonical_path.parts().size(); ++i) {
|
||||
auto& part = canonical_path.parts()[i];
|
||||
bool found = false;
|
||||
for (auto& child : node->children) {
|
||||
@ -318,7 +318,7 @@ ModelIndex FileSystemModel::index(int row, int column, const ModelIndex& parent)
|
||||
return {};
|
||||
auto& node = this->node(parent);
|
||||
const_cast<Node&>(node).reify_if_needed(*this);
|
||||
if (row >= node.children.size())
|
||||
if (static_cast<size_t>(row) >= node.children.size())
|
||||
return {};
|
||||
return create_index(row, column, &node.children[row]);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ void JsonArrayModel::update()
|
||||
|
||||
Model::ColumnMetadata JsonArrayModel::column_metadata(int column) const
|
||||
{
|
||||
ASSERT(column < m_fields.size());
|
||||
ASSERT(column < static_cast<int>(m_fields.size()));
|
||||
return { 100, m_fields[column].text_alignment };
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ int Menu::realize_menu()
|
||||
dbgprintf("GUI::Menu::realize_menu(): New menu ID: %d\n", m_menu_id);
|
||||
#endif
|
||||
ASSERT(m_menu_id > 0);
|
||||
for (int i = 0; i < m_items.size(); ++i) {
|
||||
for (size_t i = 0; i < m_items.size(); ++i) {
|
||||
auto& item = m_items[i];
|
||||
item.set_menu_id({}, m_menu_id);
|
||||
item.set_identifier({}, i);
|
||||
@ -157,7 +157,7 @@ void Menu::unrealize_menu()
|
||||
m_menu_id = 0;
|
||||
}
|
||||
|
||||
Action* Menu::action_at(int index)
|
||||
Action* Menu::action_at(size_t index)
|
||||
{
|
||||
if (index >= m_items.size())
|
||||
return nullptr;
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
|
||||
const String& name() const { return m_name; }
|
||||
|
||||
Action* action_at(int);
|
||||
Action* action_at(size_t);
|
||||
|
||||
void add_action(NonnullRefPtr<Action>);
|
||||
void add_separator();
|
||||
|
@ -264,7 +264,7 @@ String Shortcut::to_string() const
|
||||
parts.append(key_code_to_string(m_key));
|
||||
|
||||
StringBuilder builder;
|
||||
for (int i = 0; i < parts.size(); ++i) {
|
||||
for (size_t i = 0; i < parts.size(); ++i) {
|
||||
builder.append(parts[i]);
|
||||
if (i != parts.size() - 1)
|
||||
builder.append('+');
|
||||
|
@ -59,7 +59,7 @@ ModelIndex SortingProxyModel::map_to_target(const ModelIndex& index) const
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return {};
|
||||
if (index.row() >= m_row_mappings.size() || index.column() >= column_count())
|
||||
if (static_cast<size_t>(index.row()) >= m_row_mappings.size() || index.column() >= column_count())
|
||||
return {};
|
||||
return target().index(m_row_mappings[index.row()], index.column());
|
||||
}
|
||||
@ -143,7 +143,7 @@ void SortingProxyModel::resort()
|
||||
|
||||
selection.clear();
|
||||
for (auto& index : selected_indexes_in_target) {
|
||||
for (int i = 0; i < m_row_mappings.size(); ++i) {
|
||||
for (size_t i = 0; i < m_row_mappings.size(); ++i) {
|
||||
if (m_row_mappings[i] == index.row()) {
|
||||
selection.add(this->index(i, index.column()));
|
||||
continue;
|
||||
|
@ -24,9 +24,9 @@ void SyntaxHighlighter::cursor_did_change()
|
||||
ASSERT(m_editor);
|
||||
auto& document = m_editor->document();
|
||||
if (m_has_brace_buddies) {
|
||||
if (m_brace_buddies[0].index >= 0 && m_brace_buddies[0].index < document.spans().size())
|
||||
if (m_brace_buddies[0].index >= 0 && m_brace_buddies[0].index < static_cast<int>(document.spans().size()))
|
||||
document.set_span_at_index(m_brace_buddies[0].index, m_brace_buddies[0].span_backup);
|
||||
if (m_brace_buddies[1].index >= 0 && m_brace_buddies[1].index < document.spans().size())
|
||||
if (m_brace_buddies[1].index >= 0 && m_brace_buddies[1].index < static_cast<int>(document.spans().size()))
|
||||
document.set_span_at_index(m_brace_buddies[1].index, m_brace_buddies[1].span_backup);
|
||||
m_has_brace_buddies = false;
|
||||
m_editor->update();
|
||||
|
@ -145,19 +145,19 @@ void TabWidget::paint_event(PaintEvent& event)
|
||||
|
||||
Gfx::StylePainter::paint_frame(painter, container_rect, palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Raised, 2);
|
||||
|
||||
for (int i = 0; i < m_tabs.size(); ++i) {
|
||||
for (size_t i = 0; i < m_tabs.size(); ++i) {
|
||||
if (m_tabs[i].widget == m_active_widget)
|
||||
continue;
|
||||
bool hovered = i == m_hovered_tab_index;
|
||||
bool hovered = static_cast<int>(i) == m_hovered_tab_index;
|
||||
auto button_rect = this->button_rect(i);
|
||||
Gfx::StylePainter::paint_tab_button(painter, button_rect, palette(), false, hovered, m_tabs[i].widget->is_enabled());
|
||||
painter.draw_text(button_rect.translated(0, 1), m_tabs[i].title, Gfx::TextAlignment::Center, palette().button_text());
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_tabs.size(); ++i) {
|
||||
for (size_t i = 0; i < m_tabs.size(); ++i) {
|
||||
if (m_tabs[i].widget != m_active_widget)
|
||||
continue;
|
||||
bool hovered = i == m_hovered_tab_index;
|
||||
bool hovered = static_cast<int>(i) == m_hovered_tab_index;
|
||||
auto button_rect = this->button_rect(i);
|
||||
Gfx::StylePainter::paint_tab_button(painter, button_rect, palette(), true, hovered, m_tabs[i].widget->is_enabled());
|
||||
painter.draw_text(button_rect.translated(0, 1), m_tabs[i].title, Gfx::TextAlignment::Center, palette().button_text());
|
||||
@ -190,7 +190,7 @@ int TabWidget::TabData::width(const Gfx::Font& font) const
|
||||
|
||||
void TabWidget::mousedown_event(MouseEvent& event)
|
||||
{
|
||||
for (int i = 0; i < m_tabs.size(); ++i) {
|
||||
for (size_t i = 0; i < m_tabs.size(); ++i) {
|
||||
auto button_rect = this->button_rect(i);
|
||||
if (!button_rect.contains(event.position()))
|
||||
continue;
|
||||
@ -202,7 +202,7 @@ void TabWidget::mousedown_event(MouseEvent& event)
|
||||
void TabWidget::mousemove_event(MouseEvent& event)
|
||||
{
|
||||
int hovered_tab = -1;
|
||||
for (int i = 0; i < m_tabs.size(); ++i) {
|
||||
for (size_t i = 0; i < m_tabs.size(); ++i) {
|
||||
auto button_rect = this->button_rect(i);
|
||||
if (!button_rect.contains(event.position()))
|
||||
continue;
|
||||
@ -243,7 +243,7 @@ void TabWidget::set_tab_position(TabPosition tab_position)
|
||||
|
||||
int TabWidget::active_tab_index() const
|
||||
{
|
||||
for (int i = 0; i < m_tabs.size(); i++) {
|
||||
for (size_t i = 0; i < m_tabs.size(); i++) {
|
||||
if (m_tabs.at(i).widget == m_active_widget)
|
||||
return i;
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ Optional<TextDocumentSpan> TextDocument::first_non_skippable_span_before(const T
|
||||
|
||||
Optional<TextDocumentSpan> TextDocument::first_non_skippable_span_after(const TextPosition& position) const
|
||||
{
|
||||
for (int i = 0; i < m_spans.size(); ++i) {
|
||||
for (size_t i = 0; i < m_spans.size(); ++i) {
|
||||
if (!m_spans[i].range.contains(position))
|
||||
continue;
|
||||
while ((i + 1) < m_spans.size() && m_spans[i + 1].is_skippable)
|
||||
|
@ -1352,7 +1352,7 @@ void TextEditor::recompute_visual_lines(size_t line_index)
|
||||
visual_data.visual_line_breaks.append(line.length());
|
||||
|
||||
if (is_line_wrapping_enabled())
|
||||
visual_data.visual_rect = { m_horizontal_content_padding, 0, available_width, visual_data.visual_line_breaks.size() * line_height() };
|
||||
visual_data.visual_rect = { m_horizontal_content_padding, 0, available_width, static_cast<int>(visual_data.visual_line_breaks.size()) * line_height() };
|
||||
else
|
||||
visual_data.visual_rect = { m_horizontal_content_padding, 0, font().width(line.view()), line_height() };
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ void UndoStack::undo()
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < undo_vector.size(); i++) {
|
||||
for (size_t i = 0; i < undo_vector.size(); i++) {
|
||||
auto& undo_command = undo_vector[i];
|
||||
undo_command.undo();
|
||||
}
|
||||
@ -68,7 +68,7 @@ void UndoStack::redo()
|
||||
auto& undo_container = m_stack[m_stack_index - 1];
|
||||
auto& redo_vector = undo_container.m_undo_vector;
|
||||
|
||||
for (int i = redo_vector.size() - 1; i >= 0; i--) {
|
||||
for (int i = static_cast<int>(redo_vector.size()) - 1; i >= 0; i--) {
|
||||
auto& undo_command = redo_vector[i];
|
||||
undo_command.redo();
|
||||
}
|
||||
@ -84,7 +84,7 @@ void UndoStack::push(NonnullOwnPtr<Command>&& command)
|
||||
}
|
||||
|
||||
// Clear the elements of the stack before the m_undo_stack_index (Excluding our new element)
|
||||
for (int i = 1; i < m_stack_index; i++)
|
||||
for (size_t i = 1; i < m_stack_index; i++)
|
||||
m_stack.remove(1);
|
||||
|
||||
if (m_stack_index > 0 && !m_stack.is_empty())
|
||||
|
@ -52,8 +52,8 @@ private:
|
||||
};
|
||||
|
||||
NonnullOwnPtrVector<UndoCommandsContainer> m_stack;
|
||||
int m_stack_index { 0 };
|
||||
int m_last_updated_undo_vector_size { 0 };
|
||||
size_t m_stack_index { 0 };
|
||||
size_t m_last_updated_undo_vector_size { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -677,7 +677,7 @@ void Widget::focus_previous_widget()
|
||||
void Widget::focus_next_widget()
|
||||
{
|
||||
auto focusable_widgets = window()->focusable_widgets();
|
||||
for (int i = 0; i < focusable_widgets.size(); ++i) {
|
||||
for (size_t i = 0; i < focusable_widgets.size(); ++i) {
|
||||
if (focusable_widgets[i] != this)
|
||||
continue;
|
||||
if (i < focusable_widgets.size() - 1)
|
||||
|
@ -48,9 +48,9 @@ void DisjointRectSet::shatter()
|
||||
do {
|
||||
pass_had_intersections = false;
|
||||
output.clear_with_capacity();
|
||||
for (int i = 0; i < m_rects.size(); ++i) {
|
||||
for (size_t i = 0; i < m_rects.size(); ++i) {
|
||||
auto& r1 = m_rects[i];
|
||||
for (int j = 0; j < m_rects.size(); ++j) {
|
||||
for (size_t j = 0; j < m_rects.size(); ++j) {
|
||||
if (i == j)
|
||||
continue;
|
||||
auto& r2 = m_rects[j];
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
void add(const Rect&);
|
||||
|
||||
bool is_empty() const { return m_rects.is_empty(); }
|
||||
int size() const { return m_rects.size(); }
|
||||
size_t size() const { return m_rects.size(); }
|
||||
|
||||
void clear() { m_rects.clear(); }
|
||||
void clear_with_capacity() { m_rects.clear_with_capacity(); }
|
||||
|
@ -249,13 +249,13 @@ RefPtr<Gfx::Bitmap> load_gif_impl(const u8* data, size_t data_size)
|
||||
}
|
||||
|
||||
// We exited the block loop after finding a trailer. We should have everything needed.
|
||||
printf("Image count: %d\n", images.size());
|
||||
printf("Image count: %zu\n", images.size());
|
||||
if (images.is_empty())
|
||||
return nullptr;
|
||||
|
||||
for (int i = 0; i < images.size(); ++i) {
|
||||
for (size_t i = 0; i < images.size(); ++i) {
|
||||
auto& image = images.at(i);
|
||||
printf("Image %d: %d,%d %dx%d %d bytes LZW-encoded\n", i, image.x, image.y, image.width, image.height, image.lzw_encoded_bytes.size());
|
||||
printf("Image %zu: %d,%d %dx%d %zu bytes LZW-encoded\n", i, image.x, image.y, image.width, image.height, image.lzw_encoded_bytes.size());
|
||||
|
||||
// FIXME: Decode the LZW-encoded bytes and turn them into an image.
|
||||
}
|
||||
|
@ -357,9 +357,9 @@ template<bool has_alpha, u8 filter_type>
|
||||
for (int i = 0; i < context.width; ++i) {
|
||||
auto& pixel = (Pixel&)context.bitmap->scanline(y)[i];
|
||||
auto& color = context.palette_data.at((int)palette_index[i]);
|
||||
auto transparency = context.palette_transparency_data.size() >= palette_index[i] + 1
|
||||
? (int)context.palette_transparency_data.data()[palette_index[i]]
|
||||
: 0xFF;
|
||||
auto transparency = context.palette_transparency_data.size() >= palette_index[i] + 1u
|
||||
? context.palette_transparency_data.data()[palette_index[i]]
|
||||
: 0xff;
|
||||
pixel.r = color.r;
|
||||
pixel.g = color.g;
|
||||
pixel.b = color.b;
|
||||
|
@ -767,7 +767,7 @@ void Painter::draw_text(const Rect& rect, const StringView& raw_text, const Font
|
||||
|
||||
static const int line_spacing = 4;
|
||||
int line_height = font.glyph_height() + line_spacing;
|
||||
Rect bounding_rect { 0, 0, 0, (lines.size() * line_height) - line_spacing };
|
||||
Rect bounding_rect { 0, 0, 0, (static_cast<int>(lines.size()) * line_height) - line_spacing };
|
||||
|
||||
for (auto& line : lines) {
|
||||
auto line_width = font.width(line);
|
||||
@ -795,9 +795,9 @@ void Painter::draw_text(const Rect& rect, const StringView& raw_text, const Font
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
for (int i = 0; i < lines.size(); ++i) {
|
||||
for (size_t i = 0; i < lines.size(); ++i) {
|
||||
auto& line = lines[i];
|
||||
Rect line_rect { bounding_rect.x(), bounding_rect.y() + i * line_height, bounding_rect.width(), line_height };
|
||||
Rect line_rect { bounding_rect.x(), bounding_rect.y() + static_cast<int>(i) * line_height, bounding_rect.width(), line_height };
|
||||
line_rect.intersect(rect);
|
||||
draw_text_line(line_rect, line, font, alignment, color, elision);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ void HTMLFormElement::submit()
|
||||
});
|
||||
|
||||
StringBuilder builder;
|
||||
for (int i = 0; i < parameters.size(); ++i) {
|
||||
for (size_t i = 0; i < parameters.size(); ++i) {
|
||||
builder.append(parameters[i].name);
|
||||
builder.append('=');
|
||||
builder.append(parameters[i].value);
|
||||
|
@ -69,8 +69,8 @@ void dump_tree(const Node& node)
|
||||
|
||||
void dump_tree(const LayoutNode& layout_node)
|
||||
{
|
||||
static int indent = 0;
|
||||
for (int i = 0; i < indent; ++i)
|
||||
static size_t indent = 0;
|
||||
for (size_t i = 0; i < indent; ++i)
|
||||
dbgprintf(" ");
|
||||
|
||||
String tag_name;
|
||||
@ -122,17 +122,17 @@ void dump_tree(const LayoutNode& layout_node)
|
||||
|
||||
if (layout_node.is_block() && static_cast<const LayoutBlock&>(layout_node).children_are_inline()) {
|
||||
auto& block = static_cast<const LayoutBlock&>(layout_node);
|
||||
for (int i = 0; i < indent; ++i)
|
||||
for (size_t i = 0; i < indent; ++i)
|
||||
dbgprintf(" ");
|
||||
dbgprintf(" Line boxes (%d):\n", block.line_boxes().size());
|
||||
for (int line_box_index = 0; line_box_index < block.line_boxes().size(); ++line_box_index) {
|
||||
for (size_t line_box_index = 0; line_box_index < block.line_boxes().size(); ++line_box_index) {
|
||||
auto& line_box = block.line_boxes()[line_box_index];
|
||||
for (int i = 0; i < indent; ++i)
|
||||
for (size_t i = 0; i < indent; ++i)
|
||||
dbgprintf(" ");
|
||||
dbgprintf(" [%d] width: %g\n", line_box_index, line_box.width());
|
||||
for (int fragment_index = 0; fragment_index < line_box.fragments().size(); ++fragment_index) {
|
||||
for (size_t fragment_index = 0; fragment_index < line_box.fragments().size(); ++fragment_index) {
|
||||
auto& fragment = line_box.fragments()[fragment_index];
|
||||
for (int i = 0; i < indent; ++i)
|
||||
for (size_t i = 0; i < indent; ++i)
|
||||
dbgprintf(" ");
|
||||
dbgprintf(" [%d] layout_node: %s{%p}, start: %d, length: %d, rect: %s\n",
|
||||
fragment_index,
|
||||
@ -142,7 +142,7 @@ void dump_tree(const LayoutNode& layout_node)
|
||||
fragment.length(),
|
||||
fragment.rect().to_string().characters());
|
||||
if (fragment.layout_node().is_text()) {
|
||||
for (int i = 0; i < indent; ++i)
|
||||
for (size_t i = 0; i < indent; ++i)
|
||||
dbgprintf(" ");
|
||||
auto& layout_text = static_cast<const LayoutText&>(fragment.layout_node());
|
||||
auto fragment_text = layout_text.text_for_rendering().substring(fragment.start(), fragment.length());
|
||||
@ -153,7 +153,7 @@ void dump_tree(const LayoutNode& layout_node)
|
||||
}
|
||||
|
||||
layout_node.style().for_each_property([&](auto property_id, auto& value) {
|
||||
for (int i = 0; i < indent; ++i)
|
||||
for (size_t i = 0; i < indent; ++i)
|
||||
dbgprintf(" ");
|
||||
dbgprintf(" (%s: %s)\n", CSS::string_from_property_id(property_id), value.to_string().characters());
|
||||
});
|
||||
@ -195,7 +195,7 @@ void dump_rule(const StyleRule& rule)
|
||||
if (*relation_description)
|
||||
dbgprintf("{%s} ", relation_description);
|
||||
|
||||
for (int i = 0; i < complex_selector.compound_selector.size(); ++i) {
|
||||
for (size_t i = 0; i < complex_selector.compound_selector.size(); ++i) {
|
||||
auto& simple_selector = complex_selector.compound_selector[i];
|
||||
const char* type_description = "Unknown";
|
||||
switch (simple_selector.type) {
|
||||
|
@ -143,7 +143,7 @@ void LayoutBlock::layout_inline_children()
|
||||
|
||||
float justified_space_width = whitespace_count ? (excess_horizontal_space_including_whitespace / (float)whitespace_count) : 0;
|
||||
|
||||
for (int i = 0; i < line_box.fragments().size(); ++i) {
|
||||
for (size_t i = 0; i < line_box.fragments().size(); ++i) {
|
||||
auto& fragment = line_box.fragments()[i];
|
||||
// Vertically align everyone's bottom to the line.
|
||||
// FIXME: Support other kinds of vertical alignment.
|
||||
@ -156,7 +156,7 @@ void LayoutBlock::layout_inline_children()
|
||||
float diff = justified_space_width - fragment.rect().width();
|
||||
fragment.rect().set_width(justified_space_width);
|
||||
// Shift subsequent sibling fragments to the right to adjust for change in width.
|
||||
for (int j = i + 1; j < line_box.fragments().size(); ++j) {
|
||||
for (size_t j = i + 1; j < line_box.fragments().size(); ++j) {
|
||||
line_box.fragments()[j].rect().move_by(diff, 0);
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ void LayoutText::split_into_lines(LayoutBlock& container)
|
||||
words.append({ Utf8View(view), start, length });
|
||||
});
|
||||
|
||||
for (int i = 0; i < words.size(); ++i) {
|
||||
for (size_t i = 0; i < words.size(); ++i) {
|
||||
auto& word = words[i];
|
||||
|
||||
float word_width;
|
||||
|
@ -125,7 +125,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(nwritten == buffer.size());
|
||||
ASSERT(static_cast<size_t>(nwritten) == buffer.size());
|
||||
}
|
||||
|
||||
void drain_messages_from_client()
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
{
|
||||
// Double check we don't already have the event waiting for us.
|
||||
// Otherwise we might end up blocked for a while for no reason.
|
||||
for (ssize_t i = 0; i < m_unprocessed_messages.size(); ++i) {
|
||||
for (size_t i = 0; i < m_unprocessed_messages.size(); ++i) {
|
||||
if (m_unprocessed_messages[i]->message_id() == MessageType::static_message_id()) {
|
||||
auto message = move(m_unprocessed_messages[i]);
|
||||
m_unprocessed_messages.remove(i);
|
||||
@ -108,7 +108,7 @@ public:
|
||||
ASSERT(FD_ISSET(m_connection->fd(), &rfds));
|
||||
if (!drain_messages_from_server())
|
||||
return nullptr;
|
||||
for (ssize_t i = 0; i < m_unprocessed_messages.size(); ++i) {
|
||||
for (size_t i = 0; i < m_unprocessed_messages.size(); ++i) {
|
||||
if (m_unprocessed_messages[i]->message_id() == MessageType::static_message_id()) {
|
||||
auto message = move(m_unprocessed_messages[i]);
|
||||
m_unprocessed_messages.remove(i);
|
||||
@ -127,7 +127,7 @@ public:
|
||||
ASSERT_NOT_REACHED();
|
||||
return false;
|
||||
}
|
||||
ASSERT(nwritten == buffer.size());
|
||||
ASSERT(static_cast<size_t>(nwritten) == buffer.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ bool MDText::parse(const StringView& str)
|
||||
while (offset < str.length() && str[offset] != ')');
|
||||
|
||||
const StringView href = str.substring_view(start_of_href, offset - start_of_href);
|
||||
for (int i = first_span_in_the_current_link; i < m_spans.size(); i++)
|
||||
for (size_t i = first_span_in_the_current_link; i < m_spans.size(); i++)
|
||||
m_spans[i].style.href = href;
|
||||
first_span_in_the_current_link = -1;
|
||||
break;
|
||||
|
@ -961,12 +961,12 @@ void Terminal::unimplemented_escape()
|
||||
builder.appendf("((Unimplemented escape: %c", m_final);
|
||||
if (!m_parameters.is_empty()) {
|
||||
builder.append(" parameters:");
|
||||
for (int i = 0; i < m_parameters.size(); ++i)
|
||||
for (size_t i = 0; i < m_parameters.size(); ++i)
|
||||
builder.append((char)m_parameters[i]);
|
||||
}
|
||||
if (!m_intermediates.is_empty()) {
|
||||
builder.append(" intermediates:");
|
||||
for (int i = 0; i < m_intermediates.size(); ++i)
|
||||
for (size_t i = 0; i < m_intermediates.size(); ++i)
|
||||
builder.append((char)m_intermediates[i]);
|
||||
}
|
||||
builder.append("))");
|
||||
|
@ -128,7 +128,7 @@ public:
|
||||
return m_lines[index];
|
||||
}
|
||||
|
||||
int max_history_size() const { return 500; }
|
||||
size_t max_history_size() const { return 500; }
|
||||
const NonnullOwnPtrVector<Line>& history() const { return m_history; }
|
||||
|
||||
void inject_string(const StringView&);
|
||||
@ -184,8 +184,8 @@ private:
|
||||
NonnullOwnPtrVector<Line> m_history;
|
||||
NonnullOwnPtrVector<Line> m_lines;
|
||||
|
||||
int m_scroll_region_top { 0 };
|
||||
int m_scroll_region_bottom { 0 };
|
||||
size_t m_scroll_region_top { 0 };
|
||||
size_t m_scroll_region_bottom { 0 };
|
||||
|
||||
u16 m_columns { 1 };
|
||||
u16 m_rows { 1 };
|
||||
|
@ -241,7 +241,7 @@ void Service::spawn()
|
||||
|
||||
char* argv[m_extra_arguments.size() + 2];
|
||||
argv[0] = const_cast<char*>(m_executable_path.characters());
|
||||
for (int i = 0; i < m_extra_arguments.size(); i++)
|
||||
for (size_t i = 0; i < m_extra_arguments.size(); i++)
|
||||
argv[i + 1] = const_cast<char*>(m_extra_arguments[i].characters());
|
||||
argv[m_extra_arguments.size() + 1] = nullptr;
|
||||
|
||||
|
@ -72,10 +72,11 @@ void AppletManager::add_applet(Window& applet)
|
||||
m_applets.append(applet.make_weak_ptr());
|
||||
|
||||
quick_sort(m_applets.begin(), m_applets.end(), [](auto& a, auto& b) {
|
||||
int index_a = order_vector.find_first_index(a->title());
|
||||
int index_b = order_vector.find_first_index(b->title());
|
||||
|
||||
return index_a > index_b;
|
||||
auto index_a = order_vector.find_first_index(a->title());
|
||||
auto index_b = order_vector.find_first_index(b->title());
|
||||
ASSERT(index_a.has_value());
|
||||
ASSERT(index_b.has_value());
|
||||
return index_a.value() > index_b.value();
|
||||
});
|
||||
|
||||
calculate_applet_rects(MenuManager::the().window());
|
||||
|
@ -482,7 +482,7 @@ void ClientConnection::handle(const Messages::WindowServer::InvalidateRect& mess
|
||||
return;
|
||||
}
|
||||
auto& window = *(*it).value;
|
||||
for (int i = 0; i < message.rects().size(); ++i)
|
||||
for (size_t i = 0; i < message.rects().size(); ++i)
|
||||
window.request_update(message.rects()[i].intersected({ {}, window.size() }), message.ignore_occlusion());
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,7 @@ void Menu::event(Core::Event& event)
|
||||
--m_hovered_item_index;
|
||||
} while (hovered_item()->type() == MenuItem::Separator);
|
||||
|
||||
ASSERT(m_hovered_item_index >= 0 && m_hovered_item_index <= m_items.size() - 1);
|
||||
ASSERT(m_hovered_item_index >= 0 && m_hovered_item_index <= static_cast<int>(m_items.size()) - 1);
|
||||
|
||||
if (is_scrollable() && m_hovered_item_index < m_scroll_offset)
|
||||
--m_scroll_offset;
|
||||
@ -415,17 +415,17 @@ void Menu::event(Core::Event& event)
|
||||
if (key == Key_Down) {
|
||||
ASSERT(m_items.at(0).type() != MenuItem::Separator);
|
||||
|
||||
if (is_scrollable() && m_hovered_item_index == m_items.size() - 1)
|
||||
if (is_scrollable() && m_hovered_item_index == static_cast<int>(m_items.size()) - 1)
|
||||
return;
|
||||
|
||||
do {
|
||||
if (m_hovered_item_index == m_items.size() - 1)
|
||||
if (m_hovered_item_index == static_cast<int>(m_items.size()) - 1)
|
||||
m_hovered_item_index = 0;
|
||||
else
|
||||
++m_hovered_item_index;
|
||||
} while (hovered_item()->type() == MenuItem::Separator);
|
||||
|
||||
ASSERT(m_hovered_item_index >= 0 && m_hovered_item_index <= m_items.size() - 1);
|
||||
ASSERT(m_hovered_item_index >= 0 && m_hovered_item_index <= static_cast<int>(m_items.size()) - 1);
|
||||
|
||||
if (is_scrollable() && m_hovered_item_index >= (m_scroll_offset + visible_item_count()))
|
||||
++m_scroll_offset;
|
||||
|
@ -67,7 +67,7 @@ MenuManager::~MenuManager()
|
||||
|
||||
bool MenuManager::is_open(const Menu& menu) const
|
||||
{
|
||||
for (int i = 0; i < m_open_menu_stack.size(); ++i) {
|
||||
for (size_t i = 0; i < m_open_menu_stack.size(); ++i) {
|
||||
if (&menu == m_open_menu_stack[i].ptr())
|
||||
return true;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ void WindowSwitcher::set_visible(bool visible)
|
||||
|
||||
Window* WindowSwitcher::selected_window()
|
||||
{
|
||||
if (m_selected_index < 0 || m_selected_index >= m_windows.size())
|
||||
if (m_selected_index < 0 || m_selected_index >= static_cast<int>(m_windows.size()))
|
||||
return nullptr;
|
||||
return m_windows[m_selected_index].ptr();
|
||||
}
|
||||
@ -78,7 +78,7 @@ void WindowSwitcher::event(Core::Event& event)
|
||||
|
||||
auto& mouse_event = static_cast<MouseEvent&>(event);
|
||||
int new_hovered_index = -1;
|
||||
for (int i = 0; i < m_windows.size(); ++i) {
|
||||
for (size_t i = 0; i < m_windows.size(); ++i) {
|
||||
auto item_rect = this->item_rect(i);
|
||||
if (item_rect.contains(mouse_event.position())) {
|
||||
new_hovered_index = i;
|
||||
@ -128,20 +128,20 @@ void WindowSwitcher::on_key_event(const KeyEvent& event)
|
||||
int new_selected_index;
|
||||
|
||||
if (!event.shift()) {
|
||||
new_selected_index = (m_selected_index + 1) % m_windows.size();
|
||||
new_selected_index = (m_selected_index + 1) % static_cast<int>(m_windows.size());
|
||||
} else {
|
||||
new_selected_index = (m_selected_index - 1) % m_windows.size();
|
||||
new_selected_index = (m_selected_index - 1) % static_cast<int>(m_windows.size());
|
||||
if (new_selected_index < 0)
|
||||
new_selected_index = m_windows.size() - 1;
|
||||
new_selected_index = static_cast<int>(m_windows.size()) - 1;
|
||||
}
|
||||
ASSERT(new_selected_index < m_windows.size());
|
||||
ASSERT(new_selected_index < static_cast<int>(m_windows.size()));
|
||||
|
||||
select_window_at_index(new_selected_index);
|
||||
}
|
||||
|
||||
void WindowSwitcher::select_window(Window& window)
|
||||
{
|
||||
for (int i = 0; i < m_windows.size(); ++i) {
|
||||
for (size_t i = 0; i < m_windows.size(); ++i) {
|
||||
if (m_windows.at(i) == &window) {
|
||||
select_window_at_index(i);
|
||||
return;
|
||||
@ -180,17 +180,17 @@ void WindowSwitcher::draw()
|
||||
Gfx::Painter painter(*m_switcher_window->backing_store());
|
||||
painter.fill_rect({ {}, m_rect.size() }, palette.window());
|
||||
painter.draw_rect({ {}, m_rect.size() }, palette.threed_shadow2());
|
||||
for (int index = 0; index < m_windows.size(); ++index) {
|
||||
for (size_t index = 0; index < m_windows.size(); ++index) {
|
||||
auto& window = *m_windows.at(index);
|
||||
auto item_rect = this->item_rect(index);
|
||||
Color text_color;
|
||||
Color rect_text_color;
|
||||
if (index == m_selected_index) {
|
||||
if (static_cast<int>(index) == m_selected_index) {
|
||||
painter.fill_rect(item_rect, palette.selection());
|
||||
text_color = palette.selection_text();
|
||||
rect_text_color = palette.threed_shadow1();
|
||||
} else {
|
||||
if (index == m_hovered_index)
|
||||
if (static_cast<int>(index) == m_hovered_index)
|
||||
Gfx::StylePainter::paint_button(painter, item_rect, palette, Gfx::ButtonStyle::CoolBar, false, true);
|
||||
text_color = palette.window_text();
|
||||
rect_text_color = palette.threed_shadow2();
|
||||
|
@ -162,7 +162,7 @@ Vector<String> LineEditor::tab_complete_first_token(const String& token)
|
||||
cut_mismatching_chars(completion, m_path[i], token.length());
|
||||
seen_others = true;
|
||||
}
|
||||
for (int i = index + 1; i < m_path.size() && m_path[i].starts_with(token); ++i) {
|
||||
for (size_t i = index + 1; i < m_path.size() && m_path[i].starts_with(token); ++i) {
|
||||
cut_mismatching_chars(completion, m_path[i], token.length());
|
||||
suggestions.append(m_path[i]);
|
||||
seen_others = true;
|
||||
@ -433,7 +433,7 @@ String LineEditor::get_line(const String& prompt)
|
||||
size_t num_printed = 0;
|
||||
putchar('\n');
|
||||
for (auto& suggestion : suggestions) {
|
||||
int next_column = num_printed + suggestion.length() + longest_suggestion_length + 2;
|
||||
size_t next_column = num_printed + suggestion.length() + longest_suggestion_length + 2;
|
||||
|
||||
if (next_column > m_num_columns) {
|
||||
putchar('\n');
|
||||
@ -498,7 +498,7 @@ String LineEditor::get_line(const String& prompt)
|
||||
if (ch == 0xc) { // ^L
|
||||
printf("\033[3J\033[H\033[2J"); // Clear screen.
|
||||
fputs(prompt.characters(), stdout);
|
||||
for (int i = 0; i < m_buffer.size(); ++i)
|
||||
for (size_t i = 0; i < m_buffer.size(); ++i)
|
||||
fputc(m_buffer[i], stdout);
|
||||
if (m_cursor < (size_t)m_buffer.size())
|
||||
printf("\033[%zuD", (size_t)m_buffer.size() - m_cursor); // Move cursor N steps left.
|
||||
|
@ -59,13 +59,13 @@ private:
|
||||
|
||||
Vector<char, 1024> m_buffer;
|
||||
size_t m_cursor { 0 };
|
||||
int m_times_tab_pressed { 0 };
|
||||
int m_num_columns { 0 };
|
||||
size_t m_times_tab_pressed { 0 };
|
||||
size_t m_num_columns { 0 };
|
||||
|
||||
// FIXME: This should be something more take_first()-friendly.
|
||||
Vector<String> m_history;
|
||||
int m_history_cursor { 0 };
|
||||
int m_history_capacity { 100 };
|
||||
size_t m_history_cursor { 0 };
|
||||
size_t m_history_capacity { 100 };
|
||||
|
||||
Vector<String, 256> m_path;
|
||||
|
||||
|
@ -241,8 +241,8 @@ static int sh_cd(int argc, const char** argv)
|
||||
|
||||
static int sh_history(int, const char**)
|
||||
{
|
||||
for (int i = 0; i < editor.history().size(); ++i) {
|
||||
printf("%6d %s\n", i, editor.history()[i].characters());
|
||||
for (size_t i = 0; i < editor.history().size(); ++i) {
|
||||
printf("%6zu %s\n", i, editor.history()[i].characters());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -452,7 +452,7 @@ static int sh_dirs(int argc, const char** argv)
|
||||
for (int i = 0; i < argc; i++) {
|
||||
const char* arg = argv[i];
|
||||
if (!strcmp(arg, "-c")) {
|
||||
for (int i = 1; i < g.directory_stack.size(); i++)
|
||||
for (size_t i = 1; i < g.directory_stack.size(); i++)
|
||||
g.directory_stack.remove(i);
|
||||
|
||||
printed = true;
|
||||
@ -605,7 +605,7 @@ static Vector<String> expand_globs(const StringView& path, const StringView& bas
|
||||
builder.append(base);
|
||||
Vector<String> res;
|
||||
|
||||
for (int i = 0; i < parts.size(); ++i) {
|
||||
for (size_t i = 0; i < parts.size(); ++i) {
|
||||
auto& part = parts[i];
|
||||
if (!is_glob(part)) {
|
||||
builder.append(part);
|
||||
@ -758,7 +758,7 @@ static int run_command(const String& cmd)
|
||||
|
||||
FileDescriptionCollector fds;
|
||||
|
||||
for (int i = 0; i < command.subcommands.size(); ++i) {
|
||||
for (size_t i = 0; i < command.subcommands.size(); ++i) {
|
||||
auto& subcommand = command.subcommands[i];
|
||||
for (auto& redirection : subcommand.redirections) {
|
||||
switch (redirection.type) {
|
||||
@ -814,7 +814,7 @@ static int run_command(const String& cmd)
|
||||
|
||||
CommandTimer timer(cmd);
|
||||
|
||||
for (int i = 0; i < command.subcommands.size(); ++i) {
|
||||
for (size_t i = 0; i < command.subcommands.size(); ++i) {
|
||||
auto& subcommand = command.subcommands[i];
|
||||
Vector<String> argv_string = process_arguments(subcommand.args);
|
||||
Vector<const char*> argv;
|
||||
@ -879,7 +879,7 @@ static int run_command(const String& cmd)
|
||||
|
||||
int wstatus = 0;
|
||||
|
||||
for (int i = 0; i < children.size(); ++i) {
|
||||
for (size_t i = 0; i < children.size(); ++i) {
|
||||
auto& child = children[i];
|
||||
do {
|
||||
int rc = waitpid(child.pid, &wstatus, WEXITED | WSTOPPED);
|
||||
|
@ -128,7 +128,7 @@ int main(int argc, char** argv)
|
||||
usleep(100);
|
||||
}
|
||||
auto average = average_result(results);
|
||||
printf("\nFinished: runs=%d time=%dms write_bps=%llu read_bps=%llu\n", results.size(), timer.elapsed(), average.write_bps, average.read_bps);
|
||||
printf("\nFinished: runs=%zu time=%dms write_bps=%llu read_bps=%llu\n", results.size(), timer.elapsed(), average.write_bps, average.read_bps);
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ int main(int argc, char** argv)
|
||||
|
||||
static void print(const String& name, const JsonValue& value, Vector<String>& trail)
|
||||
{
|
||||
for (int i = 0; i < trail.size(); ++i)
|
||||
for (size_t i = 0; i < trail.size(); ++i)
|
||||
printf("%s", trail[i].characters());
|
||||
|
||||
printf("%s%s%s = ", color_name, name.characters(), color_off);
|
||||
|
@ -145,9 +145,9 @@ int print_escaped(const char* name)
|
||||
return printed;
|
||||
}
|
||||
|
||||
int print_name(const struct stat& st, const String& name, const char* path_for_link_resolution = nullptr)
|
||||
size_t print_name(const struct stat& st, const String& name, const char* path_for_link_resolution = nullptr)
|
||||
{
|
||||
int nprinted = 0;
|
||||
size_t nprinted = 0;
|
||||
|
||||
if (!flag_colorize || !output_is_terminal) {
|
||||
nprinted = printf("%s", name.characters());
|
||||
@ -345,7 +345,7 @@ int do_file_system_object_long(const char* path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool print_filesystem_object_short(const char* path, const char* name, int* nprinted)
|
||||
bool print_filesystem_object_short(const char* path, const char* name, size_t* nprinted)
|
||||
{
|
||||
struct stat st;
|
||||
int rc = lstat(path, &st);
|
||||
@ -363,7 +363,7 @@ int do_file_system_object_short(const char* path)
|
||||
Core::DirIterator di(path, !flag_show_dotfiles ? Core::DirIterator::SkipDots : Core::DirIterator::Flags::NoFlags);
|
||||
if (di.has_error()) {
|
||||
if (di.error() == ENOTDIR) {
|
||||
int nprinted;
|
||||
size_t nprinted = 0;
|
||||
bool status = print_filesystem_object_short(path, path, &nprinted);
|
||||
printf("\n");
|
||||
if (status)
|
||||
@ -385,8 +385,8 @@ int do_file_system_object_short(const char* path)
|
||||
quick_sort(names.begin(), names.end(), [](auto& a, auto& b) { return a < b; });
|
||||
|
||||
size_t printed_on_row = 0;
|
||||
int nprinted;
|
||||
for (int i = 0; i < names.size(); ++i) {
|
||||
size_t nprinted = 0;
|
||||
for (size_t i = 0; i < names.size(); ++i) {
|
||||
auto& name = names[i];
|
||||
StringBuilder builder;
|
||||
builder.append(path);
|
||||
@ -404,7 +404,7 @@ int do_file_system_object_short(const char* path)
|
||||
size_t column_width = longest_name + (offset > 0 ? offset : 2);
|
||||
printed_on_row += column_width;
|
||||
|
||||
for (int j = nprinted; i != (names.size() - 1) && j < (int)column_width; ++j)
|
||||
for (size_t j = nprinted; i != (names.size() - 1) && j < column_width; ++j)
|
||||
printf(" ");
|
||||
if ((printed_on_row + column_width) >= terminal_columns) {
|
||||
printf("\n");
|
||||
|
@ -73,7 +73,7 @@ static void copy_stdin(Vector<int>& fds, bool* err)
|
||||
}
|
||||
|
||||
Vector<int> broken_fds;
|
||||
for (int i = 0; i < fds.size(); ++i) {
|
||||
for (size_t i = 0; i < fds.size(); ++i) {
|
||||
auto fd = fds.at(i);
|
||||
int twrite = 0;
|
||||
while (twrite != nread) {
|
||||
|
Loading…
Reference in New Issue
Block a user