summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-25 14:49:47 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-25 14:52:35 +0100
commitceec1a7d38d4c8941dbf537b85bd50f0030ffbec (patch)
tree2b137c37ae0f331bb3626583a619a3175ef614d4 /Applications
parent9c6f7d3e7d2252ad2d51f2c7c7379cab867fa477 (diff)
downloadserenity-ceec1a7d38d4c8941dbf537b85bd50f0030ffbec.zip
AK: Make Vector use size_t for its size and capacity
Diffstat (limited to 'Applications')
-rw-r--r--Applications/Browser/History.h2
-rw-r--r--Applications/DisplayProperties/DisplayProperties.cpp6
-rw-r--r--Applications/FileManager/DirectoryView.h2
-rw-r--r--Applications/FileManager/FileUtils.cpp2
-rw-r--r--Applications/Help/History.h2
-rw-r--r--Applications/Help/ManualModel.cpp2
-rw-r--r--Applications/IRCClient/IRCClient.cpp6
-rw-r--r--Applications/IRCClient/IRCClient.h6
-rw-r--r--Applications/Piano/AudioEngine.cpp4
-rw-r--r--Applications/Piano/SamplerWidget.cpp2
-rw-r--r--Applications/SoundPlayer/PlaybackManager.h4
-rw-r--r--Applications/SystemMenu/PowerDialog.cpp4
-rw-r--r--Applications/Welcome/TextWidget.cpp2
13 files changed, 23 insertions, 21 deletions
diff --git a/Applications/Browser/History.h b/Applications/Browser/History.h
index 8f6f66ff51..6df67c2b99 100644
--- a/Applications/Browser/History.h
+++ b/Applications/Browser/History.h
@@ -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();
diff --git a/Applications/DisplayProperties/DisplayProperties.cpp b/Applications/DisplayProperties/DisplayProperties.cpp
index da6c96f499..964d7a25dd 100644
--- a/Applications/DisplayProperties/DisplayProperties.cpp
+++ b/Applications/DisplayProperties/DisplayProperties.cpp
@@ -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);
diff --git a/Applications/FileManager/DirectoryView.h b/Applications/FileManager/DirectoryView.h
index 5992b977f0..9d528141c3 100644
--- a/Applications/FileManager/DirectoryView.h
+++ b/Applications/FileManager/DirectoryView.h
@@ -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);
diff --git a/Applications/FileManager/FileUtils.cpp b/Applications/FileManager/FileUtils.cpp
index 3976b9515f..9db2f3f199 100644
--- a/Applications/FileManager/FileUtils.cpp
+++ b/Applications/FileManager/FileUtils.cpp
@@ -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);
diff --git a/Applications/Help/History.h b/Applications/Help/History.h
index 744176df95..c4058fabfc 100644
--- a/Applications/Help/History.h
+++ b/Applications/Help/History.h
@@ -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();
diff --git a/Applications/Help/ManualModel.cpp b/Applications/Help/ManualModel.cpp
index 928863de56..0188dea1db 100644
--- a/Applications/Help/ManualModel.cpp
+++ b/Applications/Help/ManualModel.cpp
@@ -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);
diff --git a/Applications/IRCClient/IRCClient.cpp b/Applications/IRCClient/IRCClient.cpp
index 0aa6fc4812..d117616c62 100644
--- a/Applications/IRCClient/IRCClient.cpp
+++ b/Applications/IRCClient/IRCClient.cpp
@@ -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;
diff --git a/Applications/IRCClient/IRCClient.h b/Applications/IRCClient/IRCClient.h
index 99f48342c3..1c8cff8a8e 100644
--- a/Applications/IRCClient/IRCClient.h
+++ b/Applications/IRCClient/IRCClient.h
@@ -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&);
diff --git a/Applications/Piano/AudioEngine.cpp b/Applications/Piano/AudioEngine.cpp
index 97793f170c..e3b8d5c434 100644
--- a/Applications/Piano/AudioEngine.cpp
+++ b/Applications/Piano/AudioEngine.cpp
@@ -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;
diff --git a/Applications/Piano/SamplerWidget.cpp b/Applications/Piano/SamplerWidget.cpp
index 2231afcea3..543cee8ebb 100644
--- a/Applications/Piano/SamplerWidget.cpp
+++ b/Applications/Piano/SamplerWidget.cpp
@@ -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);
diff --git a/Applications/SoundPlayer/PlaybackManager.h b/Applications/SoundPlayer/PlaybackManager.h
index 5ed9cfed51..681a79a364 100644
--- a/Applications/SoundPlayer/PlaybackManager.h
+++ b/Applications/SoundPlayer/PlaybackManager.h
@@ -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;
diff --git a/Applications/SystemMenu/PowerDialog.cpp b/Applications/SystemMenu/PowerDialog.cpp
index 988431f3a9..650ee23e89 100644
--- a/Applications/SystemMenu/PowerDialog.cpp
+++ b/Applications/SystemMenu/PowerDialog.cpp
@@ -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);
diff --git a/Applications/Welcome/TextWidget.cpp b/Applications/Welcome/TextWidget.cpp
index 8d4bad08d0..882054dafe 100644
--- a/Applications/Welcome/TextWidget.cpp
+++ b/Applications/Welcome/TextWidget.cpp
@@ -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();