Add clang-tidy target and fix problems
This commit is contained in:
parent
fca35ade9e
commit
f97b149376
25 changed files with 199 additions and 115 deletions
src/models
|
@ -1,3 +1,4 @@
|
|||
#include <bsd/string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sqlite3.h>
|
||||
|
@ -35,6 +36,8 @@ static controller_t*
|
|||
controller_db_select_mapper(sqlite3_stmt *stmt)
|
||||
{
|
||||
controller_t *new_controller = malloc(sizeof(controller_t));
|
||||
new_controller->id = 0;
|
||||
|
||||
for(int i = 0; i < sqlite3_column_count(stmt); i++)
|
||||
{
|
||||
const char *name = sqlite3_column_name(stmt, i);
|
||||
|
@ -50,14 +53,14 @@ controller_db_select_mapper(sqlite3_stmt *stmt)
|
|||
new_controller->id = sqlite3_column_int(stmt, i);
|
||||
break;
|
||||
case 'p': // ip
|
||||
strncpy(new_controller->ip, (const char*)sqlite3_column_text(stmt, i), 16);
|
||||
strlcpy(new_controller->ip, (const char*)sqlite3_column_text(stmt, i), sizeof(new_controller->ip));
|
||||
break;
|
||||
default: // ignore columns not implemented
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'n': // name
|
||||
strncpy(new_controller->name, (const char*)sqlite3_column_text(stmt, i), 127);
|
||||
strlcpy(new_controller->name, (const char*)sqlite3_column_text(stmt, i), sizeof(new_controller->name));
|
||||
break;
|
||||
case 'p': // port
|
||||
new_controller->port = sqlite3_column_int(stmt, i);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue