os: avoid implicit conversions

Issue #23
This commit is contained in:
Norman Feske 2021-12-02 11:23:38 +01:00
parent 03047009b1
commit 04cf6ea3ab
167 changed files with 651 additions and 532 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -64,7 +64,7 @@ class Block::Session_client : public Genode::Rpc_client<Session>
*/
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);
}
};

View File

@ -142,7 +142,7 @@ struct Block::Connection : Genode::Connection<Session>, 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>, 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>, 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<JOB>::_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<JOB>::_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 };
});
}

View File

@ -134,8 +134,8 @@ class Decorator::Window_base : private Genode::List_model<Window_base>::Element
using List_model<Window_base>::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)
{

View File

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

View File

@ -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_ */

View File

@ -120,7 +120,7 @@ class Gpio::Root : public Genode::Root_component<Gpio::Session_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);

View File

@ -37,22 +37,23 @@ struct I2c::Connection : Genode::Connection<I2c::Session>, 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));
}
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,7 +18,7 @@
namespace Genode {
typedef Genode::Pixel_rgba<unsigned char, Genode::Surface_base::ALPHA8,
typedef Genode::Pixel_rgba<uint8_t, Genode::Surface_base::ALPHA8,
0, 0, 0, 0, 0, 0, 0xff, 0>
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;
}

View File

@ -18,7 +18,7 @@
namespace Genode {
typedef Pixel_rgba<unsigned short, Surface_base::RGB565,
typedef Pixel_rgba<uint16_t, Surface_base::RGB565,
0xf800, 8, 0x07e0, 3, 0x001f, -3, 0, 0>
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;
}
}

View File

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

View File

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

View File

@ -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_ */

View File

@ -22,7 +22,7 @@ namespace Genode {
template <>
inline void
Texture<Pixel_rgb888>::rgba(unsigned char const *rgba, unsigned len, int y)
Texture<Pixel_rgb888>::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);
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -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 */

View File

@ -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_ */

View File

@ -66,8 +66,7 @@ namespace Terminal {
{
unsigned char const _c;
template <typename T>
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 <typename T>
explicit Ecma(T c) : _c(c) { }
explicit Ecma(unsigned char c) : _c(c) { }
void print(Genode::Output &out) const
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,9 +20,12 @@ template <typename T>
inline T host_to_big_endian(T x)
{
Genode::uint8_t v[sizeof(T)];
for (unsigned i=0; i<sizeof(T); i++) {
unsigned mask = (sizeof(T) - i - 1) * 8;
v[i] = (x & (0xff << mask)) >> 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;
}

View File

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

View File

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

View File

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

View File

@ -48,6 +48,7 @@ namespace Vfs {
using Genode::static_cap_cast;
using Genode::Interface;
using Genode::String;
using Genode::size_t;
struct Timestamp
{

View File

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

View File

@ -137,7 +137,7 @@ class Virtio::Device : Platform::Device::Mmio
write<QueueSel>(queue_index);
if (read<QueueReady>() != 0) {
return 0; }
return read<QueueNumMax>();
return (uint16_t)read<QueueNumMax>();
}
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<Config_8>(value, offset); break;
case ACCESS_16BIT: write<Config_16>(value, (offset >> 1)); break;
case ACCESS_32BIT: write<Config_32>(value, (offset >> 2)); break;
case ACCESS_8BIT: write<Config_8> ((uint8_t) value, offset); break;
case ACCESS_16BIT: write<Config_16>((uint16_t)value, (offset >> 1)); break;
case ACCESS_32BIT: write<Config_32>(value, (offset >> 2)); break;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,3 +8,5 @@ SRC_CC += nic.cc ipv4_config.cc
INC_DIR += $(PRG_DIR)
CONFIG_XSD = config.xsd
CC_CXX_WARN_STRICT_CONVERSION =

View File

@ -109,7 +109,7 @@ void Rom_logger::Main::_handle_update()
} else if (format == "hexdump") {
short const *data = _rom_ds->local_addr<short const>();
/* 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]),

View File

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

View File

@ -83,7 +83,7 @@ struct Trace_subject_registry
unsigned update_subjects(Genode::Trace::Connection &trace)
{
return Genode::retry<Genode::Out_of_ram>(
return (unsigned)Genode::retry<Genode::Out_of_ram>(
[&] () { return trace.subjects(_subjects, MAX_SUBJECTS); },
[&] () { trace.upgrade_ram(4096); }
);

View File

@ -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<unsigned long>(attr, 0); }
static unsigned _get_value(Xml_node node, char const * const attr) {
return node.attribute_value<unsigned>(attr, 0U); }
static bool _config_has_device(Xml_node config, Entry const &entry)
{

View File

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

View File

@ -235,7 +235,7 @@ namespace Ahci {
/* read_dma_ext : write_dma_ext */
write<Command>(read ? 0x25 : 0x35);
write<Lba>(block_number);
write<Sector>(block_count);
write<Sector>((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<Command>(read ? 0x60 : 0x61);
write<Lba>(block_number);
write<Features>(block_count);
write<Sector0_7::Tag>(slot);
write<Features>((uint16_t)block_count);
write<Sector0_7::Tag>((uint8_t)slot);
}
void flush_cache_ext()
@ -269,8 +269,8 @@ namespace Ahci {
*/
void byte_count(uint16_t bytes)
{
write<Lba8_15>(bytes & 0xff);
write<Lba16_23>(bytes >> 8);
write<Lba8_15> ((uint8_t)(bytes & 0xff));
write<Lba16_23>((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<Ctba0>(addr);
write<Ctba0_u0>(addr >> 32);
write<Ctba0>((uint32_t)addr);
write<Ctba0_u0>((uint32_t)(addr >> 32));
write<Prdtl>(1);
write<Bits::Cfl>(Command_fis::size() / sizeof(unsigned));
}
@ -364,8 +364,8 @@ namespace Ahci {
void read10(block_number_t block_number, block_count_t block_count)
{
write<Command>(0x28);
write<Lba>(block_number);
write<Sector>(block_count);
write<Lba>((uint32_t)block_number);
write<Sector>((uint16_t)block_count);
}
void start_unit()
@ -393,9 +393,9 @@ namespace Ahci {
: Mmio(base)
{
uint64_t addr = phys;
write<Dba>(addr);
write<Dbau>(addr >> 32);
write<Bits::Dbc>(bytes > 0 ? bytes - 1 : 0);
write<Dba>((uint32_t)addr);
write<Dbau>((uint32_t)(addr >> 32));
write<Bits::Dbc>((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<Clb>(addr);
write<Clbu>(addr >> 32);
write<Clb> ((uint32_t)(addr));
write<Clbu>((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<Fb>(addr);
write<Fbu>(addr >> 32);
write<Fb> ((uint32_t)(addr));
write<Fbu>((uint32_t)(addr >> 32));
}
/**

View File

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

View File

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

View File

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

View File

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

View File

@ -20,7 +20,10 @@
#include <timer_session/connection.h>
/* Linux includes */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <SDL/SDL.h>
#pragma GCC diagnostic pop
/* local includes */
#include "convert_keycode.h"

View File

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

View File

@ -390,7 +390,9 @@ class Igd::Execlist_context : public Igd::Common_context_regs
{
typename Ring_buffer_start_value::access_t v = read<Ring_buffer_start_value>();
/* 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<Ring_buffer_start_value>(v);
}

View File

@ -1289,8 +1289,8 @@ class Igd::Mmio : public Genode::Mmio
v |= (p[i] & 0xff) << (8 * i);
}
write<PAT_INDEX_L>(v);
write<PAT_INDEX_H>(v >> 32);
write<PAT_INDEX_L>((uint32_t)(v));
write<PAT_INDEX_H>((uint32_t)(v >> 32));
}
/**

View File

@ -5,3 +5,5 @@ LIBS = base
REQUIRES = x86
INC_DIR += $(PRG_DIR)
CC_CXX_WARN_STRICT_CONVERSION =

View File

@ -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<Mmio::Control::Tx_rx_select>(0);
if (m.count() > 1) {
@ -149,7 +149,7 @@ void I2c::Driver::_read(uint8_t address, I2c::Session::Message & m)
_mmio.write<Mmio::Control::Tx_ack_enable>(1);
}
byte = _mmio.read<Mmio::Data>();
byte = (uint8_t)_mmio.read<Mmio::Data>();
_irq.ack();
});
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,3 +3,5 @@ SRC_CC = main.cc
INC_DIR += $(PRG_DIR)
LIBS += base
REQUIRES = x86
CC_CXX_WARN_STRICT_CONVERSION =

View File

@ -5,3 +5,5 @@ SRC_CC += device_pd.cc
LIBS = base
INC_DIR = $(PRG_DIR)
CC_CXX_WARN_STRICT_CONVERSION =

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -144,7 +144,7 @@ class I2c::I2c : Platform::Device::Mmio
try {
_start();
_write(addr << 1 | 1);
_write((Genode::uint8_t)(addr << 1 | 1));
write<Control::Tx_rx_select>(0);
if (num > 1)
@ -166,7 +166,7 @@ class I2c::I2c : Platform::Device::Mmio
write<Control::Tx_ack_enable>(1);
}
buf[i] = read<Data>();
buf[i] = (Genode::uint8_t)read<Data>();
_irq_handler.ack();
}

View File

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

View File

@ -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_ */

View File

@ -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<LCR>(0x80); /* select bank 1 */
_outb<LCR>(0x80u); /* select bank 1 */
for (volatile int i = 10000000; i--; );
_outb<DLLO>((115200/baud) >> 0);
_outb<DLHI>((115200/baud) >> 8);
_outb<LCR>(0x03); /* set 8,N,1 */
_outb<IER>(0x00); /* disable interrupts */
_outb<EIR>(0x07); /* enable FIFOs */
_outb<MCR>(0x0b); /* force data terminal ready */
_outb<IER>(0x01); /* enable RX interrupts */
_outb<DLLO>(((115200/baud) >> 0) && 0xff);
_outb<DLHI>(((115200/baud) >> 8) && 0xff);
_outb<LCR>(0x03u); /* set 8,N,1 */
_outb<IER>(0x00u); /* disable interrupts */
_outb<EIR>(0x07u); /* enable FIFOs */
_outb<MCR>(0x0bu); /* force data terminal ready */
_outb<IER>(0x01u); /* enable RX interrupts */
_inb<IER>();
_inb<EIR>();
_inb<LCR>();
@ -103,7 +103,7 @@ class Uart::Driver : public Uart::Driver_base
_inb<MSR>();
}
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<TRB>();
}
void baud_rate(int bits_per_second) override
void baud_rate(size_t bits_per_second) override
{
_init_comport(bits_per_second);
}

View File

@ -116,7 +116,7 @@ class Uart::Session_component : public Rpc_object<Uart::Session,
&& _read_number(height) == ';'
&& _read_number(width) == 'R') {
Genode::log("detected terminal size ", width, "x", height);
log("detected terminal size ", width, "x", height);
return Size(width, height);
}
@ -142,7 +142,7 @@ class Uart::Session_component : public Rpc_object<Uart::Session,
** Uart session interface **
****************************/
void baud_rate(Genode::size_t bits_per_second) override
void baud_rate(size_t bits_per_second) override
{
_driver.baud_rate(bits_per_second);
}

View File

@ -86,7 +86,7 @@ class Uart::Driver_base
/**
* Set baud rate for terminal
*/
virtual void baud_rate(int baud)
virtual void baud_rate(size_t baud)
{
Genode::warning("Setting baudrate to ", baud,
" is not supported. Use default value.");

View File

@ -2,3 +2,5 @@ TARGET = usb_block_drv
SRC_CC = main.cc
INC_DIR = $(PRG_DIR)
LIBS = base
CC_CXX_WARN_STRICT_CONVERSION =

View File

@ -25,18 +25,18 @@
using namespace Genode;
struct Device {
unsigned long vendor;
unsigned long product;
unsigned long cla;
unsigned long bus;
unsigned long dev;
genode_usb_session * usb_session { nullptr };
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;
genode_usb_session * usb_session { nullptr };
Device(unsigned long vendor,
unsigned long product,
unsigned long cla,
unsigned long bus,
unsigned long dev)
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)
: vendor(vendor), product(product),
cla(cla), bus(bus), dev(dev) {}
@ -62,7 +62,7 @@ class genode_usb_session : public Usb::Session_rpc_object
::Root & _root;
Attached_dataspace & _ds;
Signal_context_capability _sigh_state_cap {};
unsigned short _id;
genode_usb_session_handle_t _id;
Session_label const _label;
List_element<genode_usb_session> _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<genode_usb_session>
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<genode_usb_session>
Reporter _reporter { _env, "devices" };
Constructible<Device> _devices[MAX_DEVICES];
List<List_element<genode_usb_session>> _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<genode_usb_session>
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<genode_usb_session>
*
* \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<unsigned long>("vendor_id", 0);
unsigned long product = policy.attribute_value<unsigned long>("product_id", 0);
unsigned long bus = policy.attribute_value<unsigned long>("bus", 0);
unsigned long dev = policy.attribute_value<unsigned long>("dev", 0);
unsigned long cla = policy.attribute_value<unsigned long>("class", 0);
genode_usb_vendor_id_t vendor =
policy.attribute_value<genode_usb_vendor_id_t>("vendor_id", 0);
genode_usb_product_id_t product =
policy.attribute_value<genode_usb_product_id_t>("product_id", 0);
genode_usb_bus_num_t bus =
policy.attribute_value<genode_usb_bus_num_t>("bus", 0);
genode_usb_dev_num_t dev =
policy.attribute_value<genode_usb_dev_num_t>("dev", 0);
genode_usb_class_num_t cla =
policy.attribute_value<genode_usb_class_num_t>("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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -222,13 +222,13 @@ namespace Sandbox {
width = node.attribute_value<unsigned long>("width", default_width),
height = node.attribute_value<unsigned long>("height", default_height);
long const x1 = node.attribute_value<long>("xpos", 0),
y1 = node.attribute_value<long>("ypos", 0),
x2 = x1 + width - 1,
y2 = y1 + height - 1;
int const x1 = (int)node.attribute_value<long>("xpos", 0),
y1 = (int)node.attribute_value<long>("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()));
}

View File

@ -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> _info_fs { "info", Info { } };
Readonly_value_file_system<Genode::uint64_t> _block_count_fs { "block_count", 0 };
Readonly_value_file_system<Genode::size_t> _block_size_fs { "block_size", 0 };
Readonly_value_file_system<size_t> _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)

View File

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

Some files were not shown because too many files have changed in this diff Show More