From f7d33010e529286a7359ed78825961b9e5a43586 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Sun, 23 Dec 2018 21:29:42 +0100 Subject: [PATCH] gems: strict warning fixes Issue #3094 --- repos/gems/include/gems/animator.h | 2 +- repos/gems/include/gems/file.h | 6 + repos/gems/include/gems/png_image.h | 150 +++++++++++------- .../include/polygon_gfx/interpolate_rgba.h | 2 +- 4 files changed, 98 insertions(+), 62 deletions(-) diff --git a/repos/gems/include/gems/animator.h b/repos/gems/include/gems/animator.h index 2ebaed4074..996a5638e9 100644 --- a/repos/gems/include/gems/animator.h +++ b/repos/gems/include/gems/animator.h @@ -28,7 +28,7 @@ class Animator friend class Item; - Genode::List > _items; + Genode::List > _items { }; public: diff --git a/repos/gems/include/gems/file.h b/repos/gems/include/gems/file.h index e35dca2a57..7ae5d385e2 100644 --- a/repos/gems/include/gems/file.h +++ b/repos/gems/include/gems/file.h @@ -21,6 +21,12 @@ class File { private: + /* + * Noncopyable + */ + File(File const &); + File & operator = (File const &); + Genode::Allocator &_alloc; Genode::size_t const _file_size; void *_data; diff --git a/repos/gems/include/gems/png_image.h b/repos/gems/include/gems/png_image.h index a7c3339381..36c783e475 100644 --- a/repos/gems/include/gems/png_image.h +++ b/repos/gems/include/gems/png_image.h @@ -49,90 +49,120 @@ class Png_image Genode::Region_map &_rm; Genode::Allocator &_alloc; - struct Read_struct + class Read_struct { - /* start of PNG data */ - png_bytep const data; + private: - /* read position, maintained by 'read_callback' */ - unsigned pos = 0; + /* + * Noncopyable + */ + Read_struct(Read_struct const &); + Read_struct & operator = (Read_struct const &); - static void callback(png_structp png_ptr, png_bytep dst, png_size_t len) - { - Read_struct &read_struct = *(Read_struct *)png_get_io_ptr(png_ptr); - Genode::memcpy(dst, read_struct.data + read_struct.pos, len); - read_struct.pos += len; - } + public: - png_structp png_ptr = - _assert_non_null( - png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0)); + /* start of PNG data */ + png_bytep const data; - Read_struct(void *data) : data((png_bytep)data) - { - png_set_read_fn(png_ptr, this, callback); - } + /* read position, maintained by 'read_callback' */ + unsigned pos = 0; - ~Read_struct() - { - png_destroy_read_struct(&png_ptr, nullptr, nullptr); - } + static void callback(png_structp png_ptr, png_bytep dst, png_size_t len) + { + Read_struct &read_struct = *(Read_struct *)png_get_io_ptr(png_ptr); + Genode::memcpy(dst, read_struct.data + read_struct.pos, len); + read_struct.pos += len; + } + + png_structp png_ptr = + _assert_non_null( + png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0)); + + Read_struct(void *data) : data((png_bytep)data) + { + png_set_read_fn(png_ptr, this, callback); + } + + ~Read_struct() + { + png_destroy_read_struct(&png_ptr, nullptr, nullptr); + } }; Read_struct _read_struct; - struct Info + class Info { - png_structp png_ptr; - png_infop info_ptr; + private: - int bit_depth, color_type, interlace_type; - png_uint_32 img_w, img_h; + /* + * Noncopyable + */ + Info(Info const &); + Info & operator = (Info const &); - Info(png_structp png_ptr) - : - png_ptr(png_ptr), - info_ptr(_assert_non_null(png_create_info_struct(png_ptr))) - { - png_read_info(png_ptr, info_ptr); + public: - png_get_IHDR(png_ptr, info_ptr, &img_w, &img_h, &bit_depth, &color_type, - &interlace_type, nullptr, nullptr); + png_structp png_ptr; + png_infop info_ptr; - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); + int bit_depth = 0, color_type = 0, interlace_type = 0; + png_uint_32 img_w = 0, img_h = 0; - if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); + Info(png_structp png_ptr) + : + png_ptr(png_ptr), + info_ptr(_assert_non_null(png_create_info_struct(png_ptr))) + { + png_read_info(png_ptr, info_ptr); - if (bit_depth < 8) png_set_packing(png_ptr); - if (bit_depth == 16) png_set_strip_16(png_ptr); - } + png_get_IHDR(png_ptr, info_ptr, &img_w, &img_h, &bit_depth, &color_type, + &interlace_type, nullptr, nullptr); - ~Info() - { - png_destroy_info_struct(png_ptr, &info_ptr); - } + if (color_type == PNG_COLOR_TYPE_PALETTE) + png_set_palette_to_rgb(png_ptr); + + if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png_ptr); + + if (bit_depth < 8) png_set_packing(png_ptr); + if (bit_depth == 16) png_set_strip_16(png_ptr); + } + + ~Info() + { + png_destroy_info_struct(png_ptr, &info_ptr); + } } _info { _read_struct.png_ptr }; - struct Row + class Row { - Genode::Allocator &alloc; - size_t const row_num_bytes; - png_bytep const row_ptr; + private: - Row(Genode::Allocator &alloc, png_structp png_ptr, png_infop info_ptr) - : - alloc(alloc), - row_num_bytes(png_get_rowbytes(png_ptr, info_ptr)*8), - row_ptr((png_bytep)alloc.alloc(row_num_bytes)) - { } + /* + * Noncopyable + */ + Row(Row const &); + Row & operator = (Row const &); - ~Row() - { - alloc.free(row_ptr, row_num_bytes); - } + public: + + Genode::Allocator &alloc; + size_t const row_num_bytes; + png_bytep const row_ptr; + + Row(Genode::Allocator &alloc, png_structp png_ptr, png_infop info_ptr) + : + alloc(alloc), + row_num_bytes(png_get_rowbytes(png_ptr, info_ptr)*8), + row_ptr((png_bytep)alloc.alloc(row_num_bytes)) + { } + + ~Row() + { + alloc.free(row_ptr, row_num_bytes); + } } _row { _alloc, _read_struct.png_ptr, _info.info_ptr }; public: diff --git a/repos/gems/include/polygon_gfx/interpolate_rgba.h b/repos/gems/include/polygon_gfx/interpolate_rgba.h index 7be032d373..eeb127f0f1 100644 --- a/repos/gems/include/polygon_gfx/interpolate_rgba.h +++ b/repos/gems/include/polygon_gfx/interpolate_rgba.h @@ -36,7 +36,7 @@ static inline void Polygon::interpolate_rgba(Polygon::Color start, PT *dst, unsigned char *dst_alpha, unsigned num_values, - int x, int y) + int, int) { /* sanity check */ if (num_values == 0) return;