add: -Wpedantic build flag and fix code
This commit is contained in:
parent
11f1a79d6a
commit
5b9f2aa49b
7 changed files with 15 additions and 13 deletions
|
@ -6,7 +6,7 @@ add_executable(controller main.c)
|
||||||
option(WIRING_PI_DEBUG "Use WiringPi Debugging Tool (0=off, 1=silent, 2=LOG_DEBUG) (0)" OFF)
|
option(WIRING_PI_DEBUG "Use WiringPi Debugging Tool (0=off, 1=silent, 2=LOG_DEBUG) (0)" OFF)
|
||||||
option(LOG_LEVEL "Set logging level (5=trace, 4=debug, 3=info, 2=warn, 1=error, 0=fatal) (3)" OFF)
|
option(LOG_LEVEL "Set logging level (5=trace, 4=debug, 3=info, 2=warn, 1=error, 0=fatal) (3)" OFF)
|
||||||
|
|
||||||
SET(CMAKE_C_FLAGS "-Wall -Wextra -lwiringPi -lwiringPiDev -luuid -llmdb -g")
|
SET(CMAKE_C_FLAGS "-Wall -Wextra -Werror -Wpedantic -lwiringPi -lwiringPiDev -luuid -llmdb -g")
|
||||||
|
|
||||||
string(LENGTH "${CMAKE_SOURCE_DIR}/" SOURCE_PATH_SIZE)
|
string(LENGTH "${CMAKE_SOURCE_DIR}/" SOURCE_PATH_SIZE)
|
||||||
add_definitions("-DSOURCE_PATH_SIZE=${SOURCE_PATH_SIZE}")
|
add_definitions("-DSOURCE_PATH_SIZE=${SOURCE_PATH_SIZE}")
|
||||||
|
|
|
@ -60,11 +60,11 @@ controller_debug(controller_t *controller)
|
||||||
}
|
}
|
||||||
char uuid_str[37];
|
char uuid_str[37];
|
||||||
uuid_unparse(controller->id, uuid_str);
|
uuid_unparse(controller->id, uuid_str);
|
||||||
LOG_DEBUG("(1/5) %s @ %p", uuid_str, controller);
|
LOG_DEBUG("(1/5) %s @ %p", uuid_str, (void*)controller);
|
||||||
LOG_DEBUG("(2/5) name: %s", controller->name);
|
LOG_DEBUG("(2/5) name: %s", controller->name);
|
||||||
LOG_DEBUG("(3/5) command_port: %5d discovery_port: %5d", controller->command_port, controller->discovery_port);
|
LOG_DEBUG("(3/5) command_port: %5d discovery_port: %5d", controller->command_port, controller->discovery_port);
|
||||||
LOG_DEBUG("(4/5) relay count: %3d", controller->relay_count);
|
LOG_DEBUG("(4/5) relay count: %3d", controller->relay_count);
|
||||||
LOG_DEBUG("(5/5) relays @ %p:", controller->relays);
|
LOG_DEBUG("(5/5) relays @ %p:", (void*)controller->relays);
|
||||||
for(uint8_t i = 0; i < controller->relay_count; ++i)
|
for(uint8_t i = 0; i < controller->relay_count; ++i)
|
||||||
{
|
{
|
||||||
relay_debug(controller->relays[i]);
|
relay_debug(controller->relays[i]);
|
||||||
|
|
|
@ -65,7 +65,7 @@ relay_debug(relay_t *relay)
|
||||||
LOG_DEBUG("relay is NULL");
|
LOG_DEBUG("relay is NULL");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG_DEBUG("(1/3) %d @ %p", relay->number, relay);
|
LOG_DEBUG("(1/3) %d @ %p", relay->number, (void*)relay);
|
||||||
LOG_DEBUG("(2/3) name: %s", relay->name);
|
LOG_DEBUG("(2/3) name: %s", relay->name);
|
||||||
LOG_DEBUG("(3/3) schedule:");
|
LOG_DEBUG("(3/3) schedule:");
|
||||||
schedule_debug(relay->schedule);
|
schedule_debug(relay->schedule);
|
||||||
|
|
|
@ -14,8 +14,8 @@ relay_load_single(MDB_txn *mdb_txn, MDB_dbi mdb_dbi, db_key_relay_e key_relay, u
|
||||||
|
|
||||||
size_t key_size = sizeof(db_key_relay_e) + sizeof(uint8_t);
|
size_t key_size = sizeof(db_key_relay_e) + sizeof(uint8_t);
|
||||||
void *key_data = malloc(key_size);
|
void *key_data = malloc(key_size);
|
||||||
memmove(key_data, &key_relay, sizeof(db_key_relay_e));
|
memmove((uint8_t*)key_data, &key_relay, sizeof(db_key_relay_e));
|
||||||
memmove(key_data + sizeof(db_key_relay_e), &num, sizeof(uint8_t));
|
memmove((uint8_t*)key_data + sizeof(db_key_relay_e), &num, sizeof(uint8_t));
|
||||||
|
|
||||||
MDB_val key;
|
MDB_val key;
|
||||||
key.mv_size = key_size;
|
key.mv_size = key_size;
|
||||||
|
|
|
@ -14,8 +14,8 @@ relay_save_single(MDB_txn *mdb_txn, MDB_dbi mdb_dbi, db_key_relay_e key_relay, u
|
||||||
|
|
||||||
size_t key_size = sizeof(db_key_relay_e) + sizeof(uint8_t);
|
size_t key_size = sizeof(db_key_relay_e) + sizeof(uint8_t);
|
||||||
void *key_data = malloc(key_size);
|
void *key_data = malloc(key_size);
|
||||||
memmove(key_data, &key_relay, sizeof(db_key_relay_e));
|
memmove((uint8_t*)key_data, &key_relay, sizeof(db_key_relay_e));
|
||||||
memmove(key_data + sizeof(db_key_relay_e), &num, sizeof(uint8_t));
|
memmove((uint8_t*)key_data + sizeof(db_key_relay_e), &num, sizeof(uint8_t));
|
||||||
|
|
||||||
MDB_val key;
|
MDB_val key;
|
||||||
key.mv_size = key_size;
|
key.mv_size = key_size;
|
||||||
|
|
|
@ -66,7 +66,7 @@ schedule_debug(schedule_t *schedule)
|
||||||
}
|
}
|
||||||
char uuid_str[37];
|
char uuid_str[37];
|
||||||
uuid_unparse(schedule->id, uuid_str);
|
uuid_unparse(schedule->id, uuid_str);
|
||||||
LOG_DEBUG("(1/3) %s @ %p", uuid_str, schedule);
|
LOG_DEBUG("(1/3) %s @ %p", uuid_str, (void*)schedule);
|
||||||
LOG_DEBUG("(2/3) period count: %3d", schedule->length);
|
LOG_DEBUG("(2/3) period count: %3d", schedule->length);
|
||||||
|
|
||||||
// one block: "HH:MM-HH:MM, " --> size: 13 (14 with '\0')
|
// one block: "HH:MM-HH:MM, " --> size: 13 (14 with '\0')
|
||||||
|
|
10
vendor/confini.c
vendored
10
vendor/confini.c
vendored
|
@ -1959,6 +1959,7 @@ static size_t further_cuts (char * const srcstr, const IniFormat format) {
|
||||||
follow (switch case fallthrough).
|
follow (switch case fallthrough).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
__attribute__((fallthrough));
|
||||||
|
|
||||||
case _LIBCONFINI_VT_:
|
case _LIBCONFINI_VT_:
|
||||||
case _LIBCONFINI_FF_:
|
case _LIBCONFINI_FF_:
|
||||||
|
@ -2527,6 +2528,7 @@ int strip_ini_cache (
|
||||||
(switch case fallthrough).
|
(switch case fallthrough).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
__attribute__((fallthrough));
|
||||||
|
|
||||||
case _LIBCONFINI_SC_INT_MARKER_:
|
case _LIBCONFINI_SC_INT_MARKER_:
|
||||||
|
|
||||||
|
@ -2819,7 +2821,7 @@ int load_ini_file (
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_size > SIZE_MAX) {
|
if ((size_t) file_size > SIZE_MAX) {
|
||||||
|
|
||||||
return CONFINI_EFBIG;
|
return CONFINI_EFBIG;
|
||||||
|
|
||||||
|
@ -2835,7 +2837,7 @@ int load_ini_file (
|
||||||
|
|
||||||
rewind(ini_file);
|
rewind(ini_file);
|
||||||
|
|
||||||
if (fread(cache, 1, (size_t) file_size, ini_file) < file_size) {
|
if (fread(cache, 1, (size_t) file_size, ini_file) < (size_t) file_size) {
|
||||||
|
|
||||||
free(cache);
|
free(cache);
|
||||||
return CONFINI_EIO;
|
return CONFINI_EIO;
|
||||||
|
@ -2911,7 +2913,7 @@ int load_ini_path (
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_size > SIZE_MAX) {
|
if ((size_t) file_size > SIZE_MAX) {
|
||||||
|
|
||||||
return CONFINI_EFBIG;
|
return CONFINI_EFBIG;
|
||||||
|
|
||||||
|
@ -2927,7 +2929,7 @@ int load_ini_path (
|
||||||
|
|
||||||
rewind(ini_file);
|
rewind(ini_file);
|
||||||
|
|
||||||
if (fread(cache, 1, (size_t) file_size, ini_file) < file_size) {
|
if (fread(cache, 1, (size_t) file_size, ini_file) < (size_t) file_size) {
|
||||||
|
|
||||||
free(cache);
|
free(cache);
|
||||||
return CONFINI_EIO;
|
return CONFINI_EIO;
|
||||||
|
|
Loading…
Reference in a new issue