1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:17:42 +00:00

LibGUI: Fix compiler warnings.

This commit is contained in:
Andreas Kling 2019-06-22 14:41:11 +02:00
parent 56ae96558b
commit 3f0f7caa45
6 changed files with 21 additions and 13 deletions

View file

@ -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;
}

View file

@ -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();
}

View file

@ -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);

View file

@ -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;
};

View file

@ -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;

View file

@ -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;