From 97a35cb39091080229d8730d7e7e7607d05c8d33 Mon Sep 17 00:00:00 2001 From: Timothy Werquin Date: Mon, 31 Jul 2023 21:01:05 +0200 Subject: [PATCH] GCC 13 and Werror cleanups Removes some unused code, and ensures most code compiles with gcc 13. --- apps/rocket/main.cpp | 2 -- apps/yaft/fb/common.cpp | 21 --------------------- apps/yaft/keyboard.cpp | 2 -- apps/yaft/util.h | 24 +++++++++++++++++------- libs/rMlib/include/Input.h | 1 + tools/input-test/main.cpp | 32 ++++++++++++++++---------------- 6 files changed, 34 insertions(+), 48 deletions(-) diff --git a/apps/rocket/main.cpp b/apps/rocket/main.cpp index 3ebfe5a..1e17271 100755 --- a/apps/rocket/main.cpp +++ b/apps/rocket/main.cpp @@ -15,8 +15,6 @@ namespace { #define KEY_POWER 116 #endif -constexpr auto config_path_suffix = ".config/rocket/config"; - std::vector stoppedChildren; std::function stopCallback; diff --git a/apps/yaft/fb/common.cpp b/apps/yaft/fb/common.cpp index 04ee4ce..d6dba13 100755 --- a/apps/yaft/fb/common.cpp +++ b/apps/yaft/fb/common.cpp @@ -6,21 +6,6 @@ #include namespace { -inline uint16_t -color2pixel(uint32_t color) { - uint32_t r, g, b; - - r = 0xFF & (color >> (BITS_PER_RGB * 2)); - g = 0xFF & (color >> BITS_PER_RGB); - b = 0xFF & (color >> 0); - - // RGB 565 - r = r >> (BITS_PER_RGB - 5); - g = g >> (BITS_PER_RGB - 6); - b = b >> (BITS_PER_RGB - 5); - - return (r << 11) | (g << 5) | (b << 0); -} inline uint16_t color2brightness(uint32_t color) { @@ -211,12 +196,6 @@ draw_line(rmlib::fb::FrameBuffer& fb, struct terminal_t* term, int line) { void refresh(rmlib::fb::FrameBuffer& fb, struct terminal_t* term) { - // if (term->palette_modified) { - // term->palette_modified = false; - // for (int i = 0; i < COLORS; i++) - // fb.real_palette[i] = color2pixel(&fb.info, term->virtual_palette[i]); - // } - if (term->mode & MODE_CURSOR) term->line_dirty[term->cursor.y] = true; diff --git a/apps/yaft/keyboard.cpp b/apps/yaft/keyboard.cpp index f4e8d6d..070f936 100755 --- a/apps/yaft/keyboard.cpp +++ b/apps/yaft/keyboard.cpp @@ -412,7 +412,6 @@ Keyboard::initKeyMap() { ctrlKey = -1; int y = startHeight; - int rowNum = 0; const auto& currentLayout = hidden ? hidden_layout : layout; @@ -437,7 +436,6 @@ Keyboard::initKeyMap() { } y += key_height; - rowNum++; } int marginLeft = term->width - term->cols * CELL_WIDTH; diff --git a/apps/yaft/util.h b/apps/yaft/util.h index 09a377c..58dab29 100644 --- a/apps/yaft/util.h +++ b/apps/yaft/util.h @@ -7,21 +7,31 @@ enum loglevel_t { FATAL, }; +static inline const char* +loglevel2str(enum loglevel_t loglevel) { + switch (loglevel) { + case DEBUG: + return "DEBUG"; + case WARN: + return "WARN"; + case ERROR: + return "ERROR"; + case FATAL: + return "FATAL"; + default: + return "UNK"; + } +} + static inline void logging(enum loglevel_t loglevel, const char* format, ...) { va_list arg; - static const char* loglevel2str[] = { - [DEBUG] = "DEBUG", - [WARN] = "WARN", - [ERROR] = "ERROR", - [FATAL] = "FATAL", - }; /* debug message is available on verbose mode */ if ((loglevel == DEBUG) && (VERBOSE == false)) return; - fprintf(stderr, ">>%s<<\t", loglevel2str[loglevel]); + fprintf(stderr, ">>%s<<\t", loglevel2str(loglevel)); va_start(arg, format); vfprintf(stderr, format, arg); diff --git a/libs/rMlib/include/Input.h b/libs/rMlib/include/Input.h index 9517ae4..43972ae 100755 --- a/libs/rMlib/include/Input.h +++ b/libs/rMlib/include/Input.h @@ -4,6 +4,7 @@ #include "MathUtil.h" #include +#include #include #include #include diff --git a/tools/input-test/main.cpp b/tools/input-test/main.cpp index 240512d..befa158 100644 --- a/tools/input-test/main.cpp +++ b/tools/input-test/main.cpp @@ -149,22 +149,22 @@ printEvent(const KeyEvent& ev) { int main() { - // struct udev* udev = udev_new(); - // if (!udev) { - // fprintf(stderr, "udev_new() failed\n"); - // return 1; - // } - - // enumerate_devices(udev); - // monitor_devices(udev); - - // udev_unref(udev); - - // auto deviceType = device::getDeviceType(); - // if (deviceType.isError()) { - // std::cerr << "Unknown device\n"; - // return -1; - // } + struct udev* udev = udev_new(); + if (!udev) { + fprintf(stderr, "udev_new() failed\n"); + return 1; + } + + enumerate_devices(udev); + monitor_devices(udev); + + udev_unref(udev); + + auto deviceType = device::getDeviceType(); + if (deviceType.isError()) { + std::cerr << "Unknown device\n"; + return -1; + } InputManager input; auto err = input.openAll();