From 32f380fb86012c5dbc856d3c81acfde13f2803e8 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Sat, 25 Nov 2017 11:31:56 +0000 Subject: Hunting down all warnings --- cmd/cmd_lua.c | 19 ++++++++----------- cmd/cmd_todo.c | 27 ++++++++++++--------------- 2 files changed, 20 insertions(+), 26 deletions(-) (limited to 'cmd') diff --git a/cmd/cmd_lua.c b/cmd/cmd_lua.c index 820620f..2c850be 100644 --- a/cmd/cmd_lua.c +++ b/cmd/cmd_lua.c @@ -127,28 +127,27 @@ int lua_excute(const char *fname, rpc_call_request *req, rpc_call_response **res { int t; int top = lua_gettop(L); - int len = lua_rawlen(L,1); + //int len = lua_rawlen(L,1); if (top == 1) { t = lua_type(L,1); if (t == LUA_TTABLE) { - int j; - - const char *r_result; - const char *r_error; + + char *r_result; //this care unchangable stupid C dont know what is const + char *r_error; //this unchangable stupid C dont know what is const int r_id; size_t sz; - check_table_key_string(L, "result", &r_result, &sz); + check_table_key_string(L, "result", (const char **)&r_result, &sz); //printf("RESULT:%s\n", r_result); check_table_key_integer(L, "id", &r_id); //printf("ID:%d\n", r_id); - check_table_key_string(L, "error", &r_error, &sz); + check_table_key_string(L, "error", (const char **)&r_error, &sz); //printf("ERROR:%s\n", r_error); @@ -176,12 +175,10 @@ void *cmd_lua(void *data) char *ret = NULL; char *req_data = NULL; int fret; - int rc; - int i; int count; sds params = sdsempty(); - sds out_result = sdsempty(), out_lua = sdsempty(); + sds out_result = sdsempty(); sds *tokens; rpc_call_request *req = NULL; @@ -202,7 +199,7 @@ void *cmd_lua(void *data) //prepare request nb_req = malloc(sizeof(netbyte_store)); nb_init(nb_req); - nb_load(nb_req, req_data); + nb_load(nb_req, (unsigned char *)req_data); if (nb_req == NULL) { diff --git a/cmd/cmd_todo.c b/cmd/cmd_todo.c index 079866e..c1d9e4a 100644 --- a/cmd/cmd_todo.c +++ b/cmd/cmd_todo.c @@ -4,6 +4,8 @@ //https://www.google.nl/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&uact=8&ved=0ahUKEwiMu9_F5ZrXAhVLOMAKHZ6NDQYQFghDMAM&url=https%3A%2F%2Fopensource.apple.com%2Fsource%2FQuickTimeStreamingServer%2FQuickTimeStreamingServer-452%2FCommonUtilitiesLib%2Fbase64.c&usg=AOvVaw3tk0M33ne4ru28Bn_R1KI3 #define TODO_MAX_PER_USER 64 +#define TODO_MAX_DB_FILE_SIZE (1024*1024) +#define TODO_DB_NAME "todo.db" static int add_todo(sqlite3 *db, char *user, char *todo) { @@ -12,11 +14,11 @@ static int add_todo(sqlite3 *db, char *user, char *todo) char *b64_user, *b64_todo; sqlite3_stmt *res=NULL; - b64_user = b64_encode(user, strlen(user)); - b64_todo = b64_encode(todo, strlen(todo)); + b64_user = b64_encode((unsigned char *)user, strlen(user)); + b64_todo = b64_encode((unsigned char *)todo, strlen(todo)); //check how many todo stuff is for single user - snprintf(sql_add_table, 1024, "SELECT COUNT(*) FROM todo WHERE user='%s';", b64_user, b64_todo); + snprintf(sql_add_table, 1024, "SELECT COUNT(*) FROM todo WHERE user='%s';", b64_user); printf("%s\n", sql_add_table); if ((rc = sqlite3_prepare_v2(db, sql_add_table, -1, &res, 0)) != SQLITE_OK) { @@ -71,7 +73,7 @@ static int cb_list_todo_table(void *param1, int argc, char **argv, char **cname) *out = sdscat(*out, " - "); } else if (strncmp(cname[i],"todo",4) == 0) { - char *b64_todo = b64_decode(argv[i], strlen(argv[i])); + char *b64_todo = (char *)b64_decode(argv[i], strlen(argv[i])); *out = sdscat(*out, b64_todo); free(b64_todo); *out = sdscat(*out, "\n"); @@ -91,7 +93,7 @@ static int list_todo(sqlite3 *db, char *user, sds *out) char sql_list_table[1024]; char *b64_user; - b64_user = b64_encode(user, strlen(user)); + b64_user = b64_encode((unsigned char *)user, strlen(user)); snprintf(sql_list_table, 1024, "SELECT * FROM todo WHERE user='%s'", b64_user); printf("%s\n",sql_list_table); free(b64_user); @@ -111,7 +113,6 @@ static int list_todo(sqlite3 *db, char *user, sds *out) static int list_total(sqlite3 *db, sds *out) { int rc; - char *err_msg = NULL; sqlite3_stmt *res=NULL; char sql_list_total[1024]; @@ -128,7 +129,7 @@ static int list_total(sqlite3 *db, sds *out) rc = sqlite3_step(res); if (rc == SQLITE_ROW) { - const char *cret = sqlite3_column_text(res, 0); + const char *cret = (char *)sqlite3_column_text(res, 0); *out = sdscat(*out, cret); } sqlite3_finalize(res); @@ -144,21 +145,18 @@ static int del_todo(sqlite3 *db, char *user, int id) char sql_del_table[1024]; char *b64_user; - b64_user = b64_encode(user, strlen(user)); + b64_user = b64_encode((unsigned char *)user, strlen(user)); snprintf(sql_del_table, 1024, "DELETE FROM todo WHERE user='%s' AND id=%d;", b64_user, id); free(b64_user); - PRINT("%s\n",sql_del_table); if ((rc = sqlite3_exec(db, sql_del_table, 0, 0, &err_msg )) != SQLITE_OK) { printf("Cant del todo: %s\n", err_msg); sqlite3_free(err_msg); - PNL(); return -1; } - PNL(); return 0; } @@ -198,7 +196,7 @@ void *cmd_todo(void *data) //prepare request nb_req = malloc(sizeof(netbyte_store)); nb_init(nb_req); - nb_load(nb_req, req_data); + nb_load(nb_req, (unsigned char *)req_data); if (nb_req == NULL) { @@ -217,13 +215,13 @@ void *cmd_todo(void *data) //main code //check if database filesize is not bigger then 1MB, consider it for now as abuse woop woop - if (file_size("todo.db")>1024*1024) + if (file_size(TODO_DB_NAME)>TODO_MAX_DB_FILE_SIZE) { printf("File should be limited to just 1MB pal\n"); return ret; } - if ((rc = sqlite3_open("todo.db", &db)) != SQLITE_OK) + if ((rc = sqlite3_open(TODO_DB_NAME, &db)) != SQLITE_OK) { printf("Cannot open todo database: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); @@ -286,7 +284,6 @@ void *cmd_todo(void *data) if (count > 2) { int id = atoi(tokens[2]); - PRINT("%d\n",id); del_todo(db, req->user, id); } -- cgit v1.2.3