summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-06-22 14:41:11 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-06-22 14:41:11 +0200
commit3f0f7caa45a2243f231610883e09bcfb3a6ccd4b (patch)
treee3bbaec11ff870bc110233ac9cd58d8c5191ee04
parent56ae96558ba568b22318230cffb8f0a88a6d05e5 (diff)
downloadserenity-3f0f7caa45a2243f231610883e09bcfb3a6ccd4b.zip
LibGUI: Fix compiler warnings.
-rw-r--r--LibGUI/GEventLoop.cpp16
-rw-r--r--LibGUI/GFileSystemModel.cpp4
-rw-r--r--LibGUI/GWindow.cpp2
-rw-r--r--LibGUI/GWindow.h2
-rw-r--r--SharedGraphics/Font.cpp2
-rw-r--r--SharedGraphics/PNGLoader.cpp8
6 files changed, 21 insertions, 13 deletions
diff --git a/LibGUI/GEventLoop.cpp b/LibGUI/GEventLoop.cpp
index ffa5b02c3b..4debe6e442 100644
--- a/LibGUI/GEventLoop.cpp
+++ b/LibGUI/GEventLoop.cpp
@@ -367,7 +367,11 @@ bool GEventLoop::drain_messages_from_server()
if (message.extra_size) {
extra_data = ByteBuffer::create_uninitialized(message.extra_size);
int extra_nread = read(s_windowserver_fd, extra_data.data(), extra_data.size());
- ASSERT(extra_nread == message.extra_size);
+ if (extra_nread < 0) {
+ perror("read");
+ ASSERT_NOT_REACHED();
+ }
+ ASSERT((size_t)extra_nread == message.extra_size);
}
m_unprocessed_bundles.append({ move(message), move(extra_data) });
}
@@ -380,17 +384,21 @@ bool GEventLoop::post_message_to_server(const WSAPI_ClientMessage& message, cons
struct iovec iov[2];
int iov_count = 1;
- iov[0].iov_base = (void*)&message;
+ iov[0].iov_base = const_cast<WSAPI_ClientMessage*>(&message);
iov[0].iov_len = sizeof(message);
if (!extra_data.is_empty()) {
- iov[1].iov_base = (void*)extra_data.data();
+ iov[1].iov_base = const_cast<byte*>(extra_data.data());
iov[1].iov_len = extra_data.size();
++iov_count;
}
int nwritten = writev(s_windowserver_fd, iov, iov_count);
- ASSERT(nwritten == sizeof(message) + extra_data.size());
+ if (nwritten < 0) {
+ perror("writev");
+ ASSERT_NOT_REACHED();
+ }
+ ASSERT((size_t)nwritten == sizeof(message) + extra_data.size());
return true;
}
diff --git a/LibGUI/GFileSystemModel.cpp b/LibGUI/GFileSystemModel.cpp
index 3f06e00b95..58780c08b8 100644
--- a/LibGUI/GFileSystemModel.cpp
+++ b/LibGUI/GFileSystemModel.cpp
@@ -23,10 +23,10 @@ struct GFileSystemModel::Node {
GModelIndex index(const GFileSystemModel& model) const
{
if (!parent)
- return model.create_index(0, 0, (void*)this);
+ return model.create_index(0, 0, const_cast<Node*>(this));
for (int row = 0; row < parent->children.size(); ++row) {
if (parent->children[row] == this)
- return model.create_index(row, 0, (void*)this);
+ return model.create_index(row, 0, const_cast<Node*>(this));
}
ASSERT_NOT_REACHED();
}
diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp
index 74e339ff5a..c4ade828e8 100644
--- a/LibGUI/GWindow.cpp
+++ b/LibGUI/GWindow.cpp
@@ -626,7 +626,7 @@ void GWindow::set_icon_path(const StringView& path)
WSAPI_ClientMessage message;
message.type = WSAPI_ClientMessage::Type::SetWindowIcon;
message.window_id = m_window_id;
- ASSERT(path.length() < sizeof(message.text));
+ ASSERT(path.length() < (int)sizeof(message.text));
strcpy(message.text, path.characters());
message.text_length = path.length();
GEventLoop::post_message_to_server(message);
diff --git a/LibGUI/GWindow.h b/LibGUI/GWindow.h
index 617d4125c0..bca25f075f 100644
--- a/LibGUI/GWindow.h
+++ b/LibGUI/GWindow.h
@@ -170,6 +170,6 @@ private:
bool m_show_titlebar { true };
bool m_keybind_mode { false };
String m_entered_keybind;
- size_t m_max_keybind_length { 0 };
+ int m_max_keybind_length { 0 };
HashMap<String, WeakPtr<GWidget>> m_keyboard_activation_targets;
};
diff --git a/SharedGraphics/Font.cpp b/SharedGraphics/Font.cpp
index 9f58f55d5c..9b27d33093 100644
--- a/SharedGraphics/Font.cpp
+++ b/SharedGraphics/Font.cpp
@@ -107,7 +107,7 @@ RefPtr<Font> Font::load_from_memory(const byte* data)
size_t bytes_per_glyph = sizeof(unsigned) * header.glyph_height;
- auto* rows = (unsigned*)(data + sizeof(FontFileHeader));
+ auto* rows = const_cast<unsigned*>((const unsigned*)(data + sizeof(FontFileHeader)));
byte* widths = nullptr;
if (header.is_variable_width)
widths = (byte*)(rows) + 256 * bytes_per_glyph;
diff --git a/SharedGraphics/PNGLoader.cpp b/SharedGraphics/PNGLoader.cpp
index 2560966b39..23d09879e5 100644
--- a/SharedGraphics/PNGLoader.cpp
+++ b/SharedGraphics/PNGLoader.cpp
@@ -27,7 +27,7 @@ static_assert(sizeof(PNG_IHDR) == 13);
struct Scanline {
byte filter { 0 };
- ByteBuffer data;
+ ByteBuffer data { };
};
struct PNGLoadingContext {
@@ -61,9 +61,9 @@ public:
template<typename T>
bool read(T& value)
{
- if (m_size_remaining < sizeof(T))
+ if (m_size_remaining < (int)sizeof(T))
return false;
- value = *((NetworkOrdered<T>*)m_data_ptr);
+ value = *((const NetworkOrdered<T>*)m_data_ptr);
m_data_ptr += sizeof(T);
m_size_remaining -= sizeof(T);
return true;
@@ -383,7 +383,7 @@ static RefPtr<GraphicsBitmap> load_png_impl(const byte* data, int data_size)
static bool process_IHDR(const ByteBuffer& data, PNGLoadingContext& context)
{
- if (data.size() < sizeof(PNG_IHDR))
+ if (data.size() < (int)sizeof(PNG_IHDR))
return false;
auto& ihdr = *(const PNG_IHDR*)data.pointer();
context.width = ihdr.width;