diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c791a9..de06cb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,8 +9,9 @@ target_link_libraries(core -lsqlite3) target_link_libraries(core -luuid) set(CMAKE_C_FLAGS "$ENV{CFLAGS}") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wpedantic -Werror -Wall -Wextra -ffile-prefix-map=${CMAKE_SOURCE_DIR}/src/=") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=gnu99 -Wpedantic -Werror -Wall -Wextra -ffile-prefix-map=${CMAKE_SOURCE_DIR}/src/=") +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -fprofile-arcs -ftest-coverage") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -fprofile-arcs -ftest-coverage") add_definitions("-DMG_ENABLE_EXTRA_ERRORS_DESC -DMG_ENABLE_MQTT_BROKER") diff --git a/src/models/junction_relay_schedule.c b/src/models/junction_relay_schedule.c index 69366fc..e2b2309 100644 --- a/src/models/junction_relay_schedule.c +++ b/src/models/junction_relay_schedule.c @@ -40,7 +40,7 @@ junction_relay_schedule_insert_weekdays(int relay_id, int *schedule_ids) static const char query_base[] = "INSERT INTO junction_relay_schedule (weekday, schedule_id, relay_id) VALUES"; static const char query_extender[] = " (?, ?, ?)"; - size_t query_len = STRLEN(query_base) + (7 * (STRLEN(query_extender) + 1)); + size_t query_len = STRLEN(query_base) + (7 * (STRLEN(query_extender) + 1)) + 1; char *query = malloc(sizeof(char) * query_len + 1); strncpy(query, query_base, query_len); query_len -= STRLEN(query_base); diff --git a/src/models/junction_tag.c b/src/models/junction_tag.c index 2866948..919c3d7 100644 --- a/src/models/junction_tag.c +++ b/src/models/junction_tag.c @@ -67,7 +67,7 @@ junction_tag_insert_list(int *tag_ids, int relay_id, int schedule_id, int count) static const char query_base[] = "INSERT INTO junction_tag(tag_id, schedule_id, relay_id) VALUES"; static const char query_extender[] = " (?, ?, ?)"; - size_t query_len = STRLEN(query_base) + (count * (STRLEN(query_extender) + 1)); + size_t query_len = STRLEN(query_base) + (count * (STRLEN(query_extender) + 1)) + 1; char *query = malloc(sizeof(char) * query_len + 1); strncpy(query, query_base, query_len); query_len -= STRLEN(query_base);