gems: avoid implicit conversions

Issue #23
This commit is contained in:
Norman Feske
2021-12-03 16:16:48 +01:00
parent 5bd8fa9678
commit 8a1675e12e
58 changed files with 197 additions and 161 deletions

View File

@ -22,11 +22,14 @@
#include <terminal_session/terminal_session.h>
/* libc includes */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <unistd.h>
#include <sys/types.h>
#include <sys/select.h>
#include <stdio.h>
#include <fcntl.h>
#pragma GCC diagnostic pop /* restore -Wconversion warnings */
class Open_file

View File

@ -49,9 +49,11 @@ struct Alpha_dither_painter
for (dst = dst_line, w = clipped.w(); w--; dst++, x++) {
int const v = Genode::Dither_matrix::value(x, y) << 13;
using namespace Genode;
dst->pixel = Genode::min(255, Genode::max(0, (fade - v) >> 16));
int const v = Dither_matrix::value(x, y) << 13;
dst->pixel = (uint8_t)min(255, max(0, (fade - v) >> 16));
}
y++;
@ -88,15 +90,17 @@ struct Alpha_dither_painter
for (dst = dst_line, src = src_line, w = clipped.w(); w--; dst++, src++, x++) {
using namespace Genode;
/*
* Multiply texture alpha value with fade value, dither the
* result.
*/
int const a = (((int)src->pixel)*fade);
int const v = Genode::Dither_matrix::value(x, y) << 13;
int const v = Dither_matrix::value(x, y) << 13;
dst->pixel = Genode::min(255, Genode::max(0, (a - v) >> 16));
dst->pixel = (uint8_t)min(255, max(0, (a - v) >> 16));
}
y++;

View File

@ -441,14 +441,14 @@ struct Gui_fader::Main
enum { PERIOD = 20 };
unsigned long alpha = 0;
unsigned alpha = 0;
unsigned long fade_in_steps = 0;
unsigned long fade_out_steps = 0;
unsigned fade_in_steps = 0;
unsigned fade_out_steps = 0;
bool initial_fade_in = true;
unsigned long initial_fade_in_steps = 0;
unsigned initial_fade_in_steps = 0;
Genode::uint64_t curr_frame() const { return timer.elapsed_ms() / PERIOD; }
@ -471,7 +471,7 @@ struct Gui_fader::Main
void handle_timer()
{
Genode::uint64_t frame = curr_frame();
if (gui_session.animate(frame - last_frame))
if (gui_session.animate((unsigned)(frame - last_frame)))
timer.trigger_once(PERIOD);
last_frame = frame;
@ -502,7 +502,7 @@ void Gui_fader::Main::handle_config_update()
Genode::Xml_node config_xml = config.xml();
unsigned long new_alpha = alpha;
unsigned new_alpha = alpha;
if (config_xml.has_attribute("alpha"))
config_xml.attribute("alpha").value(new_alpha);
@ -515,7 +515,7 @@ void Gui_fader::Main::handle_config_update()
bool const fade_in = (new_alpha > alpha);
int const steps =
unsigned const steps =
fade_in ? (initial_fade_in ? initial_fade_in_steps : fade_in_steps)
: fade_out_steps;

View File

@ -100,9 +100,9 @@ class Terminal::Session_component : public Rpc_object<Session, Session_component
{
char const *src = _io_buffer.local_addr<char const>();
unsigned const max = min(num_bytes, _io_buffer.size());
size_t const max = min(num_bytes, _io_buffer.size());
unsigned i = 0;
size_t i = 0;
for (Utf8_ptr utf8(src); utf8.complete() && i < max; ) {
_character_consumer.consume_character(
@ -121,7 +121,7 @@ class Terminal::Session_component : public Rpc_object<Session, Session_component
/* we don't support UTF-8 sequences split into multiple writes */
if (i != num_bytes) {
warning("truncated UTF-8 sequence");
for (unsigned j = i; j < num_bytes; j++)
for (size_t j = i; j < num_bytes; j++)
warning("(unhandled value ", Hex(src[j]), ")");
}

View File

@ -232,7 +232,7 @@ struct Wm::Decorator_gui_session : Genode::Rpc_object<Gui::Session>,
case Command::OP_TITLE:
{
unsigned long id = 0;
unsigned id = 0;
Genode::ascii_to(cmd.title.title.string(), id);
if (id > 0)

View File

@ -73,7 +73,7 @@ struct Wm::Main : Pointer::Tracker
if (!focus_rom.valid())
return;
unsigned long win_id = 0;
unsigned win_id = 0;
Xml_node(focus_rom.local_addr<char>()).sub_node("window")
.attribute("id").value(win_id);
@ -97,10 +97,10 @@ struct Wm::Main : Pointer::Tracker
resize_request_rom.xml().for_each_sub_node("window", [&] (Xml_node window) {
unsigned long const
win_id = window.attribute_value("id", 0UL),
width = window.attribute_value("width", 0UL),
height = window.attribute_value("height", 0UL);
unsigned const
win_id = window.attribute_value("id", 0U),
width = window.attribute_value("width", 0U),
height = window.attribute_value("height", 0U);
gui_root.request_resize(win_id, Area(width, height));
});

View File

@ -213,7 +213,7 @@ class Wm::Window_registry
Id create()
{
Window * const win = new (_alloc) Window(_window_ids.alloc());
Window * const win = new (_alloc) Window((unsigned)_window_ids.alloc());
_windows.insert(win);