Fix several build warnings

This commit is contained in:
Cameron Gutman 2023-10-29 19:56:18 +00:00
parent c007eabf50
commit dc03235a62
4 changed files with 8 additions and 8 deletions

View File

@ -90,7 +90,7 @@ void cec_init() {
g_iface.init_video_standalone(g_iface.connection);
cec_adapter devices[10];
int8_t iDevicesFound = g_iface.find_adapters(g_iface.connection, devices, sizeof(devices) / sizeof(devices), NULL);
int8_t iDevicesFound = g_iface.find_adapters(g_iface.connection, devices, sizeof(devices) / sizeof(devices[0]), NULL);
if (iDevicesFound <= 0) {
fprintf(stderr, "No CEC devices found\n");

View File

@ -1009,9 +1009,9 @@ void evdev_map(char* device) {
for (int i = 0; i < 16; i++)
buf += sprintf(buf, "%02x", ((unsigned char*) guid)[i]);
struct mapping map;
strncpy(map.name, name, sizeof(map.name));
strncpy(map.guid, str_guid, sizeof(map.guid));
struct mapping map = {0};
strncpy(map.name, name, sizeof(map.name) - 1);
strncpy(map.guid, str_guid, sizeof(map.guid) - 1);
libevdev_free(evdev);
close(fd);

View File

@ -38,8 +38,8 @@ struct mapping* mapping_parse(char* mapping) {
exit(EXIT_FAILURE);
}
strncpy(map->guid, guid, sizeof(map->guid));
strncpy(map->name, name, sizeof(map->name));
strncpy(map->guid, guid, sizeof(map->guid) - 1);
strncpy(map->name, name, sizeof(map->name) - 1);
/* Initialize all mapping indices to -1 to ensure they won't match anything */
memset(&map->abs_leftx, -1, offsetof(struct mapping, next) - offsetof(struct mapping, abs_leftx));
@ -58,7 +58,7 @@ struct mapping* mapping_parse(char* mapping) {
value++;
}
if (strcmp("platform", key) == 0)
strncpy(map->platform, value, sizeof(map->platform));
strncpy(map->platform, value, sizeof(map->platform) - 1);
else if (sscanf(value, "b%d", &int_value) == 1) {
if (strcmp("a", key) == 0)
map->btn_a = int_value;

View File

@ -74,7 +74,7 @@ void loop_add_fd(int fd, FdHandler handler, int events) {
void loop_remove_fd(int fd) {
numFds--;
int fdindex;
int fdindex = numFds;
for (int i=0;i<=numFds;i++) {
if (fds[i].fd == fd) {