summaryrefslogtreecommitdiffstats
path: root/minui
diff options
context:
space:
mode:
Diffstat (limited to 'minui')
-rw-r--r--minui/events.cpp15
-rw-r--r--minui/resources.cpp28
2 files changed, 21 insertions, 22 deletions
diff --git a/minui/events.cpp b/minui/events.cpp
index 3b2262a4b..a6b9671ed 100644
--- a/minui/events.cpp
+++ b/minui/events.cpp
@@ -49,7 +49,7 @@ static unsigned ev_count = 0;
static unsigned ev_dev_count = 0;
static unsigned ev_misc_count = 0;
-static bool test_bit(size_t bit, unsigned long* array) {
+static bool test_bit(size_t bit, unsigned long* array) { // NOLINT
return (array[bit/BITS_PER_LONG] & (1UL << (bit % BITS_PER_LONG))) != 0;
}
@@ -65,7 +65,8 @@ int ev_init(ev_callback input_cb, void* data) {
if (dir != NULL) {
dirent* de;
while ((de = readdir(dir))) {
- unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)];
+ // Use unsigned long to match ioctl's parameter type.
+ unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; // NOLINT
// fprintf(stderr,"/dev/input/%s\n", de->d_name);
if (strncmp(de->d_name, "event", 5)) continue;
@@ -175,8 +176,9 @@ int ev_get_input(int fd, uint32_t epevents, input_event* ev) {
}
int ev_sync_key_state(ev_set_key_callback set_key_cb, void* data) {
- unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)];
- unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)];
+ // Use unsigned long to match ioctl's parameter type.
+ unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; // NOLINT
+ unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)]; // NOLINT
for (size_t i = 0; i < ev_dev_count; ++i) {
memset(ev_bits, 0, sizeof(ev_bits));
@@ -203,8 +205,9 @@ int ev_sync_key_state(ev_set_key_callback set_key_cb, void* data) {
}
void ev_iterate_available_keys(std::function<void(int)> f) {
- unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)];
- unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)];
+ // Use unsigned long to match ioctl's parameter type.
+ unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; // NOLINT
+ unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)]; // NOLINT
for (size_t i = 0; i < ev_dev_count; ++i) {
memset(ev_bits, 0, sizeof(ev_bits));
diff --git a/minui/resources.cpp b/minui/resources.cpp
index 40d3c2c88..730b05f13 100644
--- a/minui/resources.cpp
+++ b/minui/resources.cpp
@@ -28,6 +28,7 @@
#include <linux/fb.h>
#include <linux/kd.h>
+#include <vector>
#include <png.h>
#include "minui.h"
@@ -280,7 +281,7 @@ int res_create_multi_display_surface(const char* name, int* frames, int* fps,
goto exit;
}
- surface = reinterpret_cast<GRSurface**>(malloc(*frames * sizeof(GRSurface*)));
+ surface = reinterpret_cast<GRSurface**>(calloc(*frames, sizeof(GRSurface*)));
if (surface == NULL) {
result = -8;
goto exit;
@@ -315,7 +316,7 @@ exit:
if (result < 0) {
if (surface) {
for (int i = 0; i < *frames; ++i) {
- if (surface[i]) free(surface[i]);
+ free(surface[i]);
}
free(surface);
}
@@ -391,18 +392,13 @@ int res_create_localized_alpha_surface(const char* name,
png_infop info_ptr = NULL;
png_uint_32 width, height;
png_byte channels;
- unsigned char* row;
png_uint_32 y;
+ std::vector<unsigned char> row;
*pSurface = NULL;
if (locale == NULL) {
- surface = malloc_surface(0);
- surface->width = 0;
- surface->height = 0;
- surface->row_bytes = 0;
- surface->pixel_bytes = 1;
- goto exit;
+ return result;
}
result = open_png(name, &png_ptr, &info_ptr, &width, &height, &channels);
@@ -413,13 +409,13 @@ int res_create_localized_alpha_surface(const char* name,
goto exit;
}
- row = reinterpret_cast<unsigned char*>(malloc(width));
+ row.resize(width);
for (y = 0; y < height; ++y) {
- png_read_row(png_ptr, row, NULL);
+ png_read_row(png_ptr, row.data(), NULL);
int w = (row[1] << 8) | row[0];
int h = (row[3] << 8) | row[2];
- int len = row[4];
- char* loc = (char*)row+5;
+ __unused int len = row[4];
+ char* loc = reinterpret_cast<char*>(&row[5]);
if (y+1+h >= height || matches_locale(loc, locale)) {
printf(" %20s: %s (%d x %d @ %d)\n", name, loc, w, h, y);
@@ -436,8 +432,8 @@ int res_create_localized_alpha_surface(const char* name,
int i;
for (i = 0; i < h; ++i, ++y) {
- png_read_row(png_ptr, row, NULL);
- memcpy(surface->data + i*w, row, w);
+ png_read_row(png_ptr, row.data(), NULL);
+ memcpy(surface->data + i*w, row.data(), w);
}
*pSurface = reinterpret_cast<GRSurface*>(surface);
@@ -445,7 +441,7 @@ int res_create_localized_alpha_surface(const char* name,
} else {
int i;
for (i = 0; i < h; ++i, ++y) {
- png_read_row(png_ptr, row, NULL);
+ png_read_row(png_ptr, row.data(), NULL);
}
}
}