diff --git a/repos/os/include/audio_out_session/audio_out_session.h b/repos/os/include/audio_out_session/audio_out_session.h index f3b81c1241..6e8b600844 100644 --- a/repos/os/include/audio_out_session/audio_out_session.h +++ b/repos/os/include/audio_out_session/audio_out_session.h @@ -216,7 +216,7 @@ class Audio_out::Stream * * \return position in stream queue */ - unsigned packet_position(Packet *packet) { return packet - &_buf[0]; } + unsigned packet_position(Packet *packet) { return (unsigned)(packet - &_buf[0]); } /** * Check if stream queue is full/empty diff --git a/repos/os/include/blit/painter.h b/repos/os/include/blit/painter.h index cfbdd3868d..3efd9d6373 100644 --- a/repos/os/include/blit/painter.h +++ b/repos/os/include/blit/painter.h @@ -48,9 +48,9 @@ struct Blit_painter /* start address of destination pixels */ PT * const dst = surface.addr() + clipped.y1()*dst_w + clipped.x1(); - blit(src, src_w*sizeof(PT), - dst, dst_w*sizeof(PT), - clipped.w()*sizeof(PT), clipped.h()); + blit(src, (unsigned)(src_w*sizeof(PT)), + dst, (unsigned)(dst_w*sizeof(PT)), + (unsigned)(clipped.w()*sizeof(PT)), clipped.h()); surface.flush_pixels(clipped); } diff --git a/repos/os/include/block/component.h b/repos/os/include/block/component.h index cdb0db9929..ed9a215265 100644 --- a/repos/os/include/block/component.h +++ b/repos/os/include/block/component.h @@ -109,7 +109,7 @@ class Block::Session_component : public Block::Session_component_base, /* ignore invalid packets */ bool const valid = _range_check(_p_to_handle) && tx_sink()->packet_valid(packet) - && aligned(packet.offset(), _info.align_log2); + && aligned(packet.offset(), (unsigned)_info.align_log2); if (!valid) { _ack_packet(_p_to_handle); return; diff --git a/repos/os/include/block/request.h b/repos/os/include/block/request.h index 718727c289..64f85e673a 100644 --- a/repos/os/include/block/request.h +++ b/repos/os/include/block/request.h @@ -23,6 +23,7 @@ namespace Block { typedef Genode::uint64_t block_number_t; typedef Genode::size_t block_count_t; typedef Genode::off_t off_t; + typedef Genode::uint64_t seek_off_t; struct Operation; struct Request; diff --git a/repos/os/include/block/request_stream.h b/repos/os/include/block/request_stream.h index 98ee27976c..57aadf6a02 100644 --- a/repos/os/include/block/request_stream.h +++ b/repos/os/include/block/request_stream.h @@ -77,7 +77,7 @@ class Block::Request_stream : Genode::Noncopyable return false; /* check for proper alignment */ - if (!Genode::aligned(request.offset, _info.align_log2)) + if (!Genode::aligned(request.offset, (unsigned)_info.align_log2)) return false; return true; diff --git a/repos/os/include/block_session/block_session.h b/repos/os/include/block_session/block_session.h index 970e657cf0..f08fc58954 100644 --- a/repos/os/include/block_session/block_session.h +++ b/repos/os/include/block_session/block_session.h @@ -213,7 +213,7 @@ struct Block::Session : public Genode::Session { return Packet_descriptor(Packet_descriptor(0UL, 0UL), Packet_descriptor::SYNC, - 0UL, info.block_count, tag); + 0UL, (block_count_t)info.block_count, tag); } diff --git a/repos/os/include/block_session/client.h b/repos/os/include/block_session/client.h index 76546c8cc6..f5d7e956ae 100644 --- a/repos/os/include/block_session/client.h +++ b/repos/os/include/block_session/client.h @@ -64,7 +64,7 @@ class Block::Session_client : public Genode::Rpc_client */ Packet_descriptor alloc_packet(Genode::size_t size) { - return tx()->alloc_packet(size, _info.align_log2); + return tx()->alloc_packet(size, (unsigned)_info.align_log2); } }; diff --git a/repos/os/include/block_session/connection.h b/repos/os/include/block_session/connection.h index cfafe8d9c9..dfdbce8847 100644 --- a/repos/os/include/block_session/connection.h +++ b/repos/os/include/block_session/connection.h @@ -142,7 +142,7 @@ struct Block::Connection : Genode::Connection, Session_client Packet_descriptor const p(_curr_operation(), _payload, tag); if (_operation.type == Operation::Type::WRITE) - _with_offset_and_length(job, [&] (off_t offset, size_t length) { + _with_offset_and_length(job, [&] (seek_off_t offset, size_t length) { policy.produce_write_content(job, offset, tx.packet_content(p), length); }); @@ -306,7 +306,7 @@ struct Block::Connection : Genode::Connection, Session_client * communication buffer shared with the server) * \param length size of 'dst' buffer in bytes */ - void produce_write_content(Job &, off_t offset, + void produce_write_content(Job &, seek_off_t offset, char *dst, size_t length); /** @@ -316,7 +316,7 @@ struct Block::Connection : Genode::Connection, Session_client * \param src pointer to received data * \param length number of bytes received */ - void consume_read_result(Job &, off_t offset, + void consume_read_result(Job &, seek_off_t offset, char const *src, size_t length); /** @@ -372,7 +372,7 @@ bool Block::Connection::_try_process_ack(POLICY &policy, Tx::Source &tx) _tags.template apply<_JOB>(id, [&] (_JOB &job) { if (type == Operation::Type::READ) - Job::_with_offset_and_length(job, [&] (off_t offset, size_t length) { + Job::_with_offset_and_length(job, [&] (seek_off_t offset, size_t length) { policy.consume_read_result(job, offset, tx.packet_content(p), length); }); @@ -444,7 +444,7 @@ bool Block::Connection::_try_submit_pending_job(POLICY &policy, Tx::Source size_t const bytes = _info.block_size * job._curr_operation().count; - payload = { .offset = tx.alloc_packet(bytes, _info.align_log2).offset(), + payload = { .offset = tx.alloc_packet(bytes, (unsigned)_info.align_log2).offset(), .bytes = bytes }; }); } diff --git a/repos/os/include/decorator/window.h b/repos/os/include/decorator/window.h index f07fe1c402..11f11fe4f7 100644 --- a/repos/os/include/decorator/window.h +++ b/repos/os/include/decorator/window.h @@ -134,8 +134,8 @@ class Decorator::Window_base : private Genode::List_model::Element using List_model::Element::next; - unsigned long id() const { return _id; } - Rect geometry() const { return _geometry; } + unsigned id() const { return _id; } + Rect geometry() const { return _geometry; } void stacking_neighbor(View_handle neighbor) { diff --git a/repos/os/include/decorator/xml_utils.h b/repos/os/include/decorator/xml_utils.h index 6b0c6d1cdb..ab99a433e0 100644 --- a/repos/os/include/decorator/xml_utils.h +++ b/repos/os/include/decorator/xml_utils.h @@ -31,8 +31,8 @@ namespace Decorator { */ static inline Decorator::Point Decorator::point_attribute(Genode::Xml_node const &point) { - return Point(point.attribute_value("xpos", 0L), - point.attribute_value("ypos", 0L)); } + return Point((int)point.attribute_value("xpos", 0L), + (int)point.attribute_value("ypos", 0L)); } /** @@ -40,8 +40,8 @@ static inline Decorator::Point Decorator::point_attribute(Genode::Xml_node const */ static inline Decorator::Area Decorator::area_attribute(Genode::Xml_node const &area) { - return Area(area.attribute_value("width", 0UL), - area.attribute_value("height", 0UL)); + return Area(area.attribute_value("width", 0U), + area.attribute_value("height", 0U)); } diff --git a/repos/os/include/genode_c_api/usb.h b/repos/os/include/genode_c_api/usb.h index 304d0d79ed..918d827b4d 100644 --- a/repos/os/include/genode_c_api/usb.h +++ b/repos/os/include/genode_c_api/usb.h @@ -19,6 +19,11 @@ struct genode_usb_session; /* definition is private to the implementation */ +typedef unsigned short genode_usb_vendor_id_t; +typedef unsigned short genode_usb_product_id_t; +typedef unsigned int genode_usb_bus_num_t; +typedef unsigned int genode_usb_dev_num_t; +typedef unsigned char genode_usb_class_num_t; #ifdef __cplusplus extern "C" { @@ -45,34 +50,35 @@ typedef void (*genode_usb_free_peer_buffer_t) * Callback to copy over config descriptor for given device */ typedef unsigned (*genode_usb_rpc_config_desc_t) - (unsigned long bus, unsigned long dev, void * dev_desc, void * conf_desc); + (genode_usb_bus_num_t bus, genode_usb_dev_num_t dev, + void * dev_desc, void * conf_desc); /** * Callback that returns number of alt-settings of an interface for given device */ typedef int (*genode_usb_rpc_alt_settings_t) - (unsigned long bus, unsigned long dev, unsigned idx); + (genode_usb_bus_num_t bus, genode_usb_dev_num_t dev, unsigned idx); /** * Callback to copy over interface descriptor for given device/interface */ typedef int (*genode_usb_rpc_iface_desc_t) - (unsigned long bus, unsigned long dev, unsigned idx, unsigned alt, - void * buf, unsigned long buf_size, int * active); + (genode_usb_bus_num_t bus, genode_usb_dev_num_t dev, unsigned idx, + unsigned alt, void * buf, unsigned long buf_size, int * active); /** * Callback to copy over additional vendor specific data of an interface */ typedef int (*genode_usb_rpc_iface_extra_t) - (unsigned long bus, unsigned long dev, unsigned idx, unsigned alt, - void * buf, unsigned long buf_size); + (genode_usb_bus_num_t bus, genode_usb_dev_num_t dev, unsigned idx, + unsigned alt, void * buf, unsigned long buf_size); /** * Callback to copy over endpoint descriptor for given device/iface/endpoint */ typedef int (*genode_usb_rpc_endp_desc_t) - (unsigned long bus, unsigned long dev, unsigned idx, unsigned alt, - unsigned endp, void * buf, unsigned long buf_size); + (genode_usb_bus_num_t bus, genode_usb_dev_num_t dev, unsigned idx, + unsigned alt, unsigned endp, void * buf, unsigned long buf_size); struct genode_usb_rpc_callbacks { genode_usb_alloc_peer_buffer_t alloc_fn; @@ -99,13 +105,14 @@ void genode_usb_init(struct genode_env * env, ** USB device lifetime management ** ************************************/ -void genode_usb_announce_device(unsigned long vendor, - unsigned long product, - unsigned long cla, - unsigned long bus, - unsigned long dev); +void genode_usb_announce_device(genode_usb_vendor_id_t vendor, + genode_usb_product_id_t product, + genode_usb_class_num_t cla, + genode_usb_bus_num_t bus, + genode_usb_dev_num_t dev); -void genode_usb_discontinue_device(unsigned long bus, unsigned long dev); +void genode_usb_discontinue_device(genode_usb_bus_num_t bus, + genode_usb_dev_num_t dev); /********************************** @@ -201,8 +208,8 @@ struct genode_usb_request_callbacks { genode_usb_req_flush_t flush_fn; }; -genode_usb_session_handle_t genode_usb_session_by_bus_dev(unsigned long bus, - unsigned long dev); +genode_usb_session_handle_t genode_usb_session_by_bus_dev(genode_usb_bus_num_t bus, + genode_usb_dev_num_t dev); int genode_usb_request_by_session(genode_usb_session_handle_t session_handle, struct genode_usb_request_callbacks * const c, @@ -220,4 +227,3 @@ void genode_usb_notify_peers(void); #endif #endif /* _GENODE_C_API__USB_H_ */ - diff --git a/repos/os/include/gpio/component.h b/repos/os/include/gpio/component.h index 05326f5ea4..c34fb26cd9 100644 --- a/repos/os/include/gpio/component.h +++ b/repos/os/include/gpio/component.h @@ -120,7 +120,7 @@ class Gpio::Root : public Genode::Root_component Session_component *_create_session(const char *args) override { - unsigned pin = + unsigned pin = (unsigned) Genode::Arg_string::find_arg(args, "gpio").ulong_value(0); Genode::size_t ram_quota = Genode::Arg_string::find_arg(args, "ram_quota").ulong_value(0); diff --git a/repos/os/include/i2c_session/connection.h b/repos/os/include/i2c_session/connection.h index 9f748cda55..911546fcb4 100644 --- a/repos/os/include/i2c_session/connection.h +++ b/repos/os/include/i2c_session/connection.h @@ -37,22 +37,23 @@ struct I2c::Connection : Genode::Connection, I2c::Session_client uint8_t read_8bits() { - Transaction t { Message(Message::READ, 0) }; + Transaction t { Message(Message::READ, (uint8_t)0) }; transmit(t); return t.value(0).value(0); } void write_16bits(uint16_t word) { - Transaction t { Message(Message::WRITE, word & 0xff, word >> 8) }; + Transaction t { Message(Message::WRITE, (uint8_t)(word & 0xff), + (uint8_t)(word >> 8)) }; transmit(t); } uint16_t read_16bits() { - Transaction t { Message(Message::READ, 0, 0) }; + Transaction t { Message(Message::READ, (uint8_t)0, (uint8_t)0) }; transmit(t); - return t.value(0).value(0) | (t.value(0).value(1) << 8); + return (uint16_t)(t.value(0).value(0) | (t.value(0).value(1) << 8)); } }; diff --git a/repos/os/include/net/mac_address.h b/repos/os/include/net/mac_address.h index 6eb5217678..36c83166d3 100644 --- a/repos/os/include/net/mac_address.h +++ b/repos/os/include/net/mac_address.h @@ -53,7 +53,7 @@ Genode::size_t Net::ascii_to(char const *s, Net::Mac_address &mac) if (!is_digit(s[hi], HEX) || !is_digit(s[lo], HEX)) throw -1; - mac_str[i] = (digit(s[hi], HEX) << 4) | digit(s[lo], HEX); + mac_str[i] = (char)((digit(s[hi], HEX) << 4) | digit(s[lo], HEX)); } Genode::memcpy(mac.addr, mac_str, MAC_SIZE); diff --git a/repos/os/include/nitpicker_gfx/glyph_painter.h b/repos/os/include/nitpicker_gfx/glyph_painter.h index fdf3af2138..7f4e5b4045 100644 --- a/repos/os/include/nitpicker_gfx/glyph_painter.h +++ b/repos/os/include/nitpicker_gfx/glyph_painter.h @@ -29,7 +29,7 @@ struct Glyph_painter { int value; - Fixpoint_number(float value) : value(value*256) { }; + Fixpoint_number(float value) : value((int)(value*256)) { }; Fixpoint_number(int decimal) : value(decimal << 8) { }; diff --git a/repos/os/include/nitpicker_gfx/text_painter.h b/repos/os/include/nitpicker_gfx/text_painter.h index 34794553aa..3e1c7d0d5e 100644 --- a/repos/os/include/nitpicker_gfx/text_painter.h +++ b/repos/os/include/nitpicker_gfx/text_painter.h @@ -88,7 +88,8 @@ struct Text_painter /** * Compute width of UTF8 string in pixels when rendered with the font */ - Fixpoint_number string_width(Genode::Utf8_ptr utf8, unsigned len = ~0U) const + Fixpoint_number string_width(Genode::Utf8_ptr utf8, + Genode::size_t len = ~0UL) const { Fixpoint_number result { (int)0 }; diff --git a/repos/os/include/nitpicker_gfx/texture_painter.h b/repos/os/include/nitpicker_gfx/texture_painter.h index 471a61ef0a..d97a5779cd 100644 --- a/repos/os/include/nitpicker_gfx/texture_painter.h +++ b/repos/os/include/nitpicker_gfx/texture_painter.h @@ -88,9 +88,9 @@ struct Texture_painter * a plain pixel blit. */ if (texture.alpha() == 0 || !allow_alpha) { - blit(src, src_w*sizeof(PT), - dst, dst_w*sizeof(PT), - clipped.w()*sizeof(PT), clipped.h()); + blit(src, (unsigned)(src_w*sizeof(PT)), dst, + (int)(dst_w*sizeof(PT)), + (int)(clipped.w()*sizeof(PT)), clipped.h()); break; } diff --git a/repos/os/include/nitpicker_gfx/tff_font.h b/repos/os/include/nitpicker_gfx/tff_font.h index 3de0bccdbf..730fe5843d 100644 --- a/repos/os/include/nitpicker_gfx/tff_font.h +++ b/repos/os/include/nitpicker_gfx/tff_font.h @@ -168,7 +168,7 @@ class Tff_font : public Text_painter::Font throw Insufficient_glyph_buffer(); for (unsigned i = 0; i < NUM_GLYPHS; i++) - _vertical_metrics[i] = _tff.vertical_metrics(i); + _vertical_metrics[i] = _tff.vertical_metrics((unsigned char)i); } /** diff --git a/repos/os/include/os/packet_allocator.h b/repos/os/include/os/packet_allocator.h index 434738257b..173c44057a 100644 --- a/repos/os/include/os/packet_allocator.h +++ b/repos/os/include/os/packet_allocator.h @@ -49,12 +49,12 @@ class Genode::Packet_allocator : public Genode::Range_allocator * array to track the allocations. The bit count is rounded up/aligned * to the natural machine word bit size. */ - inline size_t _bits_cnt(size_t const size) + unsigned _bits_cnt(size_t const size) { - size_t const bits = sizeof(addr_t)*8; - size_t const cnt = size / _block_size; + unsigned const bits = (unsigned)sizeof(addr_t)*8; + unsigned const cnt = (unsigned)(size / _block_size); - size_t bits_aligned = cnt / bits; + unsigned bits_aligned = cnt / bits; if (cnt % bits) bits_aligned += 1; @@ -82,7 +82,7 @@ class Genode::Packet_allocator : public Genode::Range_allocator if (_base || _array) return Alloc_error::DENIED; - size_t const bits_cnt = _bits_cnt(size); + unsigned const bits_cnt = _bits_cnt(size); _base = base; diff --git a/repos/os/include/os/path.h b/repos/os/include/os/path.h index cfdc744a2f..1b929f26ef 100644 --- a/repos/os/include/os/path.h +++ b/repos/os/include/os/path.h @@ -121,7 +121,7 @@ class Genode::Path_base return 0; } - static void strip(char *dst, unsigned count) + static void strip(char *dst, size_t count) { for (char const *src = dst + count; *src; ) *dst++ = *src++; @@ -178,7 +178,7 @@ class Genode::Path_base _append("/"); } - void _strip_from_begin(unsigned count) { strip(_path, count); } + void _strip_from_begin(size_t count) { strip(_path, count); } protected: @@ -270,7 +270,7 @@ class Genode::Path_base bool strip_prefix(char const *prefix) { - unsigned prefix_len = strlen(prefix); + size_t prefix_len = strlen(prefix); if (strcmp(prefix, _path, prefix_len) != 0) return false; diff --git a/repos/os/include/os/pixel_alpha8.h b/repos/os/include/os/pixel_alpha8.h index 6056c1d2a7..b72732add3 100644 --- a/repos/os/include/os/pixel_alpha8.h +++ b/repos/os/include/os/pixel_alpha8.h @@ -18,7 +18,7 @@ namespace Genode { - typedef Genode::Pixel_rgba Pixel_alpha8; @@ -31,7 +31,7 @@ namespace Genode { inline Pixel_alpha8 Pixel_alpha8::mix(Pixel_alpha8 p1, PT, int alpha) { Pixel_alpha8 res; - res.pixel = p1.pixel + (((255 - p1.pixel)*alpha) >> 8); + res.pixel = (uint8_t)(p1.pixel + (((255 - p1.pixel)*alpha) >> 8)); return res; } diff --git a/repos/os/include/os/pixel_rgb565.h b/repos/os/include/os/pixel_rgb565.h index e37ccb32fa..eee3d745f1 100644 --- a/repos/os/include/os/pixel_rgb565.h +++ b/repos/os/include/os/pixel_rgb565.h @@ -18,7 +18,7 @@ namespace Genode { - typedef Pixel_rgba Pixel_rgb565; @@ -27,7 +27,8 @@ namespace Genode { inline Pixel_rgb565 Pixel_rgb565::avr(Pixel_rgb565 p1, Pixel_rgb565 p2) { Pixel_rgb565 res; - res.pixel = ((p1.pixel&0xf7df)>>1) + ((p2.pixel&0xf7df)>>1); + res.pixel = (uint16_t)(((p1.pixel&0xf7df)>>1) + + ((p2.pixel&0xf7df)>>1)); return res; } @@ -36,8 +37,8 @@ namespace Genode { inline Pixel_rgb565 Pixel_rgb565::blend(Pixel_rgb565 src, int alpha) { Pixel_rgb565 res; - res.pixel = ((((alpha >> 3) * (src.pixel & 0xf81f)) >> 5) & 0xf81f) - | ((( alpha * (src.pixel & 0x07c0)) >> 8) & 0x07c0); + res.pixel = (uint16_t)(((((alpha >> 3) * (src.pixel & 0xf81f)) >> 5) & 0xf81f) | + ((( alpha * (src.pixel & 0x07c0)) >> 8) & 0x07c0)); return res; } @@ -53,7 +54,8 @@ namespace Genode { * error of the blend function when having only 5 bits * per channel. */ - res.pixel = blend(p1, 264 - alpha).pixel + blend(p2, alpha).pixel; + res.pixel = (uint16_t)(blend(p1, 264 - alpha).pixel + + blend(p2, alpha).pixel); return res; } } diff --git a/repos/os/include/os/pixel_rgba.h b/repos/os/include/os/pixel_rgba.h index d17c39cfaa..7364e45627 100644 --- a/repos/os/include/os/pixel_rgba.h +++ b/repos/os/include/os/pixel_rgba.h @@ -59,11 +59,13 @@ class Genode::Pixel_rgba */ Pixel_rgba() {} - Pixel_rgba(int red, int green, int blue, int alpha = 255) : - pixel((_shift(red, r_shift) & r_mask) - | (_shift(green, g_shift) & g_mask) - | (_shift(blue, b_shift) & b_mask) - | (_shift(alpha, a_shift) & a_mask)) { } + Pixel_rgba(int red, int green, int blue, int alpha = 255) + : + pixel((ST)((_shift(red, r_shift) & r_mask) + | (_shift(green, g_shift) & g_mask) + | (_shift(blue, b_shift) & b_mask) + | (_shift(alpha, a_shift) & a_mask))) + { } static Surface_base::Pixel_format format() { return FORMAT; } diff --git a/repos/os/include/os/session_policy.h b/repos/os/include/os/session_policy.h index eb1659fde2..9885470640 100644 --- a/repos/os/include/os/session_policy.h +++ b/repos/os/include/os/session_policy.h @@ -46,8 +46,8 @@ struct Genode::Xml_node_label_score * If 0, there is a conflict. If 1, an empty string matched. */ enum { CONFLICT = 0 }; - unsigned prefix_match = CONFLICT; - unsigned suffix_match = CONFLICT; + size_t prefix_match = CONFLICT; + size_t suffix_match = CONFLICT; Xml_node_label_score() { } @@ -74,7 +74,7 @@ struct Genode::Xml_node_label_score Suffix const suffix = node.attribute_value("label_suffix", Suffix()); if (label.length() >= suffix.length()) { - unsigned const offset = label.length() - suffix.length(); + size_t const offset = label.length() - suffix.length(); if (!strcmp(label.string() + offset, suffix.string())) suffix_match = suffix.length(); diff --git a/repos/os/include/os/texture.h b/repos/os/include/os/texture.h index 0bd0d2457a..d5082fa48d 100644 --- a/repos/os/include/os/texture.h +++ b/repos/os/include/os/texture.h @@ -57,7 +57,7 @@ class Genode::Texture : public Texture_base /** * Import rgba data line into texture */ - inline void rgba(unsigned char const *rgba, unsigned len, int y); + inline void rgba(unsigned char const *rgba, size_t len, int y); }; #endif /* _INCLUDE__OS__TEXTURE_H_ */ diff --git a/repos/os/include/os/texture_rgb888.h b/repos/os/include/os/texture_rgb888.h index 355e0451a6..ff195eedf9 100644 --- a/repos/os/include/os/texture_rgb888.h +++ b/repos/os/include/os/texture_rgb888.h @@ -22,7 +22,7 @@ namespace Genode { template <> inline void - Texture::rgba(unsigned char const *rgba, unsigned len, int y) + Texture::rgba(unsigned char const *rgba, size_t len, int y) { if (len > size().w()) len = size().w(); if (y < 0 || y >= (int)size().h()) return; @@ -40,7 +40,7 @@ namespace Genode { dst_pixel[i].rgba(r, g, b); if (dst_alpha) - dst_alpha[i] = min(a, 255); + dst_alpha[i] = (unsigned char)min(a, 255); } } } diff --git a/repos/os/include/os/vfs.h b/repos/os/include/os/vfs.h index 9f8e7af3f9..8c9f23aee1 100644 --- a/repos/os/include/os/vfs.h +++ b/repos/os/include/os/vfs.h @@ -304,7 +304,7 @@ struct Genode::Directory : Noncopyable, Interface if (result != File_io_service::READ_OK) throw Nonexistent_file(); - return Path(Genode::Cstring(buf, out_count)); + return Path(Genode::Cstring(buf, (size_t)out_count)); } void unlink(Path const &rel_path) @@ -471,7 +471,7 @@ class Genode::Readonly_file : public File if (result != Vfs::File_io_service::READ_OK) throw Truncated_during_read(); - return out_count; + return (size_t)out_count; } /** @@ -531,7 +531,7 @@ class Genode::File_content File_content(Allocator &alloc, Directory const &dir, Path const &rel_path, Limit limit) : - _buffer(alloc, min(dir.file_size(rel_path), (Vfs::file_size)limit.value)) + _buffer(alloc, min((size_t)dir.file_size(rel_path), limit.value)) { Readonly_file file {dir, rel_path}; @@ -738,8 +738,8 @@ class Genode::New_file : Noncopyable break; case Write_result::WRITE_OK: - out_count = min(remaining_bytes, out_count); - remaining_bytes -= out_count; + out_count = min((Vfs::file_size)remaining_bytes, out_count); + remaining_bytes -= (size_t)out_count; src += out_count; _handle.advance_seek(out_count); break; diff --git a/repos/os/include/ram_fs/chunk.h b/repos/os/include/ram_fs/chunk.h index f0ebbd4f6f..214e92693e 100644 --- a/repos/os/include/ram_fs/chunk.h +++ b/repos/os/include/ram_fs/chunk.h @@ -147,7 +147,7 @@ class File_system::Chunk : public Chunk_base memcpy(&_data[local_offset], src, len); - _num_entries = max(_num_entries, local_offset + len); + _num_entries = max(_num_entries, (size_t)(local_offset + len)); } void read(char *dst, size_t len, seek_off_t seek_offset) const @@ -170,9 +170,9 @@ class File_system::Chunk : public Chunk_base if (local_offset >= _num_entries) return; - memset(&_data[local_offset], 0, _num_entries - local_offset); + memset(&_data[local_offset], 0, (size_t)(_num_entries - local_offset)); - _num_entries = local_offset; + _num_entries = (size_t)local_offset; } }; @@ -257,7 +257,7 @@ class File_system::Chunk_index : public Chunk_base */ unsigned _index_by_offset(seek_off_t offset) const { - return (offset - base_offset()) / ENTRY_SIZE; + return (unsigned)((offset - base_offset()) / ENTRY_SIZE); } /** @@ -295,11 +295,11 @@ class File_system::Chunk_index : public Chunk_base seek_offset - obj.base_offset() - index*ENTRY_SIZE; /* available capacity at 'entry' starting at seek offset */ - seek_off_t const capacity = ENTRY_SIZE - local_seek_offset; - seek_off_t const curr_len = min(len, capacity); + size_t const capacity = ENTRY_SIZE - (size_t)local_seek_offset; + size_t const curr_len = min(len, capacity); /* apply functor (read or write) to entry */ - func(entry, data, curr_len, seek_offset); + func(entry, data, (size_t)curr_len, seek_offset); /* advance to next entry */ len -= curr_len; diff --git a/repos/os/include/smbios/smbios.h b/repos/os/include/smbios/smbios.h index c4ca242b15..0bd33a62a1 100644 --- a/repos/os/include/smbios/smbios.h +++ b/repos/os/include/smbios/smbios.h @@ -27,7 +27,7 @@ namespace Genode { { uint8_t sum { 0 }; for (uint8_t idx = 0; idx < size; idx++) { - sum += base[idx]; + sum = (uint8_t)(sum + base[idx]); } return sum == 0; } diff --git a/repos/os/include/terminal/char_cell_array_character_screen.h b/repos/os/include/terminal/char_cell_array_character_screen.h index 5d397b9565..55d188ffde 100644 --- a/repos/os/include/terminal/char_cell_array_character_screen.h +++ b/repos/os/include/terminal/char_cell_array_character_screen.h @@ -38,8 +38,8 @@ struct Char_cell int colidx, bool inv, bool highlight) : value(c.value), - attr(f.attr_bits() | (inv ? ATTR_INVERSE : 0) - | (highlight ? ATTR_HIGHLIGHT : 0)), + attr((unsigned char)(f.attr_bits() | (inv ? ATTR_INVERSE : 0) + | (highlight ? ATTR_HIGHLIGHT : 0))), color(colidx & COLOR_MASK) { } @@ -54,7 +54,7 @@ struct Char_cell bool highlight() const { return attr & ATTR_HIGHLIGHT; } void set_cursor() { attr |= ATTR_CURSOR; } - void clear_cursor() { attr &= ~ATTR_CURSOR; } + void clear_cursor() { attr &= (unsigned char)(~ATTR_CURSOR); } bool has_cursor() const { return attr & ATTR_CURSOR; } diff --git a/repos/os/include/terminal/decoder.h b/repos/os/include/terminal/decoder.h index d363634115..06e1948bca 100644 --- a/repos/os/include/terminal/decoder.h +++ b/repos/os/include/terminal/decoder.h @@ -94,9 +94,9 @@ class Terminal::Decoder if (type == NUMBER) { Genode::print(out, value); } else if (state == STATE_ESC_ECMA) { - Ecma(value).print(out); + Ecma((unsigned char)value).print(out); } else { - Ascii(value).print(out); + Ascii((unsigned char)value).print(out); } } @@ -290,8 +290,8 @@ class Terminal::Decoder || (_escape_stack[1].type != Escape_stack::Entry::NUMBER)) return false; - int const p1 = _escape_stack[1].value; - char const command = _escape_stack[2].value; + int const p1 = _escape_stack[1].value; + int const command = _escape_stack[2].value; switch (command) { case 'A': return (_screen.cuu(p1), true); @@ -330,8 +330,8 @@ class Terminal::Decoder || (_escape_stack[2].type != Escape_stack::Entry::NUMBER)) return false; - int const p1 = _escape_stack[2].value; - char const command = _escape_stack[3].value; + int const p1 = _escape_stack[2].value; + int const command = _escape_stack[3].value; switch (command) { case 'h': return (_screen.decsm(p1), true); @@ -508,7 +508,7 @@ class Terminal::Decoder _enter_state_esc_ecma(); break; } - Genode::error("unknown CSI ESC", Ascii(c)); + Genode::error("unknown CSI ESC", Ascii((unsigned char)c)); _enter_state_idle(); } @@ -523,8 +523,8 @@ class Terminal::Decoder */ /* check for start of a number argument */ - if (is_digit(c)) { - _append_to_number(c); + if (is_digit((char)c)) { + _append_to_number((char)c); } else /* non-number character of escape sequence */ diff --git a/repos/os/include/terminal/font_face.h b/repos/os/include/terminal/font_face.h index 5777383ee3..cd974eb70f 100644 --- a/repos/os/include/terminal/font_face.h +++ b/repos/os/include/terminal/font_face.h @@ -30,7 +30,7 @@ class Font_face static unsigned char attr_mask() { return 3; } - unsigned char attr_bits() const { return _type & attr_mask(); } + unsigned char attr_bits() const { return (unsigned char)(_type & attr_mask()); } }; #endif /* _TERMINAL__FONT_FACE_H_ */ diff --git a/repos/os/include/terminal/print.h b/repos/os/include/terminal/print.h index 3756128543..e84eb91f8a 100644 --- a/repos/os/include/terminal/print.h +++ b/repos/os/include/terminal/print.h @@ -66,8 +66,7 @@ namespace Terminal { { unsigned char const _c; - template - explicit Ascii(T c) : _c(c) { } + explicit Ascii(unsigned char c) : _c(c) { } void print(Genode::Output &out) const { @@ -120,8 +119,7 @@ namespace Terminal { { unsigned char const _c; - template - explicit Ecma(T c) : _c(c) { } + explicit Ecma(unsigned char c) : _c(c) { } void print(Genode::Output &out) const { diff --git a/repos/os/include/terminal/types.h b/repos/os/include/terminal/types.h index dd8c46a21b..e08014219d 100644 --- a/repos/os/include/terminal/types.h +++ b/repos/os/include/terminal/types.h @@ -29,17 +29,16 @@ namespace Terminal { } -/* - * The character definition is wrapped in a compound data structure to make - * the implementation easily changeable to unicode later. - */ struct Terminal::Character { - Genode::uint16_t value; + using value_t = Genode::uint16_t; + + value_t value = 0; + + Character() { } - Character() : value(0) { } Character(Codepoint cp) - : value(cp.value < 1<<16 ? cp.value : 0) { } + : value((value_t)(cp.value < (1<<16) ? cp.value : 0)) { } bool valid() const { return value != 0; } }; diff --git a/repos/os/include/trace/trace_buffer.h b/repos/os/include/trace/trace_buffer.h index 99ebfce2b4..513fbed94c 100644 --- a/repos/os/include/trace/trace_buffer.h +++ b/repos/os/include/trace/trace_buffer.h @@ -47,7 +47,7 @@ class Trace_buffer warning("buffer wrapped multiple times; you might want to raise buffer size; curr_count=", _buffer.wrapped(), " last_count=", _wrapped_count); } - _wrapped_count = _buffer.wrapped(); + _wrapped_count = (unsigned)_buffer.wrapped(); } Trace::Buffer::Entry new_curr { _curr }; diff --git a/repos/os/include/uart_session/uart_session.h b/repos/os/include/uart_session/uart_session.h index 1b53a7888f..5f78e47dc3 100644 --- a/repos/os/include/uart_session/uart_session.h +++ b/repos/os/include/uart_session/uart_session.h @@ -22,6 +22,7 @@ namespace Uart { using namespace Terminal; + using namespace Genode; struct Session; } @@ -37,14 +38,14 @@ struct Uart::Session : Terminal::Session /** * Set baud rate */ - virtual void baud_rate(Genode::size_t bits_per_second) = 0; + virtual void baud_rate(size_t bits_per_second) = 0; /******************* ** RPC interface ** *******************/ - GENODE_RPC(Rpc_baud_rate, void, baud_rate, Genode::size_t); + GENODE_RPC(Rpc_baud_rate, void, baud_rate, size_t); GENODE_RPC_INTERFACE_INHERIT(Terminal::Session, Rpc_baud_rate); }; diff --git a/repos/os/include/usb/types.h b/repos/os/include/usb/types.h index ab17e20fab..cfd070d167 100644 --- a/repos/os/include/usb/types.h +++ b/repos/os/include/usb/types.h @@ -100,7 +100,7 @@ struct Usb::String len = Genode::min(length, len); for (unsigned i = 0; i < len; i++) - buffer[i] = string[i] & 0xff; + buffer[i] = (char)(string[i] & 0xff); buffer[len] = 0; return buffer; diff --git a/repos/os/include/util/dirty_rect.h b/repos/os/include/util/dirty_rect.h index 403f77d3fd..db7479d035 100644 --- a/repos/os/include/util/dirty_rect.h +++ b/repos/os/include/util/dirty_rect.h @@ -50,7 +50,7 @@ class Genode::Dirty_rect /** * Return the costs of adding a new to an existing rectangle */ - static unsigned _costs(Rect const &existing, Rect const &added) + static size_t _costs(Rect const &existing, Rect const &added) { /* * If 'existing' is unused, using it will cost the area of the diff --git a/repos/os/include/util/endian.h b/repos/os/include/util/endian.h index 51bdfc6626..5455303545 100644 --- a/repos/os/include/util/endian.h +++ b/repos/os/include/util/endian.h @@ -20,9 +20,12 @@ template inline T host_to_big_endian(T x) { Genode::uint8_t v[sizeof(T)]; - for (unsigned i=0; i> mask; + + for (unsigned i = 0; i < sizeof(T); i++) { + + unsigned const shift = ((unsigned)sizeof(T) - i - 1) * 8; + + v[i] = (Genode::uint8_t)((x & (0xffu << shift)) >> shift); } return *(T *)v; } diff --git a/repos/os/include/util/utf8.h b/repos/os/include/util/utf8.h index 0caa452ec2..b2304c8b1d 100644 --- a/repos/os/include/util/utf8.h +++ b/repos/os/include/util/utf8.h @@ -41,19 +41,19 @@ struct Genode::Codepoint output.out_char(bits( 0, 7)); } else if (value < 1<<11) { - output.out_char(bits( 6, 5) | 0xc0); - output.out_char(bits( 0, 6) | 0x80); + output.out_char(bits( 6, 5) | (char)0xc0); + output.out_char(bits( 0, 6) | (char)0x80); } else if (value < 1<<16) { - output.out_char(bits(12, 4) | 0xe0); - output.out_char(bits( 6, 6) | 0x80); - output.out_char(bits( 0, 6) | 0x80); + output.out_char(bits(12, 4) | (char)0xe0); + output.out_char(bits( 6, 6) | (char)0x80); + output.out_char(bits( 0, 6) | (char)0x80); } else if (value < 0x11<<16) { - output.out_char(bits(18, 3) | 0xf0); - output.out_char(bits(12, 6) | 0x80); - output.out_char(bits( 6, 6) | 0x80); - output.out_char(bits( 0, 6) | 0x80); + output.out_char(bits(18, 3) | (char)0xf0); + output.out_char(bits(12, 6) | (char)0x80); + output.out_char(bits( 6, 6) | (char)0x80); + output.out_char(bits( 0, 6) | (char)0x80); } } }; diff --git a/repos/os/include/vfs/dir_file_system.h b/repos/os/include/vfs/dir_file_system.h index 9665be3e4a..c2e7160277 100644 --- a/repos/os/include/vfs/dir_file_system.h +++ b/repos/os/include/vfs/dir_file_system.h @@ -299,7 +299,7 @@ class Vfs::Dir_file_system : public File_system * Determine number of matching directory entries within * the current file system. */ - int const fs_num_dirent = vfs_handle.ds().num_dirent(sub_path); + int const fs_num_dirent = (int)vfs_handle.ds().num_dirent(sub_path); /* * Query directory entry if index lies with the file diff --git a/repos/os/include/vfs/readonly_value_file_system.h b/repos/os/include/vfs/readonly_value_file_system.h index 6ca1cab331..5772c6aa31 100644 --- a/repos/os/include/vfs/readonly_value_file_system.h +++ b/repos/os/include/vfs/readonly_value_file_system.h @@ -59,8 +59,8 @@ class Vfs::Readonly_value_file_system : public Vfs::Single_file_system if (seek() > _buffer.length()) return READ_ERR_INVALID; - char const * const src = _buffer.string() + seek(); - Genode::size_t const len = min(_buffer.length() - seek(), count); + char const * const src = _buffer.string() + seek(); + size_t const len = min((size_t)(_buffer.length() - seek()), (size_t)count); Genode::memcpy(dst, src, len); out_count = len; diff --git a/repos/os/include/vfs/types.h b/repos/os/include/vfs/types.h index 19376d8b94..51ba3c3210 100644 --- a/repos/os/include/vfs/types.h +++ b/repos/os/include/vfs/types.h @@ -48,6 +48,7 @@ namespace Vfs { using Genode::static_cap_cast; using Genode::Interface; using Genode::String; + using Genode::size_t; struct Timestamp { diff --git a/repos/os/include/vfs/value_file_system.h b/repos/os/include/vfs/value_file_system.h index 20f3593b2c..1dbd453d7d 100644 --- a/repos/os/include/vfs/value_file_system.h +++ b/repos/os/include/vfs/value_file_system.h @@ -61,7 +61,7 @@ class Vfs::Value_file_system : public Vfs::Single_file_system return READ_ERR_INVALID; char const * const src = _buffer.string() + seek(); - Genode::size_t const len = min(_buffer.length() - seek(), count); + Genode::size_t const len = min((size_t)(_buffer.length() - seek()), (size_t)count); Genode::memcpy(dst, src, len); out_count = len; @@ -74,7 +74,7 @@ class Vfs::Value_file_system : public Vfs::Single_file_system if (seek() > BUF_SIZE) return WRITE_ERR_INVALID; - Genode::size_t const len = min(BUF_SIZE- seek(), count); + Genode::size_t const len = min((size_t)(BUF_SIZE- seek()), (size_t)count); _buffer = Buffer(Genode::Cstring(src, len)); out_count = len; diff --git a/repos/os/include/virtio/mmio_device.h b/repos/os/include/virtio/mmio_device.h index 3ebfc466e6..4ee4d448bd 100644 --- a/repos/os/include/virtio/mmio_device.h +++ b/repos/os/include/virtio/mmio_device.h @@ -137,7 +137,7 @@ class Virtio::Device : Platform::Device::Mmio write(queue_index); if (read() != 0) { return 0; } - return read(); + return (uint16_t)read(); } uint32_t read_config(uint8_t offset, Access_size size) @@ -153,9 +153,9 @@ class Virtio::Device : Platform::Device::Mmio void write_config(uint8_t offset, Access_size size, uint32_t value) { switch (size) { - case ACCESS_8BIT: write(value, offset); break; - case ACCESS_16BIT: write(value, (offset >> 1)); break; - case ACCESS_32BIT: write(value, (offset >> 2)); break; + case ACCESS_8BIT: write ((uint8_t) value, offset); break; + case ACCESS_16BIT: write((uint16_t)value, (offset >> 1)); break; + case ACCESS_32BIT: write(value, (offset >> 2)); break; } } diff --git a/repos/os/include/virtio/queue.h b/repos/os/include/virtio/queue.h index a4df06a523..bdc5351055 100644 --- a/repos/os/include/virtio/queue.h +++ b/repos/os/include/virtio/queue.h @@ -208,7 +208,7 @@ class Virtio::Queue auto const used_idx = _used->idx; auto const avail_idx = _avail->idx; if (avail_idx >= used_idx) { - return _queue_size - avail_idx + used_idx; + return (Genode::uint16_t)(_queue_size - avail_idx + used_idx); } else { return used_idx - avail_idx; } @@ -266,7 +266,7 @@ class Virtio::Queue static_assert(!TRAITS::device_write_only); static_assert(TRAITS::has_data_payload); - const int req_desc_count = 1 + (sizeof(header) + data_size) / _buffer_size; + Genode::size_t const req_desc_count = 1 + (sizeof(header) + data_size) / _buffer_size; if (req_desc_count > _avail_capacity()) return false; @@ -392,7 +392,7 @@ class Virtio::Queue static_assert(!TRAITS::device_write_only); static_assert(TRAITS::has_data_payload); - int req_desc_count = 1 + (sizeof(header) + data_size) / _buffer_size; + Genode::size_t const req_desc_count = 1 + (sizeof(header) + data_size) / _buffer_size; if (req_desc_count > _avail_capacity()) return false; @@ -417,7 +417,7 @@ class Virtio::Queue if (data != nullptr && data_size > 0) { len = Genode::min(_buffer_size - sizeof(header), data_size); Genode::memcpy((char *)_buffer_local_addr(desc) + desc->len, data, len); - desc->len += len; + desc->len += (Genode::uint32_t)len; len = data_size + sizeof(header) - desc->len; } @@ -433,11 +433,11 @@ class Virtio::Queue desc = &_desc_table[avail_idx % _queue_size]; avail_idx++; - Genode::size_t write_len = Genode::min(_buffer_size, len); + Genode::size_t write_len = Genode::min((Genode::size_t)_buffer_size, len); Genode::memcpy((char *)_buffer_local_addr(desc), data + data_offset, write_len); - desc->len = write_len; + desc->len = (Genode::uint32_t)write_len; desc->flags = len > 0 ? Descriptor::Flags::NEXT : 0; desc->next = len > 0 ? (avail_idx % _queue_size) : 0; diff --git a/repos/os/lib/mk/net.mk b/repos/os/lib/mk/net.mk index cf4dbbd0e1..74db51e450 100644 --- a/repos/os/lib/mk/net.mk +++ b/repos/os/lib/mk/net.mk @@ -1,4 +1,6 @@ SRC_CC += ethernet.cc ipv4.cc dhcp.cc arp.cc udp.cc tcp.cc SRC_CC += icmp.cc internet_checksum.cc +CC_CXX_WARN_STRICT_CONVERSION = + vpath %.cc $(REP_DIR)/src/lib/net diff --git a/repos/os/src/app/block_tester/main.cc b/repos/os/src/app/block_tester/main.cc index a23d11ace9..4ed42cea7d 100644 --- a/repos/os/src/app/block_tester/main.cc +++ b/repos/os/src/app/block_tester/main.cc @@ -68,9 +68,9 @@ struct Test::Result size_t triggered { 0 }; bool success { false }; - bool calculate { false }; - float mibs { 0.0f }; - float iops { 0.0f }; + bool calculate { false }; + double mibs { 0.0f }; + double iops { 0.0f }; Result() { } @@ -200,7 +200,7 @@ struct Test::Test_base : private Genode::Fifo::Element /** * Block::Connection::Update_jobs_policy */ - void produce_write_content(Job &job, off_t offset, char *dst, size_t length) + void produce_write_content(Job &job, Block::seek_off_t offset, char *dst, size_t length) { _tx += length / _info.block_size; _bytes += length; @@ -215,7 +215,7 @@ struct Test::Test_base : private Genode::Fifo::Element /** * Block::Connection::Update_jobs_policy */ - void consume_read_result(Job &job, off_t offset, + void consume_read_result(Job &job, Block::seek_off_t offset, char const *src, size_t length) { _rx += length / _info.block_size; diff --git a/repos/os/src/app/block_tester/test_ping_pong.h b/repos/os/src/app/block_tester/test_ping_pong.h index 10e2a92724..d1fc13a8a8 100644 --- a/repos/os/src/app/block_tester/test_ping_pong.h +++ b/repos/os/src/app/block_tester/test_ping_pong.h @@ -63,7 +63,7 @@ struct Test::Ping_pong : Test_base throw Constructing_test_failed(); } - size_t const total_bytes = _info.block_count * _info.block_size; + size_t const total_bytes = (size_t)_info.block_count * _info.block_size; if (_length > total_bytes - (_start * _info.block_size)) { error("length too large invalid"); throw Constructing_test_failed(); diff --git a/repos/os/src/app/block_tester/test_random.h b/repos/os/src/app/block_tester/test_random.h index f9fdfbe22a..93ff964d04 100644 --- a/repos/os/src/app/block_tester/test_random.h +++ b/repos/os/src/app/block_tester/test_random.h @@ -132,8 +132,8 @@ struct Test::Random : Test_base _alternate_access = w && r; - _size_in_blocks = _size / _info.block_size; - _length_in_blocks = _length / _info.block_size; + _size_in_blocks = _size / _info.block_size; + _length_in_blocks = (size_t)(_length / _info.block_size); } void _spawn_job() override diff --git a/repos/os/src/app/cpu_burner/main.cc b/repos/os/src/app/cpu_burner/main.cc index c0e52891a2..bd40ebcbed 100644 --- a/repos/os/src/app/cpu_burner/main.cc +++ b/repos/os/src/app/cpu_burner/main.cc @@ -67,7 +67,7 @@ struct Cpu_burner if (!_config.valid()) return; - _percent = _config.xml().attribute_value("percent", 100L); + _percent = _config.xml().attribute_value("percent", (unsigned short)100); if (_percent > 100) _percent = 100; } diff --git a/repos/os/src/app/dummy/main.cc b/repos/os/src/app/dummy/main.cc index 17cfb6c84e..0784b75fda 100644 --- a/repos/os/src/app/dummy/main.cc +++ b/repos/os/src/app/dummy/main.cc @@ -150,7 +150,7 @@ struct Dummy::Log_connections Log_connections(Env &env, Xml_node node) : _env(env) { - unsigned const count = node.attribute_value("count", 0UL); + unsigned const count = node.attribute_value("count", 0U); Number_of_bytes const ram_upgrade = node.attribute_value("ram_upgrade", Number_of_bytes()); diff --git a/repos/os/src/app/log_core/component.cc b/repos/os/src/app/log_core/component.cc index ce2bd0faf7..9175d8ea0e 100644 --- a/repos/os/src/app/log_core/component.cc +++ b/repos/os/src/app/log_core/component.cc @@ -31,7 +31,10 @@ class Log unsigned short _buf_pos { 0 }; unsigned _rom_pos { 0 }; - unsigned log_size() const { return _rom_ds.size() - sizeof(_rom_pos); } + unsigned log_size() const + { + return (unsigned)(_rom_ds.size() - sizeof(_rom_pos)); + } char const * char_from_rom(unsigned offset = 0) const { diff --git a/repos/os/src/app/ping/target.mk b/repos/os/src/app/ping/target.mk index b50be39100..24175d635d 100644 --- a/repos/os/src/app/ping/target.mk +++ b/repos/os/src/app/ping/target.mk @@ -8,3 +8,5 @@ SRC_CC += nic.cc ipv4_config.cc INC_DIR += $(PRG_DIR) CONFIG_XSD = config.xsd + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/app/rom_logger/main.cc b/repos/os/src/app/rom_logger/main.cc index f0f791f5e2..8448e28d22 100644 --- a/repos/os/src/app/rom_logger/main.cc +++ b/repos/os/src/app/rom_logger/main.cc @@ -109,7 +109,7 @@ void Rom_logger::Main::_handle_update() } else if (format == "hexdump") { short const *data = _rom_ds->local_addr(); /* dataspaces are always page aligned, therefore multiples of 2*8 bytes */ - Genode::uint32_t const data_len = _rom_ds->size() / sizeof(short); + Genode::size_t const data_len = _rom_ds->size() / sizeof(short); for (Genode::uint32_t i = 0; i < data_len; i += 8) log(mkhex(i)," ",mkhex(data[i+0])," ",mkhex(data[i+1]), " ",mkhex(data[i+2])," ",mkhex(data[i+3]), diff --git a/repos/os/src/app/top/main.cc b/repos/os/src/app/top/main.cc index 44705589a3..ebdd3aae8b 100644 --- a/repos/os/src/app/top/main.cc +++ b/repos/os/src/app/top/main.cc @@ -213,21 +213,21 @@ struct Trace_subject_registry Entry const &entry = *load[x][y][i]; - unsigned ec_percent = entry.recent_time[first] * 100 / total_first[x][y]; - unsigned ec_rest = entry.recent_time[first] * 10000 / total_first[x][y] - (ec_percent * 100); + unsigned ec_percent = (unsigned)(entry.recent_time[first] * 100 / total_first[x][y]); + unsigned ec_rest = (unsigned)(entry.recent_time[first] * 10000 / total_first[x][y] - (ec_percent * 100)); unsigned sc_percent = 0; unsigned sc_rest = 0; if (total_second[x][y]) { - sc_percent = entry.recent_time[second] * 100 / total_second[x][y]; - sc_rest = entry.recent_time[second] * 10000 / total_second[x][y] - (sc_percent * 100); + sc_percent = (unsigned)(entry.recent_time[second] * 100 / total_second[x][y]); + sc_rest = (unsigned)(entry.recent_time[second] * 10000 / total_second[x][y] - (sc_percent * 100)); } enum { NAME_SPACE = 24 }; static char space[NAME_SPACE]; Genode::memset(space, ' ', NAME_SPACE - 1); - unsigned thread_name_len = entry.info.thread_name().length(); + Genode::size_t const thread_name_len = entry.info.thread_name().length(); if (!thread_name_len) space[NAME_SPACE - 1] = 0; else diff --git a/repos/os/src/app/trace_subject_reporter/main.cc b/repos/os/src/app/trace_subject_reporter/main.cc index 22832d8d17..d2e2946e5a 100644 --- a/repos/os/src/app/trace_subject_reporter/main.cc +++ b/repos/os/src/app/trace_subject_reporter/main.cc @@ -83,7 +83,7 @@ struct Trace_subject_registry unsigned update_subjects(Genode::Trace::Connection &trace) { - return Genode::retry( + return (unsigned)Genode::retry( [&] () { return trace.subjects(_subjects, MAX_SUBJECTS); }, [&] () { trace.upgrade_ram(4096); } ); diff --git a/repos/os/src/app/usb_report_filter/main.cc b/repos/os/src/app/usb_report_filter/main.cc index 37483171c5..1ac9787a4b 100644 --- a/repos/os/src/app/usb_report_filter/main.cc +++ b/repos/os/src/app/usb_report_filter/main.cc @@ -93,8 +93,8 @@ class Usb_filter::Device_registry } } - static inline unsigned _get_value(Xml_node node, char const * const attr) { - return node.attribute_value(attr, 0); } + static unsigned _get_value(Xml_node node, char const * const attr) { + return node.attribute_value(attr, 0U); } static bool _config_has_device(Xml_node config, Entry const &entry) { diff --git a/repos/os/src/drivers/acpi/spec/x86/target.mk b/repos/os/src/drivers/acpi/spec/x86/target.mk index c8ee90bb07..831a337726 100644 --- a/repos/os/src/drivers/acpi/spec/x86/target.mk +++ b/repos/os/src/drivers/acpi/spec/x86/target.mk @@ -8,3 +8,5 @@ INC_DIR = $(PRG_DIR)/../.. vpath main.cc $(PRG_DIR)/../.. vpath acpi.cc $(PRG_DIR)/../.. vpath smbios_table_reporter.cc $(PRG_DIR)/../.. + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/drivers/ahci/ahci.h b/repos/os/src/drivers/ahci/ahci.h index 123367fb5f..c529a556c6 100644 --- a/repos/os/src/drivers/ahci/ahci.h +++ b/repos/os/src/drivers/ahci/ahci.h @@ -235,7 +235,7 @@ namespace Ahci { /* read_dma_ext : write_dma_ext */ write(read ? 0x25 : 0x35); write(block_number); - write(block_count); + write((uint16_t)(block_count)); } void fpdma(bool read, block_number_t block_number, block_count_t block_count, @@ -246,8 +246,8 @@ namespace Ahci { /* read_fpdma : write_fpdma */ write(read ? 0x60 : 0x61); write(block_number); - write(block_count); - write(slot); + write((uint16_t)block_count); + write((uint8_t)slot); } void flush_cache_ext() @@ -269,8 +269,8 @@ namespace Ahci { */ void byte_count(uint16_t bytes) { - write(bytes & 0xff); - write(bytes >> 8); + write ((uint8_t)(bytes & 0xff)); + write((uint8_t)((bytes >> 8) & 0xff)); } }; @@ -299,8 +299,8 @@ namespace Ahci { void cmd_table_base(addr_t base_phys) { uint64_t addr = base_phys; - write(addr); - write(addr >> 32); + write((uint32_t)addr); + write((uint32_t)(addr >> 32)); write(1); write(Command_fis::size() / sizeof(unsigned)); } @@ -364,8 +364,8 @@ namespace Ahci { void read10(block_number_t block_number, block_count_t block_count) { write(0x28); - write(block_number); - write(block_count); + write((uint32_t)block_number); + write((uint16_t)block_count); } void start_unit() @@ -393,9 +393,9 @@ namespace Ahci { : Mmio(base) { uint64_t addr = phys; - write(addr); - write(addr >> 32); - write(bytes > 0 ? bytes - 1 : 0); + write((uint32_t)addr); + write((uint32_t)(addr >> 32)); + write((uint32_t)(bytes > 0 ? bytes - 1 : 0)); } static constexpr size_t size() { return 0x10; } @@ -564,8 +564,8 @@ struct Ahci::Port : private Port_base void command_list_base(addr_t phys) { uint64_t addr = phys; - write(addr); - write(addr >> 32); + write ((uint32_t)(addr)); + write((uint32_t)(addr >> 32)); } /** @@ -581,8 +581,8 @@ struct Ahci::Port : private Port_base void fis_rcv_base(addr_t phys) { uint64_t addr = phys; - write(addr); - write(addr >> 32); + write ((uint32_t)(addr)); + write((uint32_t)(addr >> 32)); } /** diff --git a/repos/os/src/drivers/ahci/spec/x86/platform.cc b/repos/os/src/drivers/ahci/spec/x86/platform.cc index 0375ea46f2..a1b82254bd 100644 --- a/repos/os/src/drivers/ahci/spec/x86/platform.cc +++ b/repos/os/src/drivers/ahci/spec/x86/platform.cc @@ -35,7 +35,7 @@ Ahci::Data::Data(Env &env) Io_mem_session_capability iomem_cap = pci_device->io_mem(pci_device->phys_bar_to_virt(AHCI_BASE_ID)); iomem.construct(env.rm(), Io_mem_session_client(iomem_cap).dataspace()); - uint16_t cmd = pci_device->config_read(PCI_CMD, ::Platform::Device::ACCESS_16BIT); + uint16_t cmd = (uint16_t)pci_device->config_read(PCI_CMD, ::Platform::Device::ACCESS_16BIT); cmd |= 0x2; /* respond to memory space accesses */ cmd |= 0x4; /* enable bus master */ _config_write(PCI_CMD, cmd, ::Platform::Device::ACCESS_16BIT); diff --git a/repos/os/src/drivers/ahci/target.inc b/repos/os/src/drivers/ahci/target.inc index a510cd8753..dee2052fcc 100644 --- a/repos/os/src/drivers/ahci/target.inc +++ b/repos/os/src/drivers/ahci/target.inc @@ -2,5 +2,7 @@ SRC_CC += main.cc platform.cc INC_DIR += $(REP_DIR)/src/drivers/ahci LIBS += base +CC_CXX_WARN_STRICT_CONVERSION = + vpath platform.cc $(PRG_DIR) vpath %.cc $(REP_DIR)/src/drivers/ahci diff --git a/repos/os/src/drivers/audio/spec/linux/main.cc b/repos/os/src/drivers/audio/spec/linux/main.cc index 83e50cd260..c560230e3c 100644 --- a/repos/os/src/drivers/audio/spec/linux/main.cc +++ b/repos/os/src/drivers/audio/spec/linux/main.cc @@ -148,8 +148,8 @@ class Audio_out::Out if (p_left->valid() && p_right->valid()) { for (unsigned i = 0; i < 2 * PERIOD; i += 2) { - data[i] = p_left->content()[i / 2] * 32767; - data[i + 1] = p_right->content()[i / 2] * 32767; + data[i] = (short)(p_left ->content()[i / 2] * 32767.0f); + data[i + 1] = (short)(p_right->content()[i / 2] * 32767.0f); } p_left->invalidate(); diff --git a/repos/os/src/drivers/framebuffer/imx53/target.mk b/repos/os/src/drivers/framebuffer/imx53/target.mk index 2e62821a89..16ea999700 100644 --- a/repos/os/src/drivers/framebuffer/imx53/target.mk +++ b/repos/os/src/drivers/framebuffer/imx53/target.mk @@ -4,3 +4,5 @@ SRC_CC = main.cc LIBS = base blit INC_DIR += $(PRG_DIR) INC_DIR += $(call select_from_repositories,include/spec/imx53) + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/drivers/framebuffer/sdl/main.cc b/repos/os/src/drivers/framebuffer/sdl/main.cc index 3cf8575e06..e4b31c59ea 100644 --- a/repos/os/src/drivers/framebuffer/sdl/main.cc +++ b/repos/os/src/drivers/framebuffer/sdl/main.cc @@ -20,7 +20,10 @@ #include /* Linux includes */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" #include +#pragma GCC diagnostic pop /* local includes */ #include "convert_keycode.h" diff --git a/repos/os/src/drivers/framebuffer/virtio/component.h b/repos/os/src/drivers/framebuffer/virtio/component.h index d36f7bd803..347c3fe713 100644 --- a/repos/os/src/drivers/framebuffer/virtio/component.h +++ b/repos/os/src/drivers/framebuffer/virtio/component.h @@ -473,7 +473,7 @@ class Virtio_fb::Driver Control_header cmd { Control_header::CMD_GET_DISPLAY_INFO }; auto display_info_cb = [&](Display_info const &info) { - for (size_t i = 0; i < _num_scanouts; ++i) { + for (uint32_t i = 0; i < _num_scanouts; ++i) { if (info.modes[i].enabled) { if (use_current_scanout && (_selected_scanout_id != i)) continue; diff --git a/repos/os/src/drivers/gpu/intel/context.h b/repos/os/src/drivers/gpu/intel/context.h index 33518ba013..f18471aa83 100644 --- a/repos/os/src/drivers/gpu/intel/context.h +++ b/repos/os/src/drivers/gpu/intel/context.h @@ -390,7 +390,9 @@ class Igd::Execlist_context : public Igd::Common_context_regs { typename Ring_buffer_start_value::access_t v = read(); /* shift ring_buffer_start value accordingly */ - typename Ring_buffer_start_value::access_t const addr = Ring_buffer_start_value::Starting_address::get(ring_buffer_start); + typename Ring_buffer_start_value::access_t const addr = + (uint32_t)Ring_buffer_start_value::Starting_address::get(ring_buffer_start); + Ring_buffer_start_value::Starting_address::set(v, addr); write(v); } diff --git a/repos/os/src/drivers/gpu/intel/mmio.h b/repos/os/src/drivers/gpu/intel/mmio.h index 313a745322..44eea1536f 100644 --- a/repos/os/src/drivers/gpu/intel/mmio.h +++ b/repos/os/src/drivers/gpu/intel/mmio.h @@ -1289,8 +1289,8 @@ class Igd::Mmio : public Genode::Mmio v |= (p[i] & 0xff) << (8 * i); } - write(v); - write(v >> 32); + write((uint32_t)(v)); + write((uint32_t)(v >> 32)); } /** diff --git a/repos/os/src/drivers/gpu/intel/target.mk b/repos/os/src/drivers/gpu/intel/target.mk index 5600a10ef6..57f525b19e 100644 --- a/repos/os/src/drivers/gpu/intel/target.mk +++ b/repos/os/src/drivers/gpu/intel/target.mk @@ -5,3 +5,5 @@ LIBS = base REQUIRES = x86 INC_DIR += $(PRG_DIR) + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/drivers/i2c/imx8q_evk/driver.cc b/repos/os/src/drivers/i2c/imx8q_evk/driver.cc index 5eac1e07f5..d58cf9f1c4 100644 --- a/repos/os/src/drivers/i2c/imx8q_evk/driver.cc +++ b/repos/os/src/drivers/i2c/imx8q_evk/driver.cc @@ -126,7 +126,7 @@ void I2c::Driver::_write(uint8_t address, I2c::Session::Message & m) void I2c::Driver::_read(uint8_t address, I2c::Session::Message & m) { /* LSB must be 1 for reading on the bus, address is on the 7 hightest bits */ - _bus_write(address << 1 | 1); + _bus_write((uint8_t)(address << 1 | 1)); _mmio.write(0); if (m.count() > 1) { @@ -149,7 +149,7 @@ void I2c::Driver::_read(uint8_t address, I2c::Session::Message & m) _mmio.write(1); } - byte = _mmio.read(); + byte = (uint8_t)_mmio.read(); _irq.ack(); }); } diff --git a/repos/os/src/drivers/input/virtio/component.h b/repos/os/src/drivers/input/virtio/component.h index c06512b373..a1e7ebb4c9 100644 --- a/repos/os/src/drivers/input/virtio/component.h +++ b/repos/os/src/drivers/input/virtio/component.h @@ -293,10 +293,10 @@ class Virtio_input::Driver throw Device_init_failed(); } - device_id.bus_type = device.read_config(Config::Data + 0, Virtio::Device::ACCESS_16BIT); - device_id.vendor = device.read_config(Config::Data + 2, Virtio::Device::ACCESS_16BIT); - device_id.product = device.read_config(Config::Data + 4, Virtio::Device::ACCESS_16BIT); - device_id.version = device.read_config(Config::Data + 6, Virtio::Device::ACCESS_16BIT); + device_id.bus_type = (uint16_t)device.read_config(Config::Data + 0, Virtio::Device::ACCESS_16BIT); + device_id.vendor = (uint16_t)device.read_config(Config::Data + 2, Virtio::Device::ACCESS_16BIT); + device_id.product = (uint16_t)device.read_config(Config::Data + 4, Virtio::Device::ACCESS_16BIT); + device_id.version = (uint16_t)device.read_config(Config::Data + 6, Virtio::Device::ACCESS_16BIT); return device_id; } @@ -312,7 +312,7 @@ class Virtio_input::Driver memset(buf, 0, sizeof(buf)); for (unsigned i = 0; i < size; ++i) - buf[i] = device.read_config(Config::Data + i, Virtio::Device::ACCESS_8BIT); + buf[i] = (uint8_t)device.read_config((uint8_t)(Config::Data + i), Virtio::Device::ACCESS_8BIT); return String(buf); } diff --git a/repos/os/src/drivers/nic/lan9118/lan9118.h b/repos/os/src/drivers/nic/lan9118/lan9118.h index 289e326fdf..a8e1793263 100644 --- a/repos/os/src/drivers/nic/lan9118/lan9118.h +++ b/repos/os/src/drivers/nic/lan9118/lan9118.h @@ -317,12 +317,12 @@ class Lan9118_base unsigned mac_addr_lo = _mac_csr_read(MAC_ADDRL), mac_addr_hi = _mac_csr_read(MAC_ADDRH); - _mac_addr.addr[5] = (mac_addr_hi >> 8) & 0xff; - _mac_addr.addr[4] = (mac_addr_hi >> 0) & 0xff; - _mac_addr.addr[3] = (mac_addr_lo >> 24) & 0xff; - _mac_addr.addr[2] = (mac_addr_lo >> 16) & 0xff; - _mac_addr.addr[1] = (mac_addr_lo >> 8) & 0xff; - _mac_addr.addr[0] = (mac_addr_lo >> 0) & 0xff; + _mac_addr.addr[5] = (uint8_t)(mac_addr_hi >> 8); + _mac_addr.addr[4] = (uint8_t)(mac_addr_hi >> 0); + _mac_addr.addr[3] = (uint8_t)(mac_addr_lo >> 24); + _mac_addr.addr[2] = (uint8_t)(mac_addr_lo >> 16); + _mac_addr.addr[1] = (uint8_t)(mac_addr_lo >> 8); + _mac_addr.addr[0] = (uint8_t)(mac_addr_lo >> 0); log("MAC address: ", _mac_addr); diff --git a/repos/os/src/drivers/nic/spec/linux/main.cc b/repos/os/src/drivers/nic/spec/linux/main.cc index 450059faee..65d52cb3c1 100644 --- a/repos/os/src/drivers/nic/spec/linux/main.cc +++ b/repos/os/src/drivers/nic/spec/linux/main.cc @@ -153,7 +153,7 @@ class Uplink_client : public Uplink_client_base _drv_transmit_pkt(const char *conn_rx_pkt_base, size_t conn_rx_pkt_size) override { - int ret; + ssize_t ret; /* non-blocking-write packet to TAP */ do { diff --git a/repos/os/src/drivers/nic/virtio/spec/x86/target.mk b/repos/os/src/drivers/nic/virtio/spec/x86/target.mk index da2d995713..65e45566ac 100644 --- a/repos/os/src/drivers/nic/virtio/spec/x86/target.mk +++ b/repos/os/src/drivers/nic/virtio/spec/x86/target.mk @@ -6,3 +6,5 @@ INC_DIR = $(REP_DIR)/src/drivers/nic/virtio CONFIG_XSD = ../../config.xsd vpath % $(REP_DIR)/src/drivers/nic/virtio + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/drivers/nic/virtio/target_mmio.inc b/repos/os/src/drivers/nic/virtio/target_mmio.inc index 5731bfc7b4..29d9e53f6c 100644 --- a/repos/os/src/drivers/nic/virtio/target_mmio.inc +++ b/repos/os/src/drivers/nic/virtio/target_mmio.inc @@ -5,3 +5,5 @@ INC_DIR = $(REP_DIR)/src/drivers/nic/virtio CONFIG_XSD = ../../config.xsd vpath % $(REP_DIR)/src/drivers/nic/virtio + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/drivers/nvme/target.mk b/repos/os/src/drivers/nvme/target.mk index c40672f2ca..4cb20fa13b 100644 --- a/repos/os/src/drivers/nvme/target.mk +++ b/repos/os/src/drivers/nvme/target.mk @@ -3,3 +3,5 @@ SRC_CC = main.cc INC_DIR += $(PRG_DIR) LIBS += base REQUIRES = x86 + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/drivers/platform/spec/x86/target.mk b/repos/os/src/drivers/platform/spec/x86/target.mk index 01c92e9944..15da865572 100644 --- a/repos/os/src/drivers/platform/spec/x86/target.mk +++ b/repos/os/src/drivers/platform/spec/x86/target.mk @@ -5,3 +5,5 @@ SRC_CC += device_pd.cc LIBS = base INC_DIR = $(PRG_DIR) + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/drivers/ps2/pl050/pl050.h b/repos/os/src/drivers/ps2/pl050/pl050.h index 022e17e39c..40b7524e2e 100644 --- a/repos/os/src/drivers/ps2/pl050/pl050.h +++ b/repos/os/src/drivers/ps2/pl050/pl050.h @@ -89,7 +89,7 @@ class Pl050 { while (empty()) if (_input_pending()) - add(_reg_base[PL050_REG_DATA]); + add((Genode::uint8_t)_reg_base[PL050_REG_DATA]); return get(); } diff --git a/repos/os/src/drivers/ps2/ps2_keyboard.h b/repos/os/src/drivers/ps2/ps2_keyboard.h index 9db67ec999..02d84189f9 100644 --- a/repos/os/src/drivers/ps2/ps2_keyboard.h +++ b/repos/os/src/drivers/ps2/ps2_keyboard.h @@ -194,7 +194,7 @@ class Ps2::Keyboard : public Input_driver _press = !(v & 0x80); /* keep the remaining bits for scan-code translation */ - v &= ~0x80; + v &= (unsigned char)(~0x80); /* convert scan code to unified key code */ switch (_type) { @@ -388,7 +388,9 @@ class Ps2::Keyboard : public Input_driver return; } - _kbd.write((capslock ? 4:0) | (numlock ? 2:0) | (scrlock ? 1:0)); + _kbd.write((unsigned char)((capslock ? 4 : 0) | + (numlock ? 2 : 0) | + (scrlock ? 1 : 0))); if (_kbd.read() != ACK) { Genode::warning("setting of mode indicators failed"); return; diff --git a/repos/os/src/drivers/rtc/spec/x86/rtc.cc b/repos/os/src/drivers/rtc/spec/x86/rtc.cc index 5507c01a5b..7a3e5fb658 100644 --- a/repos/os/src/drivers/rtc/spec/x86/rtc.cc +++ b/repos/os/src/drivers/rtc/spec/x86/rtc.cc @@ -157,9 +157,9 @@ Rtc::Timestamp Rtc::Driver::read_timestamp() void Rtc::Driver::write_timestamp(Timestamp ts) { - unsigned const ctl = _cmos_read(RTC_CONTROL); - unsigned const freq = _cmos_read(RTC_FREQ_SELECT); - bool const bcd = (!(ctl & RTC_DM_BINARY) || RTC_ALWAYS_BCD); + uint8_t const ctl = _cmos_read(RTC_CONTROL); + uint8_t const freq = _cmos_read(RTC_FREQ_SELECT); + bool const bcd = (!(ctl & RTC_DM_BINARY) || RTC_ALWAYS_BCD); /* ignore century and hope for the best */ ts.year %= 100; @@ -175,12 +175,12 @@ void Rtc::Driver::write_timestamp(Timestamp ts) _cmos_write(RTC_CONTROL, ctl | RTC_SET); _cmos_write(RTC_FREQ_SELECT, freq | RTC_DIV_RESET2); - _cmos_write(RTC_SECONDS, sec); - _cmos_write(RTC_MINUTES, min); - _cmos_write(RTC_HOURS, hour); - _cmos_write(RTC_DAY_OF_MONTH, day); - _cmos_write(RTC_MONTH, mon); - _cmos_write(RTC_YEAR, year); + _cmos_write(RTC_SECONDS, (uint8_t)sec); + _cmos_write(RTC_MINUTES, (uint8_t)min); + _cmos_write(RTC_HOURS, (uint8_t)hour); + _cmos_write(RTC_DAY_OF_MONTH, (uint8_t)day); + _cmos_write(RTC_MONTH, (uint8_t)mon); + _cmos_write(RTC_YEAR, (uint8_t)year); /* enable updating */ _cmos_write(RTC_CONTROL, ctl); diff --git a/repos/os/src/drivers/sd_card/benchmark.h b/repos/os/src/drivers/sd_card/benchmark.h index 908960a10c..bd57a43cd2 100644 --- a/repos/os/src/drivers/sd_card/benchmark.h +++ b/repos/os/src/drivers/sd_card/benchmark.h @@ -83,8 +83,8 @@ struct Benchmark /* print stats for the current request size */ uint64_t const time_after_ms = timer.elapsed_ms(); uint64_t const duration_ms = time_after_ms - time_before_ms; - size_t const kib_per_sec = (1000 * buf_size_kib) / - duration_ms; + size_t const kib_per_sec = (size_t)((1000 * buf_size_kib) + / duration_ms); log(" duration: ", duration_ms, " ms"); log(" amount: ", buf_size_kib, " KiB"); log(" throughput: ", kib_per_sec, " KiB/sec"); diff --git a/repos/os/src/drivers/sd_card/imx/driver.cc b/repos/os/src/drivers/sd_card/imx/driver.cc index f8fa6a01b7..72ea6ff418 100644 --- a/repos/os/src/drivers/sd_card/imx/driver.cc +++ b/repos/os/src/drivers/sd_card/imx/driver.cc @@ -218,7 +218,7 @@ void Driver::read_dma(Block::sector_t blk_nr, if (_prepare_dma_mb(packet, true, blk_cnt, buf_phys)) { throw Io_error(); } - if (!issue_command(Read_multiple_block(blk_nr))) { + if (!issue_command(Read_multiple_block((unsigned long)blk_nr))) { throw Io_error(); } } @@ -231,7 +231,7 @@ void Driver::write_dma(Block::sector_t blk_nr, if (_prepare_dma_mb(packet, false, blk_cnt, buf_phys)) { throw Io_error(); } - if (!issue_command(Write_multiple_block(blk_nr))) { + if (!issue_command(Write_multiple_block((unsigned long)blk_nr))) { throw Io_error(); } } diff --git a/repos/os/src/drivers/sd_card/pl180/driver.cc b/repos/os/src/drivers/sd_card/pl180/driver.cc index 414723029e..8e7d7bc900 100644 --- a/repos/os/src/drivers/sd_card/pl180/driver.cc +++ b/repos/os/src/drivers/sd_card/pl180/driver.cc @@ -179,7 +179,7 @@ Driver::Driver(Env &env, Platform::Connection & platform) /* CMD3: send relative card address (RCA) */ _request(3, &resp); - unsigned short rca = resp >> 16; + unsigned short rca = (short)(resp >> 16); /* * Now, the card is in transfer mode... @@ -208,7 +208,7 @@ void Driver::read(Block::sector_t block_number, * SDSC cards use a byte address as argument while SDHC/SDSC uses a * block address here. */ - _read_request(17, (block_number + i) * _block_size, + _read_request(17, (uint32_t)((block_number + i) * _block_size), length, &resp); _read_data(length, buffer + (i * _block_size)); } @@ -231,7 +231,7 @@ void Driver::write(Block::sector_t block_number, * SDSC cards use a byte address as argument while SDHC/SDSC uses a * block address here. */ - _write_request(24, (block_number + i) * _block_size, + _write_request(24, (uint32_t)((block_number + i) * _block_size), length, &resp); _write_data(length, buffer + (i * _block_size)); } diff --git a/repos/os/src/drivers/sd_card/rpi/driver.cc b/repos/os/src/drivers/sd_card/rpi/driver.cc index dffb9954a5..cbe3253456 100644 --- a/repos/os/src/drivers/sd_card/rpi/driver.cc +++ b/repos/os/src/drivers/sd_card/rpi/driver.cc @@ -263,7 +263,7 @@ void Driver::read(Block::sector_t block_number, { _set_block_count(block_count); - if (!issue_command(Read_multiple_block(_block_to_command_address(block_number)))) { + if (!issue_command(Read_multiple_block(_block_to_command_address((size_t)block_number)))) { error("Read_multiple_block failed"); throw Io_error(); } @@ -302,7 +302,7 @@ void Driver::write(Block::sector_t block_number, { _set_block_count(block_count); - if (!issue_command(Write_multiple_block(_block_to_command_address(block_number)))) { + if (!issue_command(Write_multiple_block(_block_to_command_address((size_t)block_number)))) { error("Write_multiple_block failed"); throw Io_error(); } diff --git a/repos/os/src/drivers/touch/synaptics_dsx/i2c.h b/repos/os/src/drivers/touch/synaptics_dsx/i2c.h index 6a9905b6bc..4793092f8f 100644 --- a/repos/os/src/drivers/touch/synaptics_dsx/i2c.h +++ b/repos/os/src/drivers/touch/synaptics_dsx/i2c.h @@ -144,7 +144,7 @@ class I2c::I2c : Platform::Device::Mmio try { _start(); - _write(addr << 1 | 1); + _write((Genode::uint8_t)(addr << 1 | 1)); write(0); if (num > 1) @@ -166,7 +166,7 @@ class I2c::I2c : Platform::Device::Mmio write(1); } - buf[i] = read(); + buf[i] = (Genode::uint8_t)read(); _irq_handler.ack(); } diff --git a/repos/os/src/drivers/uart/kdb/target.inc b/repos/os/src/drivers/uart/kdb/target.inc index 7e4b4f748e..48a02bf439 100644 --- a/repos/os/src/drivers/uart/kdb/target.inc +++ b/repos/os/src/drivers/uart/kdb/target.inc @@ -4,3 +4,5 @@ LIBS += base INC_DIR += $(REP_DIR)/src/drivers/uart $(REP_DIR)/src/drivers/uart/kdb vpath main.cc $(REP_DIR)/src/drivers/uart + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/drivers/uart/spec/pbxa9/uart_driver.h b/repos/os/src/drivers/uart/spec/pbxa9/uart_driver.h index 0881f53241..37c867e4d9 100644 --- a/repos/os/src/drivers/uart/spec/pbxa9/uart_driver.h +++ b/repos/os/src/drivers/uart/spec/pbxa9/uart_driver.h @@ -205,7 +205,7 @@ class Uart::Driver : private Genode::Attached_io_mem_dataspace, return !(_read_reg(UARTFR) & UARTFR_RXFE); } char get_char() override { - return _read_reg(UARTDR); } + return (char)_read_reg(UARTDR); } }; #endif /* _UART_DRIVER_H_ */ diff --git a/repos/os/src/drivers/uart/spec/x86/uart_driver.h b/repos/os/src/drivers/uart/spec/x86/uart_driver.h index 6633d2942a..d62fc2315c 100644 --- a/repos/os/src/drivers/uart/spec/x86/uart_driver.h +++ b/repos/os/src/drivers/uart/spec/x86/uart_driver.h @@ -28,15 +28,15 @@ class Uart::Driver : public Uart::Driver_base { private: - unsigned _port_base; + uint16_t _port_base; Genode::Io_port_connection _io_port; /** * Return I/O port base for specified UART */ - static unsigned _io_port_base(int index) + static uint16_t _io_port_base(int index) { - static unsigned port_base[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; + static uint16_t port_base[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; return port_base[index & 0x3]; } @@ -84,17 +84,17 @@ class Uart::Driver : public Uart::Driver_base * * Based on 'init_serial' of L4ka::Pistachio's 'kdb/platform/pc99/io.cc' */ - void _init_comport(unsigned baud) + void _init_comport(size_t baud) { - _outb(0x80); /* select bank 1 */ + _outb(0x80u); /* select bank 1 */ for (volatile int i = 10000000; i--; ); - _outb((115200/baud) >> 0); - _outb((115200/baud) >> 8); - _outb(0x03); /* set 8,N,1 */ - _outb(0x00); /* disable interrupts */ - _outb(0x07); /* enable FIFOs */ - _outb(0x0b); /* force data terminal ready */ - _outb(0x01); /* enable RX interrupts */ + _outb(((115200/baud) >> 0) && 0xff); + _outb(((115200/baud) >> 8) && 0xff); + _outb(0x03u); /* set 8,N,1 */ + _outb(0x00u); /* disable interrupts */ + _outb(0x07u); /* enable FIFOs */ + _outb(0x0bu); /* force data terminal ready */ + _outb(0x01u); /* enable RX interrupts */ _inb(); _inb(); _inb(); @@ -103,7 +103,7 @@ class Uart::Driver : public Uart::Driver_base _inb(); } - unsigned _baud_rate(unsigned baud_rate) + size_t _baud_rate(size_t baud_rate) { if (baud_rate != BAUD_115200) Genode::warning("baud_rate ", baud_rate, @@ -113,12 +113,15 @@ class Uart::Driver : public Uart::Driver_base public: - Driver(Genode::Env &env, unsigned index, unsigned baud, + Driver(Env &env, unsigned index, size_t baud, Uart::Char_avail_functor &func) - : Driver_base(env, _irq_number(index), func), - _port_base(_io_port_base(index)), - _io_port(env, _port_base, 0xf) { - _init_comport(_baud_rate(baud)); } + : + Driver_base(env, _irq_number(index), func), + _port_base(_io_port_base(index)), + _io_port(env, _port_base, 0xf) + { + _init_comport(_baud_rate(baud)); + } /*************************** @@ -144,7 +147,7 @@ class Uart::Driver : public Uart::Driver_base return _inb(); } - void baud_rate(int bits_per_second) override + void baud_rate(size_t bits_per_second) override { _init_comport(bits_per_second); } diff --git a/repos/os/src/drivers/uart/uart_component.h b/repos/os/src/drivers/uart/uart_component.h index 396c717cc9..69e437f88e 100644 --- a/repos/os/src/drivers/uart/uart_component.h +++ b/repos/os/src/drivers/uart/uart_component.h @@ -116,7 +116,7 @@ class Uart::Session_component : public Rpc_object _le { this }; @@ -72,12 +72,12 @@ class genode_usb_session : public Usb::Session_rpc_object public: - genode_usb_session(::Root & root, - Attached_dataspace & ds, - Env & env, - Signal_context_capability cap, - unsigned short id, - Session_label label); + genode_usb_session(::Root & root, + Attached_dataspace & ds, + Env & env, + Signal_context_capability cap, + genode_usb_session_handle_t id, + Session_label label); virtual ~genode_usb_session() {} @@ -136,6 +136,15 @@ class Root : public Root_component enum { MAX_DEVICES = 32 }; + struct Id_allocator : Bit_allocator<16> + { + genode_usb_session_handle_t alloc() + { + /* we can downcast here, because we only use 16 bits */ + return (genode_usb_session_handle_t) + Bit_allocator<16>::alloc(); + } + }; Env & _env; Signal_context_capability _sigh_cap; @@ -145,7 +154,7 @@ class Root : public Root_component Reporter _reporter { _env, "devices" }; Constructible _devices[MAX_DEVICES]; List> _sessions {}; - Bit_allocator<16> _id_alloc {}; + Id_allocator _id_alloc {}; bool _announced { false }; Root(const Root&); @@ -188,20 +197,21 @@ class Root : public Root_component Root(Env & env, Allocator & alloc, Signal_context_capability); - void announce_device(unsigned long vendor, - unsigned long product, - unsigned long cla, - unsigned long bus, - unsigned long dev); + void announce_device(genode_usb_vendor_id_t vendor, + genode_usb_product_id_t product, + genode_usb_class_num_t cla, + genode_usb_bus_num_t bus, + genode_usb_dev_num_t dev); - void discontinue_device(unsigned long bus, unsigned long dev); + void discontinue_device(genode_usb_bus_num_t bus, + genode_usb_dev_num_t dev); /* * Returns the session's handle for a given device, * or an invalid handle if there is no active session for the device */ - genode_usb_session_handle_t session(unsigned long bus, - unsigned long dev); + genode_usb_session_handle_t session(genode_usb_bus_num_t bus, + genode_usb_dev_num_t dev); /* * Finds the bus/device numbers of the device associated for a @@ -209,9 +219,9 @@ class Root : public Root_component * * \returns true if a device is associated, otherwise false */ - bool device_associated(genode_usb_session * session, - unsigned long & bus, - unsigned long & dev); + bool device_associated(genode_usb_session * session, + genode_usb_bus_num_t & bus, + genode_usb_dev_num_t & dev); /* * Apply a functor to the session with the given handle @@ -240,7 +250,8 @@ void genode_usb_session::notify() bool genode_usb_session::plugged() { - unsigned long bus, dev; + genode_usb_bus_num_t bus; + genode_usb_dev_num_t dev; return _root.device_associated(this, bus, dev); } @@ -248,7 +259,8 @@ bool genode_usb_session::plugged() void genode_usb_session::config_descriptor(Usb::Device_descriptor * device_descr, Usb::Config_descriptor * config_descr) { - unsigned long bus, dev; + genode_usb_bus_num_t bus; + genode_usb_dev_num_t dev; if (!_root.device_associated(this, bus, dev)) throw Device_not_found(); @@ -261,7 +273,8 @@ void genode_usb_session::config_descriptor(Usb::Device_descriptor * device_descr unsigned genode_usb_session::alt_settings(unsigned index) { - unsigned long bus, dev; + genode_usb_bus_num_t bus; + genode_usb_dev_num_t dev; if (!_root.device_associated(this, bus, dev)) throw Device_not_found(); @@ -276,7 +289,8 @@ void genode_usb_session::interface_descriptor(unsigned index, unsigned alt_setting, Usb::Interface_descriptor * desc) { - unsigned long bus, dev; + genode_usb_bus_num_t bus; + genode_usb_dev_num_t dev; if (!_root.device_associated(this, bus, dev)) throw Device_not_found(); @@ -294,17 +308,22 @@ bool genode_usb_session::interface_extra(unsigned index, unsigned alt_setting, Usb::Interface_extra * interface_data) { - unsigned long bus, dev; + genode_usb_bus_num_t bus; + genode_usb_dev_num_t dev; if (!_root.device_associated(this, bus, dev)) throw Device_not_found(); - int len = _callbacks->iface_extra_fn(bus, dev, index, alt_setting, - (void*)interface_data->data, - sizeof(interface_data->data)); + int len = + _callbacks->iface_extra_fn(bus, dev, index, alt_setting, + (void*)interface_data->data, + sizeof(interface_data->data)); if (len < 0) throw Interface_not_found(); - interface_data->length = len; + if (len >= 0xff) + error("Unsupported length of alt_setting iface extra!"); + + interface_data->length = (uint8_t)len; return len; } @@ -314,7 +333,8 @@ void genode_usb_session::endpoint_descriptor(unsigned interface_num, unsigned endpoint_num, Usb::Endpoint_descriptor * endp) { - unsigned long bus, dev; + genode_usb_bus_num_t bus; + genode_usb_dev_num_t dev; if (!_root.device_associated(this, bus, dev)) throw Device_not_found(); @@ -434,12 +454,12 @@ void genode_usb_session::handle_response(genode_usb_request_handle_t id, } -genode_usb_session::genode_usb_session(::Root & root, - Attached_dataspace & ds, - Env & env, - Signal_context_capability cap, - unsigned short id, - Session_label const label) +genode_usb_session::genode_usb_session(::Root & root, + Attached_dataspace & ds, + Env & env, + Signal_context_capability cap, + genode_usb_session_handle_t id, + Session_label const label) : Usb::Session_rpc_object(ds.cap(), env.ep().rpc_ep(), env.rm()), _root(root), @@ -456,11 +476,16 @@ bool ::Root::_matches(Device & d, genode_usb_session & s) try { Session_policy const policy(s._label, _config.xml()); - unsigned long vendor = policy.attribute_value("vendor_id", 0); - unsigned long product = policy.attribute_value("product_id", 0); - unsigned long bus = policy.attribute_value("bus", 0); - unsigned long dev = policy.attribute_value("dev", 0); - unsigned long cla = policy.attribute_value("class", 0); + genode_usb_vendor_id_t vendor = + policy.attribute_value("vendor_id", 0); + genode_usb_product_id_t product = + policy.attribute_value("product_id", 0); + genode_usb_bus_num_t bus = + policy.attribute_value("bus", 0); + genode_usb_dev_num_t dev = + policy.attribute_value("dev", 0); + genode_usb_class_num_t cla = + policy.attribute_value("class", 0); if (bus && dev) return (bus == d.bus) && (dev == d.dev); @@ -523,7 +548,7 @@ void ::Root::_destroy_session(genode_usb_session * session) d.usb_session = nullptr; }); - unsigned short id = session->_id; + genode_usb_session_handle_t id = session->_id; Attached_dataspace & ds = session->_ds; _sessions.remove(&session->_le); Genode::destroy(md_alloc(), session); @@ -573,11 +598,11 @@ void ::Root::_announce_service() } -void ::Root::announce_device(unsigned long vendor, - unsigned long product, - unsigned long cla, - unsigned long bus, - unsigned long dev) +void ::Root::announce_device(genode_usb_vendor_id_t vendor, + genode_usb_product_id_t product, + genode_usb_class_num_t cla, + genode_usb_bus_num_t bus, + genode_usb_dev_num_t dev) { for (unsigned idx = 0; idx < MAX_DEVICES; idx++) { if (_devices[idx].constructed()) @@ -600,7 +625,8 @@ void ::Root::announce_device(unsigned long vendor, } -void ::Root::discontinue_device(unsigned long bus, unsigned long dev) +void ::Root::discontinue_device(genode_usb_bus_num_t bus, + genode_usb_dev_num_t dev) { for (unsigned idx = 0; idx < MAX_DEVICES; idx++) { if (!_devices[idx].constructed() || @@ -618,7 +644,8 @@ void ::Root::discontinue_device(unsigned long bus, unsigned long dev) } -genode_usb_session_handle_t ::Root::session(unsigned long bus, unsigned long dev) +genode_usb_session_handle_t ::Root::session(genode_usb_bus_num_t bus, + genode_usb_dev_num_t dev) { genode_usb_session * session = nullptr; _for_each_device([&] (Device & d) { @@ -639,8 +666,9 @@ void ::Root::session(genode_usb_session_handle_t id, FUNC const & fn) } -bool ::Root::device_associated(genode_usb_session * session, - unsigned long & bus, unsigned long & dev) +bool ::Root::device_associated(genode_usb_session * session, + genode_usb_bus_num_t & bus, + genode_usb_dev_num_t & dev) { bool ret = false; _for_each_device([&] (Device & d) { @@ -678,11 +706,11 @@ extern "C" void genode_usb_init(genode_env * env_ptr, } -extern "C" void genode_usb_announce_device(unsigned long vendor, - unsigned long product, - unsigned long cla, - unsigned long bus, - unsigned long dev) +extern "C" void genode_usb_announce_device(genode_usb_vendor_id_t vendor, + genode_usb_product_id_t product, + genode_usb_class_num_t cla, + genode_usb_bus_num_t bus, + genode_usb_dev_num_t dev) { if (!_usb_root) return; @@ -691,8 +719,8 @@ extern "C" void genode_usb_announce_device(unsigned long vendor, } -extern "C" void genode_usb_discontinue_device(unsigned long bus, - unsigned long dev) +extern "C" void genode_usb_discontinue_device(genode_usb_bus_num_t bus, + genode_usb_dev_num_t dev) { if (_usb_root) _usb_root->discontinue_device(bus, dev); @@ -700,7 +728,8 @@ extern "C" void genode_usb_discontinue_device(unsigned long bus, extern "C" genode_usb_session_handle_t -genode_usb_session_by_bus_dev(unsigned long bus, unsigned long dev) +genode_usb_session_by_bus_dev(genode_usb_bus_num_t bus, + genode_usb_dev_num_t dev) { genode_usb_session_handle_t ret = _usb_root ? _usb_root->session(bus, dev) : 0; return ret; diff --git a/repos/os/src/lib/net/internet_checksum.cc b/repos/os/src/lib/net/internet_checksum.cc index 15f2b273e1..6d18505488 100644 --- a/repos/os/src/lib/net/internet_checksum.cc +++ b/repos/os/src/lib/net/internet_checksum.cc @@ -44,7 +44,7 @@ uint16_t Net::internet_checksum(Packed_uint16 const *addr, sum = (sum & 0xffff) + sum_rsh; /* return one's complement */ - return ~sum; + return (uint16_t)(~sum); } diff --git a/repos/os/src/lib/sandbox/child.cc b/repos/os/src/lib/sandbox/child.cc index e60985de91..0a6696b527 100644 --- a/repos/os/src/lib/sandbox/child.cc +++ b/repos/os/src/lib/sandbox/child.cc @@ -627,10 +627,10 @@ void Sandbox::Child::filter_session_args(Service::Name const &service, service == Vm_session::service_name()) && _prio_levels_log2 > 0) { - unsigned long priority = Arg_string::find_arg(args, "priority").ulong_value(0); + unsigned priority = (unsigned)Arg_string::find_arg(args, "priority").ulong_value(0); /* clamp priority value to valid range */ - priority = min((unsigned)Cpu_session::PRIORITY_LIMIT - 1, priority); + priority = min((unsigned)(Cpu_session::PRIORITY_LIMIT - 1), priority); long discarded_prio_lsb_bits_mask = (1 << _prio_levels_log2) - 1; if (priority & discarded_prio_lsb_bits_mask) @@ -639,7 +639,8 @@ void Sandbox::Child::filter_session_args(Service::Name const &service, priority >>= _prio_levels_log2; /* assign child priority to the most significant priority bits */ - priority |= _priority*(Cpu_session::PRIORITY_LIMIT >> _prio_levels_log2); + priority = priority + | (unsigned)(_priority*(Cpu_session::PRIORITY_LIMIT >> _prio_levels_log2)); /* override priority when delegating the session request to the parent */ String<64> value { Hex(priority) }; diff --git a/repos/os/src/lib/sandbox/heartbeat.h b/repos/os/src/lib/sandbox/heartbeat.h index 4f445508d0..d62679a83f 100644 --- a/repos/os/src/lib/sandbox/heartbeat.h +++ b/repos/os/src/lib/sandbox/heartbeat.h @@ -77,7 +77,7 @@ class Sandbox::Heartbeat : Noncopyable _timer->sigh(_timer_handler); } - unsigned const rate_ms = heartbeat.attribute_value("rate_ms", 1000UL); + unsigned const rate_ms = heartbeat.attribute_value("rate_ms", 1000U); if (rate_ms != _rate_ms) { _rate_ms = rate_ms; diff --git a/repos/os/src/lib/sandbox/server.cc b/repos/os/src/lib/sandbox/server.cc index f2fbc3c625..3b43d487ee 100644 --- a/repos/os/src/lib/sandbox/server.cc +++ b/repos/os/src/lib/sandbox/server.cc @@ -246,7 +246,7 @@ void Sandbox::Server::_handle_create_session_request(Xml_node request, Ram_quota const forward_ram_quota { ram_quota.value - keep_quota }; - Arg_string::set_arg(argbuf, sizeof(argbuf), "ram_quota", forward_ram_quota.value); + Arg_string::set_arg(argbuf, sizeof(argbuf), "ram_quota", (int)forward_ram_quota.value); Session::Diag const diag = session_diag_from_args(args.string()); diff --git a/repos/os/src/lib/sandbox/state_reporter.h b/repos/os/src/lib/sandbox/state_reporter.h index e1602084c4..dc91498e2a 100644 --- a/repos/os/src/lib/sandbox/state_reporter.h +++ b/repos/os/src/lib/sandbox/state_reporter.h @@ -153,7 +153,7 @@ class Sandbox::State_reporter : public Report_update_trigger * the user intends to limit the rate of state reports. If so, we * use the value of 'delay_ms' as interval. */ - uint64_t const period_ms = max(1000U, _report_delay_ms); + uint64_t const period_ms = max((uint64_t)1000, _report_delay_ms); bool const period_changed = (_report_period_ms != period_ms); bool const report_periodically = _periodic_sampling_needed(); diff --git a/repos/os/src/lib/sandbox/utils.h b/repos/os/src/lib/sandbox/utils.h index 853cb6da0f..31a27ddf10 100644 --- a/repos/os/src/lib/sandbox/utils.h +++ b/repos/os/src/lib/sandbox/utils.h @@ -222,13 +222,13 @@ namespace Sandbox { width = node.attribute_value("width", default_width), height = node.attribute_value("height", default_height); - long const x1 = node.attribute_value("xpos", 0), - y1 = node.attribute_value("ypos", 0), - x2 = x1 + width - 1, - y2 = y1 + height - 1; + int const x1 = (int)node.attribute_value("xpos", 0), + y1 = (int)node.attribute_value("ypos", 0), + x2 = (int)(x1 + width - 1), + y2 = (int)(y1 + height - 1); /* clip location to space boundary */ - return Location(max(x1, 0L), max(y1, 0L), + return Location(max(x1, 0), max(y1, 0), min((unsigned)(x2 - x1 + 1), space.width()), min((unsigned)(y2 - y1 + 1), space.height())); } diff --git a/repos/os/src/lib/vfs/block_file_system.h b/repos/os/src/lib/vfs/block_file_system.h index 2aa4697f22..dd7d9e507b 100644 --- a/repos/os/src/lib/vfs/block_file_system.h +++ b/repos/os/src/lib/vfs/block_file_system.h @@ -78,7 +78,7 @@ class Vfs::Block_file_system::Data_file_system : public Single_file_system char *_block_buffer; unsigned &_block_buffer_count; Block::Connection<> &_block; - Genode::size_t const _block_size; + size_t const _block_size; Block::sector_t const _block_count; Block::Session::Tx::Source *_tx_source; bool const _writeable; @@ -113,7 +113,7 @@ class Vfs::Block_file_system::Data_file_system : public Single_file_system try { Mutex::Guard guard(_mutex); - packet = _block.alloc_packet(packet_size); + packet = _block.alloc_packet((size_t)packet_size); break; } catch (Block::Session::Tx::Source::Packet_alloc_failed) { if (!_tx_source->ready_to_submit()) @@ -128,10 +128,10 @@ class Vfs::Block_file_system::Data_file_system : public Single_file_system } Mutex::Guard guard(_mutex); - Block::Packet_descriptor p(packet, op, nr, packet_count); + Block::Packet_descriptor p(packet, op, nr, (size_t)packet_count); if (write) - Genode::memcpy(_tx_source->packet_content(p), buf, packet_size); + Genode::memcpy(_tx_source->packet_content(p), buf, (size_t)packet_size); _tx_source->submit_packet(p); p = _tx_source->get_acked_packet(); @@ -143,7 +143,7 @@ class Vfs::Block_file_system::Data_file_system : public Single_file_system } if (!write) - Genode::memcpy(buf, _tx_source->packet_content(p), packet_size); + Genode::memcpy(buf, _tx_source->packet_content(p), (size_t)packet_size); _tx_source->release_packet(p); return packet_size; @@ -158,7 +158,7 @@ class Vfs::Block_file_system::Data_file_system : public Single_file_system char *block_buffer, unsigned &block_buffer_count, Block::Connection<> &block, - Genode::size_t block_size, + size_t block_size, Block::sector_t block_count, Block::Session::Tx::Source *tx_source, bool writeable, @@ -230,7 +230,7 @@ class Vfs::Block_file_system::Data_file_system : public Single_file_system return READ_ERR_INVALID; } - Genode::memcpy(dst + read, _block_buffer + displ, length); + Genode::memcpy(dst + read, _block_buffer + displ, (size_t)length); read += length; count -= length; @@ -303,7 +303,7 @@ class Vfs::Block_file_system::Data_file_system : public Single_file_system if (displ > 0 || length < _block_size) _block_io(blk_nr, _block_buffer, _block_size, false); - Genode::memcpy(_block_buffer + displ, buf + written, length); + Genode::memcpy(_block_buffer + displ, buf + written, (size_t)length); nbytes = _block_io(blk_nr, _block_buffer, _block_size, true); if ((unsigned)nbytes != _block_size) { @@ -471,7 +471,7 @@ struct Vfs::Block_file_system::Local_factory : File_system_factory Readonly_value_file_system _info_fs { "info", Info { } }; Readonly_value_file_system _block_count_fs { "block_count", 0 }; - Readonly_value_file_system _block_size_fs { "block_size", 0 }; + Readonly_value_file_system _block_size_fs { "block_size", 0 }; static Name name(Xml_node config) { @@ -480,7 +480,7 @@ struct Vfs::Block_file_system::Local_factory : File_system_factory static unsigned buffer_count(Xml_node config) { - return config.attribute_value("block_buffer_count", 1UL); + return config.attribute_value("block_buffer_count", 1U); } Local_factory(Vfs::Env &env, Xml_node config) diff --git a/repos/os/src/lib/vfs/fs_file_system.h b/repos/os/src/lib/vfs/fs_file_system.h index 59110ff80a..182319f83c 100644 --- a/repos/os/src/lib/vfs/fs_file_system.h +++ b/repos/os/src/lib/vfs/fs_file_system.h @@ -147,7 +147,7 @@ class Vfs::Fs_file_system : public File_system ::File_system::Packet_descriptor p; try { - p = source.alloc_packet(clipped_count); + p = source.alloc_packet((size_t)clipped_count); } catch (::File_system::Session::Tx::Source::Packet_alloc_failed) { return false; } @@ -155,7 +155,7 @@ class Vfs::Fs_file_system : public File_system ::File_system::Packet_descriptor const packet(p, file_handle(), ::File_system::Packet_descriptor::READ, - clipped_count, seek_offset); + (size_t)clipped_count, seek_offset); read_ready_state = Handle_state::Read_ready_state::IDLE; queued_read_state = Handle_state::Queued_state::QUEUED; @@ -181,9 +181,9 @@ class Vfs::Fs_file_system : public File_system Read_result result = packet.succeeded() ? READ_OK : READ_ERR_IO; if (result == READ_OK) { - file_size const read_num_bytes = min(packet.length(), count); + file_size const read_num_bytes = min((file_size)packet.length(), count); - memcpy(dst, source.packet_content(packet), read_num_bytes); + memcpy(dst, source.packet_content(packet), (size_t)read_num_bytes); out_count = read_num_bytes; } @@ -449,10 +449,10 @@ class Vfs::Fs_file_system : public File_system /* XXX check if alloc_packet() and submit_packet() will succeed! */ - Packet_descriptor const packet_in(source.alloc_packet(clipped_count), + Packet_descriptor const packet_in(source.alloc_packet((size_t)clipped_count), handle.file_handle(), Packet_descriptor::READ, - clipped_count, + (size_t)clipped_count, seek_offset); /* wait until packet was acknowledged */ @@ -481,9 +481,9 @@ class Vfs::Fs_file_system : public File_system catch (::File_system::Unavailable) { } } - file_size const read_num_bytes = min(packet_out.length(), count); + file_size const read_num_bytes = min((file_size)packet_out.length(), count); - memcpy(buf, source.packet_content(packet_out), read_num_bytes); + memcpy(buf, source.packet_content(packet_out), (size_t)read_num_bytes); source.release_packet(packet_out); @@ -514,13 +514,13 @@ class Vfs::Fs_file_system : public File_system } try { - Packet_descriptor packet_in(source.alloc_packet(count), + Packet_descriptor packet_in(source.alloc_packet((size_t)count), handle.file_handle(), Packet_descriptor::WRITE, - count, + (size_t)count, seek_offset); - memcpy(source.packet_content(packet_in), buf, count); + memcpy(source.packet_content(packet_in), buf, (size_t)count); /* pass packet to server side */ source.submit_packet(packet_in); @@ -630,8 +630,7 @@ class Vfs::Fs_file_system : public File_system Genode::Io_signal_handler _ready_handler { _env.env().ep(), *this, &Fs_file_system::_ready_to_submit }; - static - Genode::size_t buffer_size(Genode::Xml_node const &config) + static size_t buffer_size(Genode::Xml_node const &config) { Genode::Number_of_bytes fs_default { ::File_system::DEFAULT_TX_BUF_SIZE }; return config.attribute_value("buffer_size", fs_default); diff --git a/repos/os/src/lib/vfs/inline_file_system.h b/repos/os/src/lib/vfs/inline_file_system.h index ae541bf681..03f2e86bed 100644 --- a/repos/os/src/lib/vfs/inline_file_system.h +++ b/repos/os/src/lib/vfs/inline_file_system.h @@ -74,7 +74,7 @@ class Vfs::Inline_file_system : public Single_file_system } /* copy-out bytes from ROM dataspace */ - file_size const num_bytes = end_offset - read_offset; + size_t const num_bytes = (size_t)(end_offset - read_offset); memcpy(dst, src, num_bytes); @@ -130,7 +130,7 @@ class Vfs::Inline_file_system : public Single_file_system } try { - _node.with_raw_content([&] (char const *base, Genode::size_t size) { + _node.with_raw_content([&] (char const *base, size_t size) { *out_handle = new (alloc) Inline_vfs_handle(*this, *this, alloc, base, size); }); @@ -144,7 +144,7 @@ class Vfs::Inline_file_system : public Single_file_system { Stat_result const result = Single_file_system::stat(path, out); - _node.with_raw_content([&] (char const *, Genode::size_t size) { + _node.with_raw_content([&] (char const *, size_t size) { out.size = size; }); return result; diff --git a/repos/os/src/lib/vfs/log_file_system.h b/repos/os/src/lib/vfs/log_file_system.h index 8e5ba98ee8..c3711fd886 100644 --- a/repos/os/src/lib/vfs/log_file_system.h +++ b/repos/os/src/lib/vfs/log_file_system.h @@ -51,14 +51,15 @@ class Vfs::Log_file_system : public Single_file_system private: char _line_buf[Genode::Log_session::MAX_STRING_LEN]; - int _line_pos = 0; + + file_offset _line_pos = 0; Genode::Log_session &_log; void _flush() { - int strip = 0; - for (int i = _line_pos - 1; i > 0; --i) { + file_offset strip = 0; + for (file_offset i = _line_pos - 1; i > 0; --i) { switch(_line_buf[i]) { case '\n': case '\t': @@ -103,16 +104,16 @@ class Vfs::Log_file_system : public Single_file_system /* count does not include the trailing '\0' */ while (count > 0) { - int curr_count = min(count, ((sizeof(_line_buf) - 1) - _line_pos)); + file_size curr_count = min(count, (file_size)((sizeof(_line_buf) - 1) - _line_pos)); - for (int i = 0; i < curr_count; ++i) { + for (file_size i = 0; i < curr_count; ++i) { if (src[i] == '\n') { curr_count = i + 1; break; } } - memcpy(_line_buf + _line_pos, src, curr_count); + memcpy(_line_buf + _line_pos, src, (size_t)curr_count); _line_pos += curr_count; if ((_line_pos == sizeof(_line_buf) - 1) || diff --git a/repos/os/src/lib/vfs/ram_file_system.h b/repos/os/src/lib/vfs/ram_file_system.h index 0dad78afb8..6b735daaec 100644 --- a/repos/os/src/lib/vfs/ram_file_system.h +++ b/repos/os/src/lib/vfs/ram_file_system.h @@ -113,7 +113,7 @@ class Vfs_ram::Node : private Genode::Avl_node, private Genode::Mutex /** * Generate unique inode number */ - static unsigned _unique_inode() + static unsigned long _unique_inode() { static unsigned long inode_count; return ++inode_count; @@ -126,10 +126,9 @@ class Vfs_ram::Node : private Genode::Avl_node, private Genode::Mutex using Mutex::acquire; using Mutex::release; - unsigned inode; + unsigned long inode; - Node(char const *node_name) - : inode(_unique_inode()) + Node(char const *node_name) : inode(_unique_inode()) { name(node_name); } @@ -284,7 +283,7 @@ class Vfs_ram::File : public Vfs_ram::Node * because 'Chunk' may have truncated tailing zeros. */ if (seek_offset + len >= _length) - len = _length - seek_offset; + len = (size_t)(_length - seek_offset); file_size read_len = len; @@ -295,11 +294,11 @@ class Vfs_ram::File : public Vfs_ram::Node read_len = 0; } - _chunk.read(dst, read_len, seek_offset); + _chunk.read(dst, (size_t)read_len, (size_t)seek_offset); /* add zero padding if needed */ if (read_len < len) - memset(dst + read_len, 0, len - read_len); + memset(dst + read_len, 0, (size_t)(len - read_len)); return len; } @@ -309,7 +308,7 @@ class Vfs_ram::File : public Vfs_ram::Node file_size seek_offset, file_size &out_count) override { - out_count = read(dst, count, seek_offset); + out_count = read(dst, (size_t)count, (size_t)seek_offset); return Vfs::File_io_service::READ_OK; } @@ -319,7 +318,7 @@ class Vfs_ram::File : public Vfs_ram::Node seek_offset = _chunk.used_size(); if (seek_offset + len >= Chunk_level_0::SIZE) - len = Chunk_level_0::SIZE - (seek_offset + len); + len = Chunk_level_0::SIZE - (size_t)(seek_offset + len); try { _chunk.write(src, len, (size_t)seek_offset); } catch (Out_of_memory) { return 0; } @@ -384,7 +383,7 @@ class Vfs_ram::Symlink : public Vfs_ram::Node file_size, file_size &out_count) override { - out_count = get(dst, count); + out_count = get(dst, (size_t)count); return Vfs::File_io_service::READ_OK; } @@ -909,14 +908,14 @@ class Vfs::Ram_file_system : public Vfs::File_system File *file = dynamic_cast(node); if (!file) return ds_cap; - size_t len = file->length(); + size_t len = (size_t)file->length(); char *local_addr = nullptr; try { ds_cap = _env.env().ram().alloc(len); local_addr = _env.env().rm().attach(ds_cap); - file->read(local_addr, file->length(), 0); + file->read(local_addr, (size_t)file->length(), 0); _env.env().rm().detach(local_addr); } catch(...) { @@ -976,7 +975,7 @@ class Vfs::Ram_file_system : public Vfs::File_system static_cast(vfs_handle); Vfs_ram::Node::Guard guard(&handle->node); - out = handle->node.write(buf, len, handle->seek()); + out = handle->node.write(buf, (size_t)len, handle->seek()); handle->modifying = true; return WRITE_OK; diff --git a/repos/os/src/lib/vfs/rom_file_system.h b/repos/os/src/lib/vfs/rom_file_system.h index 1a06bf3c58..1052f5d18b 100644 --- a/repos/os/src/lib/vfs/rom_file_system.h +++ b/repos/os/src/lib/vfs/rom_file_system.h @@ -99,7 +99,7 @@ class Vfs::Rom_file_system : public Single_file_system /* copy-out bytes from ROM dataspace */ file_size const num_bytes = end_offset - read_offset; - memcpy(dst, src, num_bytes); + memcpy(dst, src, (size_t)num_bytes); out_count = num_bytes; return READ_OK; diff --git a/repos/os/src/lib/vfs/rtc_file_system.h b/repos/os/src/lib/vfs/rtc_file_system.h index 1921a5ae03..a6fa3373f6 100644 --- a/repos/os/src/lib/vfs/rtc_file_system.h +++ b/repos/os/src/lib/vfs/rtc_file_system.h @@ -63,13 +63,13 @@ class Vfs::Rtc_file_system : public Single_file_system char buf[TIMESTAMP_LEN+1]; char *b = buf; - unsigned n = Genode::snprintf(buf, sizeof(buf), "%04u-%02u-%02u %02u:%02u\n", - ts.year, ts.month, ts.day, ts.hour, ts.minute); - n -= seek(); + Genode::size_t n = Genode::snprintf(buf, sizeof(buf), "%04u-%02u-%02u %02u:%02u\n", + ts.year, ts.month, ts.day, ts.hour, ts.minute); + n -= (size_t)seek(); b += seek(); file_size len = count > n ? n : count; - Genode::memcpy(dst, b, len); + Genode::memcpy(dst, b, (size_t)len); out_count = len; return READ_OK; diff --git a/repos/os/src/lib/vfs/symlink_file_system.h b/repos/os/src/lib/vfs/symlink_file_system.h index 335c7b45ac..333e9eb706 100644 --- a/repos/os/src/lib/vfs/symlink_file_system.h +++ b/repos/os/src/lib/vfs/symlink_file_system.h @@ -44,7 +44,7 @@ class Vfs::Symlink_file_system : public Single_file_system file_size &out_count) override { auto n = min(count, _target.length()); - copy_cstring(dst, _target.string(), n); + copy_cstring(dst, _target.string(), (size_t)n); out_count = n - 1; return READ_OK; } diff --git a/repos/os/src/lib/vfs/tar_file_system.h b/repos/os/src/lib/vfs/tar_file_system.h index b239e1f1a4..a06f3e781a 100644 --- a/repos/os/src/lib/vfs/tar_file_system.h +++ b/repos/os/src/lib/vfs/tar_file_system.h @@ -112,10 +112,10 @@ class Vfs::Tar_file_system : public File_system file_size size() const { return _long_name() ? _next()->size() : _read(_size); } long long mtime() const { return _long_name() ? _next()->mtime() : _read(_mtime); } - unsigned uid() const { return _long_name() ? _next()->uid() : _read(_uid); } - unsigned gid() const { return _long_name() ? _next()->gid() : _read(_gid); } - unsigned mode() const { return _long_name() ? _next()->mode() : _read(_mode); } - unsigned type() const { return _long_name() ? _next()->type() : _read(_type); } + unsigned uid() const { return _long_name() ? _next()->uid() : (unsigned)_read(_uid); } + unsigned gid() const { return _long_name() ? _next()->gid() : (unsigned)_read(_gid); } + unsigned mode() const { return _long_name() ? _next()->mode() : (unsigned)_read(_mode); } + unsigned type() const { return _long_name() ? _next()->type() : (unsigned)_read(_type); } void *data() const { return _long_name() ? _next()->data() : (void *)_data_begin(); } Node_rwx rwx() const @@ -186,7 +186,7 @@ class Vfs::Tar_file_system : public File_system char const *data = (char *)_node->record->data() + seek(); - memcpy(dst, data, count); + memcpy(dst, data, (size_t)count); out_count = count; return READ_OK; @@ -205,7 +205,7 @@ class Vfs::Tar_file_system : public File_system Dirent &dirent = *(Dirent*)dst; - file_offset const index = seek() / sizeof(Dirent); + unsigned const index = (unsigned)(seek() / sizeof(Dirent)); Node const *node_ptr = _node->lookup_child(index); @@ -279,7 +279,7 @@ class Vfs::Tar_file_system : public File_system file_size const count = min(buf_size, 100ULL); - memcpy(buf, record->linked_name(), count); + memcpy(buf, record->linked_name(), (size_t)count); out_count = count; @@ -461,7 +461,7 @@ class Vfs::Tar_file_system : public File_system void _for_each_tar_record_do(Tar_record_action tar_record_action) { /* measure size of archive in blocks */ - unsigned block_id = 0, block_cnt = _tar_size/Record::BLOCK_LEN; + unsigned block_id = 0, block_cnt = (unsigned)(_tar_size/Record::BLOCK_LEN); /* scan metablocks of archive */ while (block_id < block_cnt) { @@ -473,7 +473,7 @@ class Vfs::Tar_file_system : public File_system file_size size = record->storage_size(); /* some datablocks */ /* one metablock */ - block_id = block_id + (size / Record::BLOCK_LEN) + 1; + block_id = block_id + (unsigned)(size / Record::BLOCK_LEN) + 1; /* round up */ if (size % Record::BLOCK_LEN != 0) block_id++; @@ -580,10 +580,10 @@ class Vfs::Tar_file_system : public File_system try { Ram_dataspace_capability ds_cap = - _env.ram().alloc(record->size()); + _env.ram().alloc((size_t)record->size()); void *local_addr = _env.rm().attach(ds_cap); - memcpy(local_addr, record->data(), record->size()); + memcpy(local_addr, record->data(), (size_t)record->size()); _env.rm().detach(local_addr); return ds_cap; diff --git a/repos/os/src/lib/vfs/terminal_file_system.h b/repos/os/src/lib/vfs/terminal_file_system.h index b0ab7eb43f..f2b78cb620 100644 --- a/repos/os/src/lib/vfs/terminal_file_system.h +++ b/repos/os/src/lib/vfs/terminal_file_system.h @@ -88,9 +88,11 @@ class Vfs::Terminal_file_system::Data_file_system : public Single_file_system char buf[buf_size]; - unsigned const received = terminal.read(buf, buf_size); + using size_t = Genode::size_t; - for (unsigned i = 0; i < received; i++) { + size_t const received = terminal.read(buf, buf_size); + + for (size_t i = 0; i < received; i++) { char const c = buf[i]; @@ -159,7 +161,7 @@ class Vfs::Terminal_file_system::Data_file_system : public Single_file_system Write_result write(char const *src, file_size count, file_size &out_count) override { - out_count = _terminal.write(src, count); + out_count = _terminal.write(src, (size_t)count); return WRITE_OK; } }; diff --git a/repos/os/src/lib/vfs/zero_file_system.h b/repos/os/src/lib/vfs/zero_file_system.h index 372e3cc715..b1e6d5d822 100644 --- a/repos/os/src/lib/vfs/zero_file_system.h +++ b/repos/os/src/lib/vfs/zero_file_system.h @@ -67,7 +67,7 @@ struct Vfs::Zero_file_system : Single_file_system count = end_offset - read_offset; } - memset(dst, 0, count); + memset(dst, 0, (size_t)count); out_count = count; return READ_OK; diff --git a/repos/os/src/server/cached_fs_rom/main.cc b/repos/os/src/server/cached_fs_rom/main.cc index e8f9c087d4..d754430d67 100755 --- a/repos/os/src/server/cached_fs_rom/main.cc +++ b/repos/os/src/server/cached_fs_rom/main.cc @@ -167,7 +167,7 @@ struct Cached_fs_rom::Transfer final if (!_fs.tx()->ready_to_submit()) throw Packet_alloc_failed(); - size_t chunk_size = min(_size, _fs.tx()->bulk_buffer_size()/4); + size_t chunk_size = (size_t)min(_size, _fs.tx()->bulk_buffer_size()/4); return _fs.tx()->alloc_packet(chunk_size); } @@ -219,7 +219,7 @@ struct Cached_fs_rom::Transfer final error("packet seek is ", packet.position(), ", file seek is ", _seek, ", file size is ", _size); _seek = _size; } else { - size_t const n = min(packet.length(), _size - pkt_seek); + size_t const n = min(packet.length(), (size_t)(_size - pkt_seek)); memcpy(_cached_rom.ram_ds.local_addr()+pkt_seek, _fs.tx()->packet_content(packet), n); _seek = pkt_seek+n; @@ -380,14 +380,14 @@ struct Cached_fs_rom::Main final : Genode::Session_request_handler if (!rom) { File_system::File_handle handle = try_open(path); File_system::Handle_guard guard(fs, handle); - size_t file_size = fs.status(handle).size; + File_system::file_size_t file_size = fs.status(handle).size; while (env.pd().avail_ram().value < file_size || env.pd().avail_caps().value < 8) { /* drop unused cache entries */ if (!cache_evict()) break; } - rom = new (heap) Cached_rom(cache, env, rm, path, file_size); + rom = new (heap) Cached_rom(cache, env, rm, path, (size_t)file_size); } if (rom->completed()) { diff --git a/repos/os/src/server/cpu_balancer/target.mk b/repos/os/src/server/cpu_balancer/target.mk index 9a511f847b..7731518d41 100644 --- a/repos/os/src/server/cpu_balancer/target.mk +++ b/repos/os/src/server/cpu_balancer/target.mk @@ -3,3 +3,5 @@ SRC_CC = component.cc session.cc config.cc trace.cc schedule.cc LIBS = base CONFIG_XSD = config.xsd + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/server/dynamic_rom/main.cc b/repos/os/src/server/dynamic_rom/main.cc index 95d4175dab..008b0af5b2 100644 --- a/repos/os/src/server/dynamic_rom/main.cc +++ b/repos/os/src/server/dynamic_rom/main.cc @@ -140,7 +140,7 @@ class Dynamic_rom::Session_component : public Rpc_object exec_state = _execute_step(_rom_node.sub_node(_curr_idx)); /* advance step index, wrap at the end */ - _curr_idx = (_curr_idx + 1) % _rom_node.num_sub_nodes(); + _curr_idx = (_curr_idx + 1) % (unsigned)_rom_node.num_sub_nodes(); } } diff --git a/repos/os/src/server/event_dump/main.cc b/repos/os/src/server/event_dump/main.cc index c82767f6c1..8187ed30fc 100644 --- a/repos/os/src/server/event_dump/main.cc +++ b/repos/os/src/server/event_dump/main.cc @@ -38,7 +38,7 @@ struct Test::Event_session : Rpc_object void submit_batch(unsigned count) { - size_t const max_events = _ds.size() / sizeof(Input::Event); + unsigned const max_events = (unsigned)(_ds.size() / sizeof(Input::Event)); if (count > max_events) warning("number of events exceeds dataspace capacity"); diff --git a/repos/os/src/server/event_filter/accelerate_source.h b/repos/os/src/server/event_filter/accelerate_source.h index 2ad11941f7..8d53dbc733 100644 --- a/repos/os/src/server/event_filter/accelerate_source.h +++ b/repos/os/src/server/event_filter/accelerate_source.h @@ -43,11 +43,12 @@ class Event_filter::Accelerate_source : public Source, Source::Filter Lut(long curve) { /* clamp parameter to valid range */ - curve = min(255, max(0, curve)); + curve = min(255L, max(0L, curve)); auto fill_segment = [&] (long x1, long y1, long x2, long /* y2 */) { - for (long i = x1 >> 8; i <= (x2 >> 8); i++) values[i] = y1 >> 8; + for (long i = x1 >> 8; i <= (x2 >> 8); i++) + values[i] = (uint8_t)(y1 >> 8); }; long const x0 = 0, y0 = 0, x1 = curve, y1 = 0, @@ -75,8 +76,8 @@ class Event_filter::Accelerate_source : public Source, Source::Filter int _apply_acceleration(int v) const { int const sign = (v < 0) ? -1 : 1, - index = max(0, min(255, (sign*v*_sensitivity_percent)/100)), - accel = (_lut.values[index]*_max)/256; + index = (int)max(0L, min(255L, (sign*v*_sensitivity_percent)/100)), + accel = (int)((_lut.values[index]*_max)/256); return v + sign*accel; } diff --git a/repos/os/src/server/event_filter/button_scroll_source.h b/repos/os/src/server/event_filter/button_scroll_source.h index 1d75b9770f..7d93ff9771 100644 --- a/repos/os/src/server/event_filter/button_scroll_source.h +++ b/repos/os/src/server/event_filter/button_scroll_source.h @@ -59,7 +59,7 @@ class Event_filter::Button_scroll_source : public Source, Source::Filter Wheel(Xml_node config) : _button(key_code_by_name(_button_attribute(config).string())), - _factor(config.attribute_value("speed_percent", 0L)) + _factor((int)config.attribute_value("speed_percent", 0L)) { } void handle_activation(Input::Event const &event) diff --git a/repos/os/src/server/event_filter/chargen_source.h b/repos/os/src/server/event_filter/chargen_source.h index a6b8114764..484b6b8d30 100644 --- a/repos/os/src/server/event_filter/chargen_source.h +++ b/repos/os/src/server/event_filter/chargen_source.h @@ -269,10 +269,10 @@ class Event_filter::Chargen_source : public Source, Source::Filter } if (node.has_attribute("b0")) { - char const b0 = node.attribute_value("b0", 0L), - b1 = node.attribute_value("b1", 0L), - b2 = node.attribute_value("b2", 0L), - b3 = node.attribute_value("b3", 0L); + char const b0 = (char)node.attribute_value("b0", 0L), + b1 = (char)node.attribute_value("b1", 0L), + b2 = (char)node.attribute_value("b2", 0L), + b3 = (char)node.attribute_value("b3", 0L); char const buf[5] { b0, b1, b2, b3, 0 }; return Utf8_ptr(buf).codepoint(); diff --git a/repos/os/src/server/event_filter/event_session.h b/repos/os/src/server/event_filter/event_session.h index 554c20bfe6..599c1c26c0 100644 --- a/repos/os/src/server/event_filter/event_session.h +++ b/repos/os/src/server/event_filter/event_session.h @@ -113,7 +113,7 @@ class Event_filter::Event_session : public Session_object max_events) warning("number of events exceeds dataspace capacity"); diff --git a/repos/os/src/server/fs_report/main.cc b/repos/os/src/server/fs_report/main.cc index f10680ae2d..9b13545bd0 100644 --- a/repos/os/src/server/fs_report/main.cc +++ b/repos/os/src/server/fs_report/main.cc @@ -168,7 +168,7 @@ class Fs_report::Session_component : public Genode::Rpc_object return; } - offset += n; + offset += (size_t)n; } _file_size = length; diff --git a/repos/os/src/server/fs_rom/main.cc b/repos/os/src/server/fs_rom/main.cc index 49f9e9b3de..d17fc386a8 100755 --- a/repos/os/src/server/fs_rom/main.cc +++ b/repos/os/src/server/fs_rom/main.cc @@ -252,7 +252,7 @@ class Fs_rom::Rom_session_component : public Rpc_object return false; try { - _file_ds.realloc(&_env.ram(), _file_size); + _file_ds.realloc(&_env.ram(), (size_t)_file_size); } catch (...) { error("failed to allocate memory for ", _file_path); return false; @@ -272,7 +272,7 @@ class Fs_rom::Rom_session_component : public Rpc_object while (!source.ready_to_submit()) _env.ep().wait_and_dispatch_one_io_signal(); - size_t chunk_size = min(_file_size - _file_seek, + size_t chunk_size = min((size_t)(_file_size - _file_seek), source.bulk_buffer_size() / 2); File_system::Packet_descriptor @@ -287,7 +287,7 @@ class Fs_rom::Rom_session_component : public Rpc_object * for the read request (indicated by a change of the seek * position). */ - size_t const orig_file_seek = _file_seek; + File_system::seek_off_t const orig_file_seek = _file_seek; while (_file_seek == orig_file_seek) _env.ep().wait_and_dispatch_one_io_signal(); } @@ -333,7 +333,7 @@ class Fs_rom::Rom_session_component : public Rpc_object /* notify if the file is removed */ catch (File_system::Lookup_failed) { if (_file_size > 0) { - memset(_file_ds.local_addr(), 0x00, _file_size); + memset(_file_ds.local_addr(), 0x00, (size_t)_file_size); _file_size = 0; Signal_transmitter(_sigh).submit(); } @@ -455,7 +455,7 @@ class Fs_rom::Rom_session_component : public Rpc_object return; } - size_t const n = min(packet.length(), _file_size - _file_seek); + size_t const n = min(packet.length(), (size_t)(_file_size - _file_seek)); memcpy(_file_ds.local_addr()+_file_seek, _fs.tx()->packet_content(packet), n); _file_seek += n; diff --git a/repos/os/src/server/gui_fb/main.cc b/repos/os/src/server/gui_fb/main.cc index 923208896e..911200f79f 100644 --- a/repos/os/src/server/gui_fb/main.cc +++ b/repos/os/src/server/gui_fb/main.cc @@ -62,7 +62,7 @@ static Input::Event translate_event(Input::Event ev, }); ev.handle_touch([&] (Input::Touch_id id, float x, float y) { - Point p = clamp(translate(Point(x, y))); + Point p = clamp(translate(Point((int)x, (int)y))); ev = Input::Touch{id, (float)p.x(), (float)p.y()}; }); @@ -265,15 +265,15 @@ struct Nit_fb::Main : View_updater unsigned width(Framebuffer::Mode const &mode) const { - if (_width > 0) return _width; - if (_width < 0) return mode.area.w() + _width; + if (_width > 0) return (unsigned)_width; + if (_width < 0) return (unsigned)(mode.area.w() + _width); return mode.area.w(); } unsigned height(Framebuffer::Mode const &mode) const { - if (_height > 0) return _height; - if (_height < 0) return mode.area.h() + _height; + if (_height > 0) return (unsigned)_height; + if (_height < 0) return (unsigned)(mode.area.h() + _height); return mode.area.h(); } @@ -339,8 +339,8 @@ struct Nit_fb::Main : View_updater Framebuffer::Mode const gui_mode = gui.mode(); position = _coordinate_origin(gui_mode, config) - + Point(config.attribute_value("xpos", 0L), - config.attribute_value("ypos", 0L)); + + Point((int)config.attribute_value("xpos", 0L), + (int)config.attribute_value("ypos", 0L)); bool const attr = config.has_attribute("width") || config.has_attribute("height"); @@ -372,7 +372,7 @@ struct Nit_fb::Main : View_updater if (height < 0) height = gui_height + height; } - fb_session.size(Area(width, height)); + fb_session.size(Area((unsigned)width, (unsigned)height)); } void handle_config_update() diff --git a/repos/os/src/server/input_event_bridge/main.cc b/repos/os/src/server/input_event_bridge/main.cc index 8abd09e99c..f562001366 100644 --- a/repos/os/src/server/input_event_bridge/main.cc +++ b/repos/os/src/server/input_event_bridge/main.cc @@ -38,7 +38,7 @@ struct Input_event_bridge::Event_session : Rpc_object max_events) warning("number of events exceeds dataspace capacity"); diff --git a/repos/os/src/server/iso9660/target.mk b/repos/os/src/server/iso9660/target.mk index 7148a44e85..3d6d3a7950 100644 --- a/repos/os/src/server/iso9660/target.mk +++ b/repos/os/src/server/iso9660/target.mk @@ -1,3 +1,5 @@ TARGET = iso9660 SRC_CC = main.cc iso9660.cc LIBS = base + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/server/lx_block/main.cc b/repos/os/src/server/lx_block/main.cc index 12cc5c6547..5b9d87ead1 100644 --- a/repos/os/src/server/lx_block/main.cc +++ b/repos/os/src/server/lx_block/main.cc @@ -21,12 +21,14 @@ #include /* libc includes */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" #include #include #include #include #include /* perror */ - +#pragma GCC diagnostic pop /* restore -Wconversion warnings */ static bool xml_attr_ok(Genode::Xml_node node, char const *attr) { @@ -118,10 +120,10 @@ class Lx_block_driver : public Block::Driver char *buffer, Block::Packet_descriptor &packet) override { - off_t const offset = block_number * _info.block_size; - size_t const count = block_count * _info.block_size; + Block::sector_t const offset = block_number * _info.block_size; + size_t const count = block_count * _info.block_size; - ssize_t const n = pread(_fd, buffer, count, offset); + ssize_t const n = pread(_fd, buffer, count, (off_t)offset); if (n == -1) { perror("pread"); throw Io_error(); @@ -140,10 +142,10 @@ class Lx_block_driver : public Block::Driver throw Io_error(); } - off_t const offset = block_number * _info.block_size; - size_t const count = block_count * _info.block_size; + Block::sector_t const offset = block_number * _info.block_size; + size_t const count = block_count * _info.block_size; - ssize_t const n = pwrite(_fd, buffer, count, offset); + ssize_t const n = pwrite(_fd, buffer, count, (off_t)offset); if (n == -1) { perror("pwrite"); throw Io_error(); diff --git a/repos/os/src/server/lx_fs/directory.h b/repos/os/src/server/lx_fs/directory.h index 5305368990..d98bf7d9fc 100644 --- a/repos/os/src/server/lx_fs/directory.h +++ b/repos/os/src/server/lx_fs/directory.h @@ -21,9 +21,6 @@ #include #include -/* libc includes */ -#include - /* local includes */ #include "file.h" #include "lx_util.h" @@ -51,7 +48,7 @@ class Lx_fs::Directory : public Node Path _path; Allocator &_alloc; - unsigned long _inode(char const *path, bool create) + uint64_t _inode(char const *path, bool create) { int ret; @@ -107,7 +104,7 @@ class Lx_fs::Directory : public Node _path(path, "./"), _alloc(alloc) { - Node::name(basename(path)); + Node::name(File_system::basename(path)); } virtual ~Directory() @@ -258,7 +255,7 @@ class Lx_fs::Directory : public Node .rwx = { .readable = (st.st_mode & S_IRUSR) != 0, .writeable = (st.st_mode & S_IWUSR) != 0, .executable = (st.st_mode & S_IXUSR) != 0}, - .inode = inode(), + .inode = (unsigned long)inode(), .modification_time = { st.st_mtime } }; } diff --git a/repos/os/src/server/lx_fs/file.h b/repos/os/src/server/lx_fs/file.h index 041f875167..dfacbc1801 100644 --- a/repos/os/src/server/lx_fs/file.h +++ b/repos/os/src/server/lx_fs/file.h @@ -32,7 +32,7 @@ class Lx_fs::File : public Node int _fd; - unsigned long _inode(int dir, char const *name, bool create) + uint64_t _inode(int dir, char const *name, bool create) { int ret; @@ -56,7 +56,7 @@ class Lx_fs::File : public Node return s.st_ino; } - unsigned long _inode_path(char const *path) + uint64_t _inode_path(char const *path) { int ret; struct stat s; @@ -104,7 +104,7 @@ class Lx_fs::File : public Node Node(_inode_path(path)), _fd(_open_path(path, mode)) { - Node::name(basename(path)); + Node::name(File_system::basename(path)); } ~File() @@ -125,9 +125,9 @@ class Lx_fs::File : public Node size_t read(char *dst, size_t len, seek_off_t seek_offset) override { - int ret = pread(_fd, dst, len, seek_offset); + size_t ret = pread(_fd, dst, len, seek_offset); - return ret == -1 ? 0 : ret; + return (int)ret == -1 ? 0UL : ret; } size_t write(char const *src, size_t len, seek_off_t seek_offset) override @@ -140,9 +140,9 @@ class Lx_fs::File : public Node seek_offset = off; } - int ret = pwrite(_fd, src, len, seek_offset); + size_t ret = pwrite(_fd, src, len, seek_offset); - return ret == -1 ? 0 : ret; + return (int)ret == -1 ? 0UL : ret; } bool sync() override @@ -166,7 +166,7 @@ class Lx_fs::File : public Node .rwx = { .readable = (st.st_mode & S_IRUSR) != 0, .writeable = (st.st_mode & S_IWUSR) != 0, .executable = (st.st_mode & S_IXUSR) != 0}, - .inode = inode(), + .inode = (unsigned long)inode(), .modification_time = { st.st_mtime } }; } diff --git a/repos/os/src/server/lx_fs/lx_util.h b/repos/os/src/server/lx_fs/lx_util.h index 174fa64307..6a9276356a 100644 --- a/repos/os/src/server/lx_fs/lx_util.h +++ b/repos/os/src/server/lx_fs/lx_util.h @@ -22,12 +22,23 @@ /* Linux includes */ #define _FILE_OFFSET_BITS 64 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" #include #include #include +#include +#include #include +#include /* strerror */ +#include +#include #include +#include +#include +#include #include +#pragma GCC diagnostic pop /* restore -Wconversion warnings */ namespace File_system { diff --git a/repos/os/src/server/lx_fs/main.cc b/repos/os/src/server/lx_fs/main.cc index c0a656eeb1..6104880e43 100644 --- a/repos/os/src/server/lx_fs/main.cc +++ b/repos/os/src/server/lx_fs/main.cc @@ -32,11 +32,6 @@ #include "open_node.h" #include "watch.h" -/* libc includes */ -#include -#include - - namespace Lx_fs { using namespace File_system; diff --git a/repos/os/src/server/lx_fs/node.h b/repos/os/src/server/lx_fs/node.h index 06988cf9e1..bd8d84d5f0 100644 --- a/repos/os/src/server/lx_fs/node.h +++ b/repos/os/src/server/lx_fs/node.h @@ -31,6 +31,8 @@ namespace Lx_fs { using Absolute_path = Genode::Path; + using uint64_t = Genode::uint64_t; + class Node; class File; } @@ -44,19 +46,19 @@ class Lx_fs::Node : public File_system::Node_base private: - Name _name; - unsigned long const _inode; + Name _name; + + uint64_t const _inode; public: - Node(unsigned long inode) - : _inode { inode } + Node(uint64_t inode) : _inode { inode } { _name[0] = 0; } - unsigned long inode() const { return _inode; } - char const *name() const { return _name; } + uint64_t inode() const { return _inode; } + char const *name() const { return _name; } /** * Assign name diff --git a/repos/os/src/server/lx_fs/notifier.cc b/repos/os/src/server/lx_fs/notifier.cc index 863e4b8f3b..3da9a829ec 100644 --- a/repos/os/src/server/lx_fs/notifier.cc +++ b/repos/os/src/server/lx_fs/notifier.cc @@ -13,21 +13,10 @@ */ /* Genode includes */ -#include "base/exception.h" +#include #include -#include "base/signal.h" -#include "util/string.h" - -/* libc includes */ -#include -#include -#include -#include /* strerror */ -#include -#include -#include -#include -#include +#include +#include /* local includes */ #include "fd_set.h" @@ -53,9 +42,6 @@ namespace Lx_fs struct Libc_signal_thread; } -#include -#include -#include /* do not leak internal function in to global namespace */ namespace diff --git a/repos/os/src/server/mixer/target.mk b/repos/os/src/server/mixer/target.mk index 406ad43a4b..401a126ce5 100644 --- a/repos/os/src/server/mixer/target.mk +++ b/repos/os/src/server/mixer/target.mk @@ -1,3 +1,5 @@ TARGET = mixer SRC_CC = mixer.cc -LIBS = base +LIBS = base + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/server/nic_bridge/target.mk b/repos/os/src/server/nic_bridge/target.mk index b2e5172a30..a5e3e35edb 100644 --- a/repos/os/src/server/nic_bridge/target.mk +++ b/repos/os/src/server/nic_bridge/target.mk @@ -3,3 +3,5 @@ LIBS = base net SRC_CC = component.cc main.cc nic.cc packet_handler.cc CONFIG_XSD = config.xsd INC_DIR += $(PRG_DIR) + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/server/nic_dump/target.mk b/repos/os/src/server/nic_dump/target.mk index 8dfc1e457e..4064bd7bbe 100644 --- a/repos/os/src/server/nic_dump/target.mk +++ b/repos/os/src/server/nic_dump/target.mk @@ -7,3 +7,5 @@ SRC_CC += component.cc main.cc packet_log.cc uplink.cc interface.cc INC_DIR += $(PRG_DIR) CONFIG_XSD = config.xsd + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/server/nic_loopback/target.mk b/repos/os/src/server/nic_loopback/target.mk index 9c63672bfa..2d38b670e1 100644 --- a/repos/os/src/server/nic_loopback/target.mk +++ b/repos/os/src/server/nic_loopback/target.mk @@ -1,3 +1,5 @@ TARGET = nic_loopback SRC_CC = main.cc LIBS = base + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/server/nic_router/target.mk b/repos/os/src/server/nic_router/target.mk index df293c3800..2267411d94 100644 --- a/repos/os/src/server/nic_router/target.mk +++ b/repos/os/src/server/nic_router/target.mk @@ -33,3 +33,5 @@ SRC_CC += \ INC_DIR += $(PRG_DIR) CONFIG_XSD = config.xsd + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/server/nitpicker/domain_registry.h b/repos/os/src/server/nitpicker/domain_registry.h index 56e6d02b47..23e21d1851 100644 --- a/repos/os/src/server/nitpicker/domain_registry.h +++ b/repos/os/src/server/nitpicker/domain_registry.h @@ -200,13 +200,13 @@ class Nitpicker::Domain_registry return; } - unsigned const layer = domain.attribute_value("layer", ~0UL); + unsigned const layer = (unsigned)domain.attribute_value("layer", ~0UL); - Point const offset(domain.attribute_value("xpos", 0L), - domain.attribute_value("ypos", 0L)); + Point const offset((int)domain.attribute_value("xpos", 0L), + (int)domain.attribute_value("ypos", 0L)); - Point const area(domain.attribute_value("width", 0L), - domain.attribute_value("height", 0L)); + Point const area((int)domain.attribute_value("width", 0L), + (int)domain.attribute_value("height", 0L)); Color const color = domain.attribute_value("color", white()); diff --git a/repos/os/src/server/nitpicker/event_session.h b/repos/os/src/server/nitpicker/event_session.h index 3114a1b06f..62bf303d9b 100644 --- a/repos/os/src/server/nitpicker/event_session.h +++ b/repos/os/src/server/nitpicker/event_session.h @@ -66,7 +66,7 @@ class Nitpicker::Event_session : public Session_object max_events) warning("number of events exceeds dataspace capacity"); diff --git a/repos/os/src/server/nitpicker/gui_session.cc b/repos/os/src/server/nitpicker/gui_session.cc index 5d51bfd21e..6fc4190178 100644 --- a/repos/os/src/server/nitpicker/gui_session.cc +++ b/repos/os/src/server/nitpicker/gui_session.cc @@ -224,8 +224,8 @@ void Gui_session::submit_input_event(Input::Event e) e = Absolute_motion{max(0, x - origin_offset.x()), max(0, y - origin_offset.y())}; }); e.handle_touch([&] (Touch_id id, float x, float y) { - e = Touch{ id, max(0.0f, x - origin_offset.x()), - max(0.0f, y - origin_offset.y())}; }); + e = Touch{ id, max(0.0f, x - (float)origin_offset.x()), + max(0.0f, y - (float)origin_offset.y())}; }); _input_session_component.submit(&e); } diff --git a/repos/os/src/server/nitpicker/user_state.cc b/repos/os/src/server/nitpicker/user_state.cc index 73f2a5d2a2..d8d6c6a14f 100644 --- a/repos/os/src/server/nitpicker/user_state.cc +++ b/repos/os/src/server/nitpicker/user_state.cc @@ -308,7 +308,10 @@ User_state::handle_input_events(Input_batch batch) Input::Event curr = *e; if (e->absolute_motion() || e->relative_motion()) { - unsigned const n = num_consecutive_events(e, batch.count - src_ev_cnt); + + unsigned const n = + num_consecutive_events(e, (unsigned)(batch.count - src_ev_cnt)); + curr = merge_motion_events(e, n); /* skip merged events */ diff --git a/repos/os/src/server/part_block/gpt.h b/repos/os/src/server/part_block/gpt.h index 8eb9b42004..4134fea259 100644 --- a/repos/os/src/server/part_block/gpt.h +++ b/repos/os/src/server/part_block/gpt.h @@ -337,8 +337,8 @@ class Block::Gpt : public Block::Partition_table if (!e.valid()) continue; - uint64_t start = e.lba_start(); - uint64_t length = e.lba_end() - e.lba_start() + 1; /* [...) */ + block_number_t start = e.lba_start(); + block_count_t length = (block_count_t)(e.lba_end() - e.lba_start() + 1); /* [...) */ _part_list[i].construct(start, length); diff --git a/repos/os/src/server/part_block/main.cc b/repos/os/src/server/part_block/main.cc index e944a207bd..0888ed3998 100644 --- a/repos/os/src/server/part_block/main.cc +++ b/repos/os/src/server/part_block/main.cc @@ -239,7 +239,7 @@ class Block::Main : Rpc_object>, unsigned next_index = 0; for (long i = 0; i < MAX_SESSIONS; i++) { - unsigned index = (_wake_up_index + i) % MAX_SESSIONS; + unsigned index = (unsigned)((_wake_up_index + i) % MAX_SESSIONS); if (!_sessions[index]) continue; @@ -396,7 +396,7 @@ class Block::Main : Rpc_object>, ** Update_jobs_policy ** ************************/ - void consume_read_result(Job &job, off_t, + void consume_read_result(Job &job, seek_off_t, char const *src, size_t length) { if (!_sessions[job.number]) return; @@ -405,7 +405,7 @@ class Block::Main : Rpc_object>, job.offset += length; } - void produce_write_content(Job &job, off_t, char *dst, size_t length) + void produce_write_content(Job &job, seek_off_t, char *dst, size_t length) { memcpy(dst, (void *)(job.addr + job.offset), length); job.offset += length; diff --git a/repos/os/src/server/part_block/mbr.h b/repos/os/src/server/part_block/mbr.h index 1bc4483531..65ebabb4fe 100644 --- a/repos/os/src/server/part_block/mbr.h +++ b/repos/os/src/server/part_block/mbr.h @@ -212,7 +212,7 @@ struct Block::Mbr_partition_table : public Block::Partition_table /* no partition table, use whole disc as partition 0 */ if (!mbr_valid && !ahdi_valid) _part_list[0].construct( - Partition(0, block.info().block_count - 1)); + Partition(0, (block_count_t)(block.info().block_count - 1))); /* report the partitions */ if (reporter.enabled()) { diff --git a/repos/os/src/server/part_block/partition_table.h b/repos/os/src/server/part_block/partition_table.h index 8ab4dbf989..d41f3c2f8c 100644 --- a/repos/os/src/server/part_block/partition_table.h +++ b/repos/os/src/server/part_block/partition_table.h @@ -128,7 +128,7 @@ struct Block::Partition_table : Interface _data.block.update_jobs(*this); } - void consume_read_result(Block_connection::Job &, off_t, + void consume_read_result(Block_connection::Job &, seek_off_t, char const *src, size_t length) { _buffer = _data.alloc.alloc(length); @@ -136,7 +136,8 @@ struct Block::Partition_table : Interface _size = length; } - void produce_write_content(Block_connection::Job &, off_t, char *, size_t) { } + void produce_write_content(Block_connection::Job &, seek_off_t, + char *, size_t) { } void completed(Block_connection::Job &, bool success) { diff --git a/repos/os/src/server/tar_rom/target.mk b/repos/os/src/server/tar_rom/target.mk index d13b6fbf5c..e5e2ec38d6 100755 --- a/repos/os/src/server/tar_rom/target.mk +++ b/repos/os/src/server/tar_rom/target.mk @@ -1,3 +1,5 @@ TARGET = tar_rom SRC_CC = main.cc LIBS = base + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/server/terminal_log/main.cc b/repos/os/src/server/terminal_log/main.cc index dd3cb1a46b..4c69596b5d 100644 --- a/repos/os/src/server/terminal_log/main.cc +++ b/repos/os/src/server/terminal_log/main.cc @@ -60,7 +60,7 @@ namespace Genode { } char const *string = string_buf.string(); - int len = strlen(string); + size_t len = strlen(string); /* * Heuristic: The Log console implementation flushes diff --git a/repos/os/src/server/vfs/node.h b/repos/os/src/server/vfs/node.h index 707f662535..80b786e3aa 100644 --- a/repos/os/src/server/vfs/node.h +++ b/repos/os/src/server/vfs/node.h @@ -383,7 +383,7 @@ class Vfs_server::Io_node : public Vfs_server::Node, switch (_handle.fs().complete_read(&_handle, _payload_ptr.ptr, _packet.length(), out_count)) { case Read_result::READ_OK: - _acknowledge_as_success(out_count); + _acknowledge_as_success((size_t)out_count); break; case Read_result::READ_ERR_IO: @@ -404,8 +404,8 @@ class Vfs_server::Io_node : public Vfs_server::Node, * * \return number of consumed bytes */ - file_size _execute_write(char const *src_ptr, size_t length, - seek_off_t write_pos) + size_t _execute_write(char const *src_ptr, size_t length, + seek_off_t write_pos) { file_size out_count = 0; try { @@ -430,7 +430,7 @@ class Vfs_server::Io_node : public Vfs_server::Node, _modified = true; - return out_count; + return (size_t)out_count; } void _execute_sync() @@ -815,7 +815,7 @@ class Vfs_server::File : public Io_node case Packet_descriptor::WRITE: { - size_t const count = _packet.length() - _write_pos; + size_t const count = (size_t)(_packet.length() - _write_pos); char const * const src_ptr = _payload_ptr.ptr + _write_pos; size_t const consumed = _execute_write(src_ptr, count, _write_pos); @@ -936,14 +936,14 @@ struct Vfs_server::Directory : Io_node * * \return size of converted data in bytes */ - file_size _convert_vfs_dirents_to_fs_dirents() + size_t _convert_vfs_dirents_to_fs_dirents() { static_assert(sizeof(Vfs_dirent) == sizeof(Fs_dirent)); - file_offset const step = sizeof(Fs_dirent); - file_offset const length = _packet.length(); + size_t const step = sizeof(Fs_dirent); + size_t const length = _packet.length(); - file_size converted_length = 0; + size_t converted_length = 0; for (file_offset offset = 0; offset + step <= length; offset += step) { @@ -1058,7 +1058,7 @@ struct Vfs_server::Directory : Io_node _execute_read(); if (_acked_packet_valid) { - file_size const length = _convert_vfs_dirents_to_fs_dirents(); + size_t const length = _convert_vfs_dirents_to_fs_dirents(); /* * Overwrite the acknowledgement assigned by diff --git a/repos/os/src/test/block/client/target.mk b/repos/os/src/test/block/client/target.mk index 8a27c6cbf0..ccef43bbcf 100644 --- a/repos/os/src/test/block/client/target.mk +++ b/repos/os/src/test/block/client/target.mk @@ -1,3 +1,5 @@ TARGET = test-block-client SRC_CC = main.cc LIBS = base + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/test/block/server/target.mk b/repos/os/src/test/block/server/target.mk index f12cdf0dc9..dd7971adbc 100644 --- a/repos/os/src/test/block/server/target.mk +++ b/repos/os/src/test/block/server/target.mk @@ -1,3 +1,5 @@ TARGET = test-block-server SRC_CC = main.cc LIBS = base + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/test/capture/main.cc b/repos/os/src/test/capture/main.cc index 34317bd0ea..4b379fd4d9 100644 --- a/repos/os/src/test/capture/main.cc +++ b/repos/os/src/test/capture/main.cc @@ -68,8 +68,8 @@ struct Test::Main static Gui::Point _point_from_xml(Xml_node node) { - return Gui::Point(node.attribute_value("xpos", 0L), - node.attribute_value("ypos", 0L)); + return Gui::Point((int)node.attribute_value("xpos", 0L), + (int)node.attribute_value("ypos", 0L)); } static Gui::Area _area_from_xml(Xml_node node, Gui::Area default_area) diff --git a/repos/os/src/test/event_filter/main.cc b/repos/os/src/test/event_filter/main.cc index 2d896fcc61..86787787a3 100644 --- a/repos/os/src/test/event_filter/main.cc +++ b/repos/os/src/test/event_filter/main.cc @@ -66,7 +66,7 @@ struct Test::Event_session : Rpc_object void submit_batch(unsigned count) { - size_t const max_events = _ds.size() / sizeof(Input::Event); + unsigned const max_events = (unsigned)(_ds.size() / sizeof(Input::Event)); if (count > max_events) warning("number of events exceeds dataspace capacity"); @@ -300,7 +300,7 @@ struct Test::Main : Input_from_filter::Event_handler void _deep_filter_config(Reporter &reporter, Xml_node node) { - unsigned const depth = node.attribute_value("depth", 0UL); + unsigned const depth = node.attribute_value("depth", 0U); Reporter::Xml_generator xml(reporter, [&] () { xml.node("input", [&] () { xml.attribute("label", "usb"); }); @@ -308,7 +308,7 @@ struct Test::Main : Input_from_filter::Event_handler }); } - unsigned const _num_steps = _config.xml().num_sub_nodes(); + unsigned const _num_steps = (unsigned)_config.xml().num_sub_nodes(); unsigned _curr_step = 0; uint64_t _went_to_sleep_time = 0; diff --git a/repos/os/src/test/fb_bench/main.cc b/repos/os/src/test/fb_bench/main.cc index f3ce9a53fe..f8727bd1ef 100644 --- a/repos/os/src/test/fb_bench/main.cc +++ b/repos/os/src/test/fb_bench/main.cc @@ -51,7 +51,7 @@ struct Test memset(buf[1], ~0, fb_ds.size()); } - void conclusion(unsigned kib, uint64_t start_ms, uint64_t end_ms) { + void conclusion(size_t kib, uint64_t start_ms, uint64_t end_ms) { log("throughput: ", kib / (end_ms - start_ms), " MiB/sec"); } ~Test() { log("\nTEST ", id, " finished\n"); } @@ -65,13 +65,14 @@ struct Test Test &operator = (Test const &); }; + struct Bytewise_ram_test : Test { static constexpr char const *brief = "byte-wise memcpy from RAM to RAM"; Bytewise_ram_test(Env &env, int id) : Test(env, id, brief) { - unsigned kib = 0; + size_t kib = 0; uint64_t const start_ms = timer.elapsed_ms(); for (; timer.elapsed_ms() - start_ms < DURATION_MS;) { memcpy(buf[0], buf[1], fb_ds.size()); @@ -81,13 +82,14 @@ struct Bytewise_ram_test : Test } }; + struct Bytewise_fb_test : Test { static constexpr char const *brief = "byte-wise memcpy from RAM to FB"; Bytewise_fb_test(Env &env, int id) : Test(env, id, brief) { - unsigned kib = 0; + size_t kib = 0; uint64_t const start_ms = timer.elapsed_ms(); for (unsigned i = 0; timer.elapsed_ms() - start_ms < DURATION_MS; i++) { memcpy(fb_ds.local_addr(), buf[i % 2], fb_ds.size()); @@ -105,7 +107,7 @@ struct Blit_test : Test { unsigned kib = 0; uint64_t const start_ms = timer.elapsed_ms(); - unsigned const w = fb_mode.area.w() * fb_mode.bytes_per_pixel(); + unsigned const w = (unsigned)(fb_mode.area.w() * fb_mode.bytes_per_pixel()); unsigned const h = fb_mode.area.h(); for (unsigned i = 0; timer.elapsed_ms() - start_ms < DURATION_MS; i++) { blit(buf[i % 2], w, fb_ds.local_addr(), w, w, h); @@ -123,7 +125,7 @@ struct Unaligned_blit_test : Test { unsigned kib = 0; uint64_t const start_ms = timer.elapsed_ms(); - unsigned const w = fb_mode.area.w() * fb_mode.bytes_per_pixel(); + unsigned const w = (unsigned)(fb_mode.area.w() * fb_mode.bytes_per_pixel()); unsigned const h = fb_mode.area.h(); for (unsigned i = 0; timer.elapsed_ms() - start_ms < DURATION_MS; i++) { blit(buf[i % 2] + 2, w, fb_ds.local_addr() + 2, w, w - 2, h); diff --git a/repos/os/src/test/immutable_rom/component.cc b/repos/os/src/test/immutable_rom/component.cc index 1bdb8d1ef5..d27d270a73 100644 --- a/repos/os/src/test/immutable_rom/component.cc +++ b/repos/os/src/test/immutable_rom/component.cc @@ -22,7 +22,7 @@ void Component::construct(Genode::Env &env) Attached_rom_dataspace rom(env, "test"); log("--- writing to ROM dataspace ---"); for (size_t i = 0; i < rom.size(); ++i) { - rom.local_addr()[i] = i; + rom.local_addr()[i] = (char)i; log("--- ROM dataspace modified at ", (Hex)i, "! ---"); } env.parent().exit(0); diff --git a/repos/os/src/test/init/main.cc b/repos/os/src/test/init/main.cc index 38436cc335..ee89a7bbac 100644 --- a/repos/os/src/test/init/main.cc +++ b/repos/os/src/test/init/main.cc @@ -206,7 +206,7 @@ struct Test::Main : Log_message_handler }); } - unsigned const _num_steps = _config.xml().num_sub_nodes(); + unsigned const _num_steps = (unsigned)_config.xml().num_sub_nodes(); unsigned _curr_step = 0; Xml_node _curr_step_xml() const { return _config.xml().sub_node(_curr_step); } diff --git a/repos/os/src/test/lx_fs_notify/file_writer/main.cc b/repos/os/src/test/lx_fs_notify/file_writer/main.cc index c30180efed..e23ee3e692 100644 --- a/repos/os/src/test/lx_fs_notify/file_writer/main.cc +++ b/repos/os/src/test/lx_fs_notify/file_writer/main.cc @@ -12,14 +12,15 @@ * under the terms of the GNU Affero General Public License version 3. */ - /* libc includes */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" #include #include #include #include #include - +#pragma GCC diagnostic pop /* stdcxx includes */ #include diff --git a/repos/os/src/test/net_flood/target.mk b/repos/os/src/test/net_flood/target.mk index 9df2191a96..7416f0992e 100644 --- a/repos/os/src/test/net_flood/target.mk +++ b/repos/os/src/test/net_flood/target.mk @@ -8,3 +8,5 @@ SRC_CC += nic.cc ipv4_config.cc INC_DIR += $(PRG_DIR) CONFIG_XSD = config.xsd + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/test/nic_loopback/target.mk b/repos/os/src/test/nic_loopback/target.mk index fd40103ee2..b4d5489bf6 100644 --- a/repos/os/src/test/nic_loopback/target.mk +++ b/repos/os/src/test/nic_loopback/target.mk @@ -1,3 +1,5 @@ TARGET = test-nic_loopback SRC_CC = main.cc LIBS = base + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/test/nic_router_dhcp/client/target.mk b/repos/os/src/test/nic_router_dhcp/client/target.mk index 5cdf6856d6..04ac34adf7 100644 --- a/repos/os/src/test/nic_router_dhcp/client/target.mk +++ b/repos/os/src/test/nic_router_dhcp/client/target.mk @@ -6,3 +6,5 @@ SRC_CC += main.cc dhcp_client.cc ipv4_address_prefix.cc SRC_CC += nic.cc ipv4_config.cc INC_DIR += $(PRG_DIR) + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/test/nic_router_dhcp/manager/target.mk b/repos/os/src/test/nic_router_dhcp/manager/target.mk index 095352407f..e8b6390e3e 100644 --- a/repos/os/src/test/nic_router_dhcp/manager/target.mk +++ b/repos/os/src/test/nic_router_dhcp/manager/target.mk @@ -8,3 +8,5 @@ INC_DIR += $(PRG_DIR) $(REP_DIR)/src/server/nic_router vpath dns.cc $(REP_DIR)/src/server/nic_router vpath xml_node.cc $(REP_DIR)/src/server/nic_router + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/test/nic_stress/target.mk b/repos/os/src/test/nic_stress/target.mk index 0a26a14e98..7650b9e65f 100644 --- a/repos/os/src/test/nic_stress/target.mk +++ b/repos/os/src/test/nic_stress/target.mk @@ -2,3 +2,5 @@ TARGET = test-nic_stress SRC_CC = main.cc LIBS = base CONFIG_XSD = config.xsd + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/test/nitpicker/test.cc b/repos/os/src/test/nitpicker/test.cc index 6285768f6c..cce1a49d81 100644 --- a/repos/os/src/test/nitpicker/test.cc +++ b/repos/os/src/test/nitpicker/test.cc @@ -187,7 +187,7 @@ void Component::construct(Genode::Env &env) for (int j = 0; j < scr_w; j++) { pixels[i*scr_w + j] = PT((3*i)/8, j, i*j/32); if (CONFIG_ALPHA) { - alpha[i*scr_w + j] = (i*2) ^ (j*2); + alpha[i*scr_w + j] = (unsigned char)((i*2) ^ (j*2)); input_mask[i*scr_w + j] = alpha[i*scr_w + j] > 127; } } diff --git a/repos/os/src/test/pci/target.mk b/repos/os/src/test/pci/target.mk index ba9724e545..eaf0a717f7 100644 --- a/repos/os/src/test/pci/target.mk +++ b/repos/os/src/test/pci/target.mk @@ -2,3 +2,5 @@ TARGET = test-pci SRC_CC = test.cc LIBS = base REQUIRES = x86 + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/test/ram_fs_chunk/main.cc b/repos/os/src/test/ram_fs_chunk/main.cc index 8c95879d6b..09db62f93b 100644 --- a/repos/os/src/test/ram_fs_chunk/main.cc +++ b/repos/os/src/test/ram_fs_chunk/main.cc @@ -34,7 +34,7 @@ struct Chunk_level_0 : Chunk_index<5, Chunk_level_1> if (used_size() > Chunk_level_0::SIZE) { throw Index_out_of_range(); } - read(read_buf, used_size(), 0); + read(read_buf, (size_t)used_size(), 0); Genode::print(out, "content (size=", used_size(), "): "); Genode::print(out, "\""); for (unsigned i = 0; i < used_size(); i++) { diff --git a/repos/os/src/test/terminal_echo/main.cc b/repos/os/src/test/terminal_echo/main.cc index e28a6f4d45..5833316d89 100644 --- a/repos/os/src/test/terminal_echo/main.cc +++ b/repos/os/src/test/terminal_echo/main.cc @@ -29,9 +29,9 @@ struct Main void handle_read_avail() { - unsigned num_bytes = terminal.read(read_buffer, sizeof(read_buffer)); + size_t num_bytes = terminal.read(read_buffer, sizeof(read_buffer)); log("got ", num_bytes, " byte(s)"); - for (unsigned i = 0; i < num_bytes; i++) { + for (size_t i = 0; i < num_bytes; i++) { if (read_buffer[i] == '\r') { terminal.write("\n", 1); } terminal.write(&read_buffer[i], 1); diff --git a/repos/os/src/test/terminal_expect_send/main.cc b/repos/os/src/test/terminal_expect_send/main.cc index 2e679bc67d..185e69d09e 100644 --- a/repos/os/src/test/terminal_expect_send/main.cc +++ b/repos/os/src/test/terminal_expect_send/main.cc @@ -34,9 +34,9 @@ struct Main void handle_read_avail() { - unsigned num_bytes = terminal.read(read_buffer, sizeof(read_buffer)); + size_t num_bytes = terminal.read(read_buffer, sizeof(read_buffer)); - for (unsigned i = 0; i < num_bytes; i++) { + for (size_t i = 0; i < num_bytes; i++) { /* copy over all characters other than line-end */ if (read_buffer[i] != '\n' && diff --git a/repos/os/src/test/timeout/target.mk b/repos/os/src/test/timeout/target.mk index d5e522101b..7ad2a9a8cf 100644 --- a/repos/os/src/test/timeout/target.mk +++ b/repos/os/src/test/timeout/target.mk @@ -2,3 +2,5 @@ TARGET = test-timeout SRC_CC += main.cc LIBS += base INC_DIR += $(PRG_DIR) + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/os/src/test/uart/main.cc b/repos/os/src/test/uart/main.cc index f6776514d4..423ba6e579 100644 --- a/repos/os/src/test/uart/main.cc +++ b/repos/os/src/test/uart/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -24,15 +24,14 @@ struct Main { Timer::Connection timer; Uart::Connection uart; - char buf[100]; Main(Env &env) : timer(env), uart(env) { log("--- UART test started ---"); for (unsigned i = 0; ; ++i) { - int n = snprintf(buf, sizeof(buf), "UART test message %d\n", i); - uart.write(buf, n); + String<200> const msg("UART test message ", i); + uart.write(msg.string(), msg.length() - 1); timer.msleep(2000); } } diff --git a/repos/os/src/test/vfs_stress/main.cc b/repos/os/src/test/vfs_stress/main.cc index 68bd65446c..a92bc560f8 100644 --- a/repos/os/src/test/vfs_stress/main.cc +++ b/repos/os/src/test/vfs_stress/main.cc @@ -208,7 +208,7 @@ struct Mkdir_test : public Stress_test } } - int wait() + Vfs::file_size wait() { return count; } @@ -271,7 +271,7 @@ struct Populate_test : public Stress_test } } - int wait() + Vfs::file_size wait() { return count; } @@ -385,7 +385,7 @@ struct Read_test : public Stress_test assert_read(read_result); - if (strcmp(path.base(), tmp, n)) + if (strcmp(path.base(), tmp, (size_t)n)) error("read returned bad data"); count += n; } @@ -510,7 +510,7 @@ struct Unlink_test : public Stress_test } } - int wait() + Vfs::file_size wait() { return count; } @@ -560,7 +560,7 @@ void Component::construct(Genode::Env &env) ** Generate directories ** **************************/ { - int count = 0; + Vfs::file_size count = 0; log("generating directory surface..."); elapsed_ms = timer.elapsed_ms(); @@ -587,7 +587,7 @@ void Component::construct(Genode::Env &env) ** Generate files ** ********************/ { - int count = 0; + Vfs::file_size count = 0; log("generating files..."); elapsed_ms = timer.elapsed_ms(); diff --git a/repos/os/src/test/vmm_x86/target.mk b/repos/os/src/test/vmm_x86/target.mk index c5b3fe048b..8d9c6f31d0 100644 --- a/repos/os/src/test/vmm_x86/target.mk +++ b/repos/os/src/test/vmm_x86/target.mk @@ -2,3 +2,5 @@ TARGET = test-vmm_x86 REQUIRES = x86 SRC_CC = component.cc LIBS = base + +CC_CXX_WARN_STRICT_CONVERSION =