From 1aa4f293008139828462eee371d0aabd2e62e421 Mon Sep 17 00:00:00 2001
From: Norman Feske <norman.feske@genode-labs.com>
Date: Thu, 2 Dec 2021 11:24:09 +0100
Subject: [PATCH] demo: avoid implicit conversions

Issue #23
---
 repos/demo/include/libpng_static/pngconf.h    |  2 +-
 repos/demo/include/scout/canvas.h             |  6 +++---
 repos/demo/include/scout/element.h            | 16 +++++++-------
 .../include/scout/graphics_backend_impl.h     |  5 +++--
 repos/demo/include/scout/texture_allocator.h  |  2 +-
 repos/demo/include/scout/types.h              |  4 ++++
 .../include/scout_gfx/sky_texture_painter.h   |  2 +-
 repos/demo/src/app/launchpad/launch_entry.h   |  4 ++--
 .../src/app/launchpad/launchpad_window.cc     |  2 +-
 .../demo/src/app/launchpad/launchpad_window.h |  8 +++----
 repos/demo/src/app/launchpad/loadbar.h        | 15 +++++++++----
 repos/demo/src/app/launchpad/main.cc          |  2 +-
 repos/demo/src/app/launchpad/section.h        | 11 +++++++---
 repos/demo/src/app/scout/browser_window.cc    | 14 ++++++-------
 repos/demo/src/app/scout/elements.cc          |  6 +++---
 repos/demo/src/app/scout/elements.h           |  6 +++---
 repos/demo/src/app/scout/fade_icon.h          |  2 +-
 repos/demo/src/app/scout/main.cc              |  2 +-
 repos/demo/src/app/scout/png_image.cc         |  2 +-
 repos/demo/src/app/scout/refracted_icon.h     |  4 +++-
 repos/demo/src/app/scout/titlebar.h           | 15 ++++++++++---
 repos/demo/src/app/scout/widgets.cc           |  6 +++---
 repos/demo/src/lib/mini_c/memset.cc           |  2 +-
 repos/demo/src/lib/mini_c/snprintf.cc         |  2 +-
 repos/demo/src/lib/mini_c/strtod.cc           |  2 +-
 repos/demo/src/lib/mini_c/vsnprintf.cc        |  2 +-
 .../src/lib/scout_gfx/sky_texture_painter.cc  | 12 +++++------
 .../src/server/liquid_framebuffer/main.cc     |  8 +++----
 .../src/server/liquid_framebuffer/services.cc |  2 +-
 repos/demo/src/server/nitlog/main.cc          | 21 ++++++++++---------
 30 files changed, 108 insertions(+), 79 deletions(-)

diff --git a/repos/demo/include/libpng_static/pngconf.h b/repos/demo/include/libpng_static/pngconf.h
index 389470ec62..7ac788025e 100644
--- a/repos/demo/include/libpng_static/pngconf.h
+++ b/repos/demo/include/libpng_static/pngconf.h
@@ -1082,7 +1082,7 @@
  * want to have unsigned int for png_uint_32 instead of unsigned long.
  */
 
-typedef unsigned long png_uint_32;
+typedef unsigned int png_uint_32;
 typedef long png_int_32;
 typedef unsigned short png_uint_16;
 typedef short png_int_16;
diff --git a/repos/demo/include/scout/canvas.h b/repos/demo/include/scout/canvas.h
index d7525ebd77..eee0154a94 100644
--- a/repos/demo/include/scout/canvas.h
+++ b/repos/demo/include/scout/canvas.h
@@ -52,7 +52,7 @@ struct Scout::Canvas_base : Texture_allocator
 	virtual void draw_box(int x, int y, int w, int h, Color c) = 0;
 
 	virtual void draw_string(int x, int y, Font *font, Color color,
-	                         char const *str, int len) = 0;
+	                         char const *str, size_t len) = 0;
 
 	virtual void draw_horizontal_shadow(Rect rect, int intensity) = 0;
 
@@ -99,7 +99,7 @@ class Scout::Canvas : public Canvas_base
 
 		void clip(Rect rect) override { _surface.clip(rect); }
 
-		void draw_string(int x, int y, Font *font, Color color, char const *str, int len) override
+		void draw_string(int x, int y, Font *font, Color color, char const *str, size_t len) override
 		{
 			char buf[len + 1];
 			Genode::copy_cstring(buf, str, len + 1);
@@ -181,7 +181,7 @@ class Scout::Canvas : public Canvas_base
 
 		void set_rgba_texture(Texture_base *texture_base,
 		                      unsigned char const *rgba,
-		                      unsigned len, int y) override
+		                      size_t len, int y) override
 		{
 			Texture<PT> *texture = static_cast<Texture<PT> *>(texture_base);
 
diff --git a/repos/demo/include/scout/element.h b/repos/demo/include/scout/element.h
index 13ee5f3295..d0a6fbc830 100644
--- a/repos/demo/include/scout/element.h
+++ b/repos/demo/include/scout/element.h
@@ -41,12 +41,12 @@ class Scout::Element
 		Parent_element *_parent;      /* parent in element hierarchy         */
 		Event_handler  *_evh;         /* event handler object                */
 		struct {
-			int mfocus      : 1;      /* element has mouse focus             */
-			int selected    : 1;      /* element has selected state          */
-			int takes_focus : 1;      /* element highlights mouse focus      */
-			int chapter     : 1;      /* display element as single page      */
-			int findable    : 1;      /* regard element in find function     */
-			int bottom      : 1;      /* place element to the bottom         */
+			unsigned mfocus      : 1;      /* element has mouse focus             */
+			unsigned selected    : 1;      /* element has selected state          */
+			unsigned takes_focus : 1;      /* element highlights mouse focus      */
+			unsigned chapter     : 1;      /* display element as single page      */
+			unsigned findable    : 1;      /* regard element in find function     */
+			unsigned bottom      : 1;      /* place element to the bottom         */
 		} _flags { };
 
 	public:
@@ -78,7 +78,7 @@ class Scout::Element
 		Area  min_size() const { return _min_size; }
 		bool  bottom()   const { return _flags.bottom; }
 
-		void findable(int flag) { _flags.findable = flag; }
+		void findable(bool flag) { _flags.findable = flag; }
 
 		/**
 		 * Set geometry of the element
@@ -95,7 +95,7 @@ class Scout::Element
 		/**
 		 * Set/reset the mouse focus
 		 */
-		virtual void mfocus(int flag)
+		virtual void mfocus(bool flag)
 		{
 			if ((_flags.mfocus == flag) || !_flags.takes_focus) return;
 			_flags.mfocus = flag;
diff --git a/repos/demo/include/scout/graphics_backend_impl.h b/repos/demo/include/scout/graphics_backend_impl.h
index c0a9d5c97c..9e4c690924 100644
--- a/repos/demo/include/scout/graphics_backend_impl.h
+++ b/repos/demo/include/scout/graphics_backend_impl.h
@@ -142,8 +142,9 @@ class Scout::Graphics_backend_impl : public Graphics_backend
 			src += offset;
 			dst += offset;
 
-			blit(src, sizeof(PT)*_max_size.w(),
-			     dst, sizeof(PT)*_max_size.w(), sizeof(PT)*rect.w(), rect.h());
+			blit(src, (unsigned)sizeof(PT)*_max_size.w(), dst,
+			     (int)sizeof(PT)*_max_size.w(),
+			     (int)sizeof(PT)*rect.w(), rect.h());
 
 			_refresh_view(rect);
 		}
diff --git a/repos/demo/include/scout/texture_allocator.h b/repos/demo/include/scout/texture_allocator.h
index a55441a8c6..64dab69f92 100644
--- a/repos/demo/include/scout/texture_allocator.h
+++ b/repos/demo/include/scout/texture_allocator.h
@@ -36,7 +36,7 @@ struct Scout::Texture_allocator : Genode::Interface
 
 	virtual void set_rgba_texture(Texture_base *texture,
 	                              unsigned char const *rgba,
-	                              unsigned len, int y) = 0;
+	                              size_t len, int y) = 0;
 };
 
 #endif /* _INCLUDE__SCOUT__TEXTURE_ALLOCATOR_H_ */
diff --git a/repos/demo/include/scout/types.h b/repos/demo/include/scout/types.h
index ce6659b3ae..d225e0adf1 100644
--- a/repos/demo/include/scout/types.h
+++ b/repos/demo/include/scout/types.h
@@ -17,9 +17,13 @@
 #include <util/geometry.h>
 
 namespace Scout {
+
 	typedef Genode::Point<> Point;
 	typedef Genode::Area<>  Area;
 	typedef Genode::Rect<>  Rect;
+
+	using size_t  = Genode::size_t;
+	using uint8_t = Genode::uint8_t;
 }
 
 #endif /* _INCLUDE__SCOUT__TYPES_H_ */
diff --git a/repos/demo/include/scout_gfx/sky_texture_painter.h b/repos/demo/include/scout_gfx/sky_texture_painter.h
index b239bd1507..1973c4c1eb 100644
--- a/repos/demo/include/scout_gfx/sky_texture_painter.h
+++ b/repos/demo/include/scout_gfx/sky_texture_painter.h
@@ -67,7 +67,7 @@ struct Sky_texture_painter
 			static void _multiply_buf(short dst[], int len, int factor)
 			{
 				for (int i = 0; i < len; i++)
-					dst[i] = (dst[i]*factor)>>8;
+					dst[i] = (short)((dst[i]*factor)>>8);
 			}
 
 			static inline int _mix_channel(int value1, int value2, int alpha)
diff --git a/repos/demo/src/app/launchpad/launch_entry.h b/repos/demo/src/app/launchpad/launch_entry.h
index a7d6fab27f..34186c9fc1 100644
--- a/repos/demo/src/app/launchpad/launch_entry.h
+++ b/repos/demo/src/app/launchpad/launch_entry.h
@@ -50,8 +50,8 @@ class Launch_entry : public Scout::Parent_element, public Loadbar_listener
 		{
 			_block.append_launchertext(_prg_name.string(), &Scout::link_style, &_launcher);
 
-			_loadbar.max_value(max_quota);
-			_loadbar.value(initial_quota);
+			_loadbar.max_value((int)max_quota);
+			_loadbar.value((int)initial_quota);
 			append(&_loadbar);
 			append(&_block);
 
diff --git a/repos/demo/src/app/launchpad/launchpad_window.cc b/repos/demo/src/app/launchpad/launchpad_window.cc
index f50f5b15ec..4128994ef7 100644
--- a/repos/demo/src/app/launchpad/launchpad_window.cc
+++ b/repos/demo/src/app/launchpad/launchpad_window.cc
@@ -59,7 +59,7 @@ Launchpad_window<PT>::Launchpad_window(Genode::Env &env,
 
 	_min_size = Scout::Area(200, 200);
 
-	_status_entry.max_value(initial_quota / 1024);
+	_status_entry.max_value((int)(initial_quota / 1024));
 
 	/* adopt widgets as child elements */
 	_info_section.append(&_status_entry);
diff --git a/repos/demo/src/app/launchpad/launchpad_window.h b/repos/demo/src/app/launchpad/launchpad_window.h
index a7b69bb3d8..3bab5a03d4 100644
--- a/repos/demo/src/app/launchpad/launchpad_window.h
+++ b/repos/demo/src/app/launchpad/launchpad_window.h
@@ -127,8 +127,8 @@ class Launchpad_window : public Scout::Scrollbar_listener,
 		 */
 		void quota(unsigned long quota) override
 		{
-			_status_entry.max_value(initial_quota() / 1024);
-			_status_entry.value(quota / 1024);
+			_status_entry.max_value((int)(initial_quota() / 1024));
+			_status_entry.value((int)(quota / 1024));
 			_status_entry.refresh();
 		}
 
@@ -150,8 +150,8 @@ class Launchpad_window : public Scout::Scrollbar_listener,
 		               Genode::Allocator &alloc) override
 		{
 			Child_entry<PT> *ce;
-			ce = new (alloc) Child_entry<PT>(name, quota / 1024,
-			                                 initial_quota() / 1024,
+			ce = new (alloc) Child_entry<PT>(name, (int)(quota / 1024),
+			                                 (int)(initial_quota() / 1024),
 			                                 *this, launchpad_child);
 			_child_entry_list.insert(ce);
 			_kiddy_section.append(ce);
diff --git a/repos/demo/src/app/launchpad/loadbar.h b/repos/demo/src/app/launchpad/loadbar.h
index 1065506486..a2ad96d84c 100644
--- a/repos/demo/src/app/launchpad/loadbar.h
+++ b/repos/demo/src/app/launchpad/loadbar.h
@@ -96,7 +96,11 @@ class Loadbar : public Scout::Parent_element
 		int _max_value;
 
 		const char *_txt;
-		int _txt_w, _txt_h, _txt_len;
+
+		int _txt_w, _txt_h;
+
+		Scout::size_t _txt_len;
+
 		Scout::Font *_font;
 
 		void _update_bar_geometry(int w)
@@ -188,8 +192,11 @@ class Loadbar : public Scout::Parent_element
 
 			using namespace Scout;
 
-			int txt_x = abs_position.x() + _position.x() + max((_size.w() - _txt_w)/2, 8UL);
-			int txt_y = abs_position.y() + _position.y() + max((_size.h() - _txt_h)/2, 0UL) - 1;
+			int txt_x = abs_position.x() + _position.x()
+			          + (int)max((_size.w() - (size_t)_txt_w)/2, 8UL);
+
+			int txt_y = abs_position.y() + _position.y()
+			          + (int)max((_size.h() - (size_t)_txt_h)/2, 0UL) - 1;
 
 			/* shrink clipping area to text area (limit too long label) */
 			int cx1 = canvas.clip().x1(), cy1 = canvas.clip().y1();
@@ -207,7 +214,7 @@ class Loadbar : public Scout::Parent_element
 			canvas.clip(Rect(Point(cx1, cy1), Area(cx2 - cx1 + 1, cy2 - cy1 + 1)));
 		}
 
-		void mfocus(int flag) override
+		void mfocus(bool flag) override
 		{
 			if (!_active) return;
 
diff --git a/repos/demo/src/app/launchpad/main.cc b/repos/demo/src/app/launchpad/main.cc
index e99a76ff99..18223e8cbb 100644
--- a/repos/demo/src/app/launchpad/main.cc
+++ b/repos/demo/src/app/launchpad/main.cc
@@ -144,7 +144,7 @@ struct Main : Scout::Event_handler
 		_user_state.handle_event(ev);
 
 		if (ev.type == Event::TIMER)
-			Tick::handle(_platform.timer_ticks());
+			Tick::handle((Scout::Tick::time)_platform.timer_ticks());
 
 		/* perform periodic redraw */
 		Genode::uint64_t const curr_time = _platform.timer_ticks();
diff --git a/repos/demo/src/app/launchpad/section.h b/repos/demo/src/app/launchpad/section.h
index f4741da1d2..15923e8adf 100644
--- a/repos/demo/src/app/launchpad/section.h
+++ b/repos/demo/src/app/launchpad/section.h
@@ -22,6 +22,8 @@ class Section : public Scout::Parent_element
 {
 	private:
 
+		typedef Scout::size_t size_t;
+
 		/*
 		 * Noncopyable
 		 */
@@ -38,7 +40,7 @@ class Section : public Scout::Parent_element
 		Scout::Font *_font;
 		int          _txt_w   = _font->string_width(_txt, Scout::strlen(_txt)).decimal();
 		int          _txt_h   = _font->bounding_box().h();
-		int          _txt_len = Scout::strlen(_txt);
+		size_t       _txt_len = Scout::strlen(_txt);
 		int          _r_add;
 
 	public:
@@ -76,8 +78,11 @@ class Section : public Scout::Parent_element
 			                abs_position.y() + _position.y() + 1,
 			                _size.w() + _r_add, _txt_h - 1, Color(240,240,240,130));
 
-			int _txt_x = abs_position.x() + _position.x() + max((_size.w() - _txt_w)/2, 8UL);
-			int _txt_y = abs_position.y() + _position.y() + max((_STH - _SH - _txt_h)/2, 0) - 1;
+			int _txt_x = abs_position.x() + _position.x()
+			           + (int)max((_size.w() - (size_t)_txt_w)/2, 8UL);
+
+			int _txt_y = abs_position.y() + _position.y()
+			           + max((_STH - _SH - (int)_txt_h)/2, 0) - 1;
 
 			Parent_element::draw(canvas, abs_position);
 
diff --git a/repos/demo/src/app/scout/browser_window.cc b/repos/demo/src/app/scout/browser_window.cc
index 362735edac..9a96fb5cdf 100644
--- a/repos/demo/src/app/scout/browser_window.cc
+++ b/repos/demo/src/app/scout/browser_window.cc
@@ -92,15 +92,15 @@ static void extract_rgba(const unsigned char *src, int w, int h,
 {
 	for (int i = 0; i < w*h; i++, src += 4) {
 
-		int r = src[0];
-		int g = src[1];
-		int b = src[2];
-		int a = src[3];
+		int     r = src[0];
+		int     g = src[1];
+		int     b = src[2];
+		uint8_t a = src[3];
 
 		if (dst_alpha[i]) {
 			PT s(r, g, b);
 			dst_pixel[i] = PT::mix(dst_pixel[i], s, a);
-			dst_alpha[i] = max((int)dst_alpha[i], a);
+			dst_alpha[i] = (uint8_t)max((int)dst_alpha[i], a);
 		} else {
 			dst_pixel[i].rgba(r, g, b);
 			dst_alpha[i] = a;
@@ -298,8 +298,8 @@ Browser_window<PT>::Browser_window(Document *initial_content,
 	using Scout::random;
 	for (int j = 0; j < _PANEL_H; j++)
 		for (int i = 0; i < _PANEL_W; i++) {
-			_panel_fg       [j][i] = _icon_fg       [ICON_INDEX][j][i&0x1];
-			_panel_fg_alpha [j][i] = _icon_fg_alpha [ICON_INDEX][j][i&0x1] + random()%3;
+			_panel_fg       [j][i] =           _icon_fg       [ICON_INDEX][j][i&0x1];
+			_panel_fg_alpha [j][i] = (uint8_t)(_icon_fg_alpha [ICON_INDEX][j][i&0x1] + random()%3);
 		}
 
 	/* init panel background */
diff --git a/repos/demo/src/app/scout/elements.cc b/repos/demo/src/app/scout/elements.cc
index b5c8cb7fe1..71784903c3 100644
--- a/repos/demo/src/app/scout/elements.cc
+++ b/repos/demo/src/app/scout/elements.cc
@@ -221,7 +221,7 @@ void Parent_element::flush_cache(Canvas_base &canvas)
  ** Token **
  ***********/
 
-Token::Token(Style *style, const char *str, int len)
+Token::Token(Style *style, const char *str, size_t len)
 :
 	_str(str),
 	_len(len),
@@ -343,8 +343,8 @@ void Block::format_fixed_width(int w)
 
 			/* indent elements of the line according to the alignment */
 			int dx = 0;
-			if (_align == CENTER) dx = max(0UL, (max_w - max_x)/2);
-			if (_align == RIGHT)  dx = max(0UL, max_w - max_x);
+			if (_align == CENTER) dx = (int)max(0UL, (max_w - max_x)/2);
+			if (_align == RIGHT)  dx = (int)max(0UL, max_w - max_x);
 			for (e = line; e && (e->position().y() == cy); e = e->next)
 				e->geometry(Rect(Point(e->position().x() + dx, e->position().y()),
 				                 e->size()));
diff --git a/repos/demo/src/app/scout/elements.h b/repos/demo/src/app/scout/elements.h
index 9cbb5cf97f..04385db2ad 100644
--- a/repos/demo/src/app/scout/elements.h
+++ b/repos/demo/src/app/scout/elements.h
@@ -89,7 +89,7 @@ class Scout::Token : public Element
 	protected:
 
 		const char  *_str;       /* start  of string   */
-		int          _len;       /* length of string   */
+		size_t       _len;       /* length of string   */
 		Style       *_style;     /* textual style      */
 		Color        _col;       /* current text color */
 		Color        _outline;   /* outline color      */
@@ -99,7 +99,7 @@ class Scout::Token : public Element
 		/**
 		 * Constructor
 		 */
-		Token(Style *style, const char *str, int len);
+		Token(Style *style, const char *str, size_t len);
 
 		/**
 		 * Element interface
@@ -178,7 +178,7 @@ class Scout::Link_token : public Token, private Link, public Event_handler,
 			                _size.w(), 1, Color(0,0,255));
 		}
 
-		void mfocus(int flag) override
+		void mfocus(bool flag) override
 		{
 			/*
 			 * highlight link of all siblings that point to the same link.
diff --git a/repos/demo/src/app/scout/fade_icon.h b/repos/demo/src/app/scout/fade_icon.h
index 8163d78181..8006d0c6a9 100644
--- a/repos/demo/src/app/scout/fade_icon.h
+++ b/repos/demo/src/app/scout/fade_icon.h
@@ -83,7 +83,7 @@ class Scout::Fade_icon : public Fader, public Icon<PT, W, H>
 		/**
 		 * Element interface
 		 */
-		void mfocus(int flag) override
+		void mfocus(bool flag) override
 		{
 			Icon<PT, W, H>::mfocus(flag);
 			int step = _focus_alpha - _default_alpha;
diff --git a/repos/demo/src/app/scout/main.cc b/repos/demo/src/app/scout/main.cc
index 0e4d6c8f0a..23f366ea43 100644
--- a/repos/demo/src/app/scout/main.cc
+++ b/repos/demo/src/app/scout/main.cc
@@ -153,7 +153,7 @@ struct Scout::Main : Scout::Event_handler
 		_user_state.handle_event(ev);
 
 		if (event.type == Event::TIMER)
-			Tick::handle(_platform.timer_ticks());
+			Tick::handle((Scout::Tick::time)_platform.timer_ticks());
 
 		/* perform periodic redraw */
 		Genode::uint64_t curr_time = _platform.timer_ticks();
diff --git a/repos/demo/src/app/scout/png_image.cc b/repos/demo/src/app/scout/png_image.cc
index bb7fdd7c4d..2504987870 100644
--- a/repos/demo/src/app/scout/png_image.cc
+++ b/repos/demo/src/app/scout/png_image.cc
@@ -63,7 +63,7 @@ static void user_read_data(png_structp png_ptr, png_bytep data, png_size_t len)
 {
 	Png_stream *stream = (Png_stream *)png_get_io_ptr(png_ptr);
 
-	stream->read((char *)data, len);
+	stream->read((char *)data, (int)len);
 }
 
 
diff --git a/repos/demo/src/app/scout/refracted_icon.h b/repos/demo/src/app/scout/refracted_icon.h
index a8c0292d47..0c7c755f3b 100644
--- a/repos/demo/src/app/scout/refracted_icon.h
+++ b/repos/demo/src/app/scout/refracted_icon.h
@@ -83,7 +83,9 @@ class Scout::Refracted_icon : public Element
 				} while ((dx < -i) || (dx > _distmap_w - 2 - i)
 				      || (dy < -j) || (dy > _distmap_h - 2 - j));
 
-				_distmap[j*_distmap_w + i] += dy*_distmap_w + dx;
+				DT &entry = _distmap[j*_distmap_w + i];
+
+				entry = (DT)(entry + dy*_distmap_w + dx);
 			}
 		}
 
diff --git a/repos/demo/src/app/scout/titlebar.h b/repos/demo/src/app/scout/titlebar.h
index d8aa55f09a..61090627cb 100644
--- a/repos/demo/src/app/scout/titlebar.h
+++ b/repos/demo/src/app/scout/titlebar.h
@@ -32,8 +32,13 @@ class Scout::Titlebar : public Parent_element
 		Titlebar &operator = (Titlebar const &);
 
 		Icon<PT, 32, 32> _fg { };
+
 		const char *_txt = nullptr;
-		int _txt_w = 0, _txt_h = 0, _txt_len = 0;
+
+		int _txt_w = 0,
+		    _txt_h = 0;
+
+		Scout::size_t _txt_len = 0;
 
 	public:
 
@@ -82,8 +87,12 @@ class Scout::Titlebar : public Parent_element
 			                abs_position.y() + _position.y(),
 			                _size.w(), _size.h(), Color(b, b, b, a));
 
-			int _txt_x = abs_position.x() + _position.x() + max((_size.w() - _txt_w)/2, 8UL);
-			int _txt_y = abs_position.y() + _position.y() + max((_size.h() - _txt_h)/2, 0UL) - 1;
+			int _txt_x = abs_position.x() + _position.x()
+			           + (int)max((_size.w() - _txt_w)/2, 8U);
+
+			int _txt_y = abs_position.y() + _position.y()
+			           + (int)max((_size.h() - _txt_h)/2, 0U) - 1;
+
 			canvas.draw_string(_txt_x , _txt_y, &title_font, Color(0,0,0,200), _txt, strlen(_txt));
 			Parent_element::draw(canvas, abs_position);
 		}
diff --git a/repos/demo/src/app/scout/widgets.cc b/repos/demo/src/app/scout/widgets.cc
index 9342ca2bf4..672940fa5e 100644
--- a/repos/demo/src/app/scout/widgets.cc
+++ b/repos/demo/src/app/scout/widgets.cc
@@ -106,7 +106,7 @@ void Icon<PT, W, H>::rgba(unsigned char *src, int vshift, int shadow)
 				for (int l = -1; l <=1; l++)
 					v += _alpha[(j + k + H)%H][(i + l + W)%W];
 
-			_shadow[j + 3][i] = v>>shadow;
+			_shadow[j + 3][i] = (unsigned char)(v>>shadow);
 		}
 
 	/* shift vertically */
@@ -122,7 +122,7 @@ void Icon<PT, W, H>::rgba(unsigned char *src, int vshift, int shadow)
 	for (int j = 0; j < H; j++)
 		for (int i = 0; i < W; i++) {
 			_pixel[j][i] = PT::mix(shcol, _pixel[j][i], _alpha[j][i]);
-			_alpha[j][i] = min(255, _alpha[j][i] + _shadow[j][i]);
+			_alpha[j][i] = (unsigned char)min(255, _alpha[j][i] + _shadow[j][i]);
 		}
 }
 
@@ -140,7 +140,7 @@ static inline void blur(unsigned char *src, unsigned char *dst, int w, int h)
 				for (int l = -kernel; l <= kernel; l++)
 					v += src[w*(j + k) + (i + l)];
 
-			dst[w*j + i] = min(v/scale, 255);
+			dst[w*j + i] = (unsigned char)min(v/scale, 255);
 		}
 }
 
diff --git a/repos/demo/src/lib/mini_c/memset.cc b/repos/demo/src/lib/mini_c/memset.cc
index d6128adc87..df88c2646a 100644
--- a/repos/demo/src/lib/mini_c/memset.cc
+++ b/repos/demo/src/lib/mini_c/memset.cc
@@ -15,5 +15,5 @@
 
 extern "C" void *memset(void *s, int c, Genode::size_t n)
 {
-	return Genode::memset(s, c, n);
+	return Genode::memset(s, (char)c, n);
 }
diff --git a/repos/demo/src/lib/mini_c/snprintf.cc b/repos/demo/src/lib/mini_c/snprintf.cc
index 1428b8cf3e..6308879780 100644
--- a/repos/demo/src/lib/mini_c/snprintf.cc
+++ b/repos/demo/src/lib/mini_c/snprintf.cc
@@ -23,5 +23,5 @@ extern "C" int snprintf(char *dst, Genode::size_t dst_len, const char *format, .
 	sc.vprintf(format, list);
 
 	va_end(list);
-	return sc.len();
+	return (int)sc.len();
 }
diff --git a/repos/demo/src/lib/mini_c/strtod.cc b/repos/demo/src/lib/mini_c/strtod.cc
index d6d17f7f05..74e416dfc0 100644
--- a/repos/demo/src/lib/mini_c/strtod.cc
+++ b/repos/demo/src/lib/mini_c/strtod.cc
@@ -17,7 +17,7 @@ extern "C" double strtod(const char *nptr, char **endptr)
 {
 	double value = 0;
 
-	int num_chars = Genode::ascii_to(nptr, value);
+	Genode::size_t num_chars = Genode::ascii_to(nptr, value);
 
 	if (endptr)
 		*endptr = (char *)(nptr + num_chars);
diff --git a/repos/demo/src/lib/mini_c/vsnprintf.cc b/repos/demo/src/lib/mini_c/vsnprintf.cc
index 09fae6c9b7..7090bd6669 100644
--- a/repos/demo/src/lib/mini_c/vsnprintf.cc
+++ b/repos/demo/src/lib/mini_c/vsnprintf.cc
@@ -17,5 +17,5 @@ extern "C" int vsnprintf(char *dst, Genode::size_t dst_len, const char *format,
 {
 	Genode::String_console sc(dst, dst_len);
 	sc.vprintf(format, list);
-	return sc.len();
+	return (int)sc.len();
 }
diff --git a/repos/demo/src/lib/scout_gfx/sky_texture_painter.cc b/repos/demo/src/lib/scout_gfx/sky_texture_painter.cc
index 5dac4b6977..2cae89fce3 100644
--- a/repos/demo/src/lib/scout_gfx/sky_texture_painter.cc
+++ b/repos/demo/src/lib/scout_gfx/sky_texture_painter.cc
@@ -53,7 +53,7 @@ static inline int filter(int x0, int x1, int x2, int x3, int u)
 		cached_u = u;
 	}
 
-	return (x0*k0 + x1*k1 + x2*k2 + x3*k3)>>8;
+	return (x0*k0 + x1*k1 + x2*k2 + x3*k3) >> 8;
 }
 
 
@@ -74,7 +74,7 @@ static void gen_buf(short tmp[], int noise_w, int noise_h,
 {
 	/* generate noise */
 	for (int i = 0; i < noise_h; i++) for (int j = 0; j < noise_w; j++)
-		dst[i*dst_w + j] = Scout::random()%256 - 128;
+		dst[i*dst_w + j] = (short)(Scout::random()%256 - 128);
 
 	/* interpolate horizontally */
 	for (int j = dst_w - 1; j >= 0; j--) {
@@ -92,7 +92,7 @@ static void gen_buf(short tmp[], int noise_w, int noise_h,
 			int x2 = dst[i*dst_w + x2_idx];
 			int x3 = dst[i*dst_w + x3_idx];
 
-			tmp[i*dst_w + j] = filter(x0, x1, x2, x3, u);
+			tmp[i*dst_w + j] = (short)filter(x0, x1, x2, x3, u);
 		}
 	}
 
@@ -112,7 +112,7 @@ static void gen_buf(short tmp[], int noise_w, int noise_h,
 			int y2 = tmp[y2_idx + j];
 			int y3 = tmp[y3_idx + j];
 
-			dst[i*dst_w + j] = filter(y0, y1, y2, y3, u);
+			dst[i*dst_w + j] = (short)filter(y0, y1, y2, y3, u);
 		}
 	}
 }
@@ -131,7 +131,7 @@ static void normalize_buf(short dst[], int len, int amp)
 	if (max == min) return;
 
 	for (int i = 0; i < len; i++)
-		dst[i] = (amp*(dst[i] - min))/(max - min);
+		dst[i] = (short)((amp*(dst[i] - min))/(max - min));
 }
 
 
@@ -141,7 +141,7 @@ static void normalize_buf(short dst[], int len, int amp)
 static void add_bufs(short src1[], short src2[], short dst[], int len)
 {
 	for (int i = 0; i < len; i++)
-		dst[i] = src1[i] + src2[i];
+		dst[i] = (short)(src1[i] + src2[i]);
 }
 
 /**
diff --git a/repos/demo/src/server/liquid_framebuffer/main.cc b/repos/demo/src/server/liquid_framebuffer/main.cc
index 0819b8e1a5..edcb53765d 100644
--- a/repos/demo/src/server/liquid_framebuffer/main.cc
+++ b/repos/demo/src/server/liquid_framebuffer/main.cc
@@ -191,7 +191,7 @@ class Liquid_fb::Main : public Scout::Event_handler
 		void _init_fb_win()
 		{
 			_fb_win.parent(&_user_state);
-			_fb_win.content_geometry(config_fb_x, config_fb_y,
+			_fb_win.content_geometry((int)config_fb_x, (int)config_fb_y,
 			                         config_fb_width, config_fb_height);
 		}
 
@@ -220,8 +220,8 @@ class Liquid_fb::Main : public Scout::Event_handler
 			_fb_win.config_decoration(config_decoration);
 
 			/* must get called after 'config_decoration()' */
-			_fb_win.content_geometry(config_fb_x, config_fb_y,
-			 config_fb_width, config_fb_height);
+			_fb_win.content_geometry((int)config_fb_x, (int)config_fb_y,
+			                         config_fb_width, config_fb_height);
 			_user_state.update_view_offset();
 		}
 
@@ -247,7 +247,7 @@ class Liquid_fb::Main : public Scout::Event_handler
 				_user_state.handle_event(ev);
 
 			if (ev.type == Event::TIMER) {
-				Scout::Tick::handle(_platform.timer_ticks());
+				Scout::Tick::handle((Scout::Tick::time)_platform.timer_ticks());
 			}
 
 			/* perform periodic redraw */
diff --git a/repos/demo/src/server/liquid_framebuffer/services.cc b/repos/demo/src/server/liquid_framebuffer/services.cc
index 7a77a12638..ac3797939f 100644
--- a/repos/demo/src/server/liquid_framebuffer/services.cc
+++ b/repos/demo/src/server/liquid_framebuffer/services.cc
@@ -109,7 +109,7 @@ class Window_content : public Scout::Element
 
 						a += (Genode::Dither_matrix::value(x, y) - 127) >> 4;
 
-						alpha[y*w + x] = Genode::max(alpha_min, Genode::min(a, 255));
+						alpha[y*w + x] = (unsigned char)Genode::max(alpha_min, Genode::min(a, 255));
 					}
 			}
 
diff --git a/repos/demo/src/server/nitlog/main.cc b/repos/demo/src/server/nitlog/main.cc
index 0954a4c35f..cc2f235e46 100644
--- a/repos/demo/src/server/nitlog/main.cc
+++ b/repos/demo/src/server/nitlog/main.cc
@@ -103,15 +103,16 @@ class Log_entry
 {
 	private:
 
-		typedef Genode::Color Color;
+		using Color  = Genode::Color;
+		using size_t = Genode::size_t;
 
-		char  _label[64];
-		char  _text[LOG_W];
-		char  _attr[LOG_W];
-		Color _color { };
-		int   _label_len = 0;
-		int   _text_len  = 0;
-		int   _id        = 0;
+		char   _label[64];
+		char   _text[LOG_W];
+		char   _attr[LOG_W];
+		Color  _color { };
+		size_t _label_len = 0;
+		size_t _text_len  = 0;
+		int    _id        = 0;
 
 	public:
 
@@ -176,8 +177,8 @@ class Log_entry
 		/**
 		 * Accessors
 		 */
-		int label_len() { return _label_len; }
-		int id()        { return _id; }
+		size_t label_len() { return _label_len; }
+		int    id()        { return _id; }
 };