diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-11-13 15:12:31 +0200 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-11-13 15:12:31 +0200 |
commit | 5a96d39542d356fc3d102d52390a55d8cb6758d3 (patch) | |
tree | 0f9e6844e880759e5b5b20b6af683a0822de410c /src/dblayer.c | |
parent | 2415d22c7a82396daf21dabe6191531cfa21e6a3 (diff) | |
download | ck-5a96d39542d356fc3d102d52390a55d8cb6758d3.tar.gz ck-5a96d39542d356fc3d102d52390a55d8cb6758d3.tar.bz2 ck-5a96d39542d356fc3d102d52390a55d8cb6758d3.zip |
Leave no string uninitialized.
Diffstat (limited to 'src/dblayer.c')
-rw-r--r-- | src/dblayer.c | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/src/dblayer.c b/src/dblayer.c index 0e2ba5b..d3fd49e 100644 --- a/src/dblayer.c +++ b/src/dblayer.c @@ -21,7 +21,7 @@ const char * const DB_FILE_NAME = "/ckdb"; /* figure out the database name */ void make_db_name(char *ret, const char *confPath) { - char db_path[STR_L]; + char db_path[STR_L] = ""; strcpy(db_path, confPath); strcat(db_path, DB_FILE_NAME); @@ -30,14 +30,14 @@ void make_db_name(char *ret, const char *confPath) { /* Check if the db file exists*/ int db_exists(const UserOpt *opt) { - char db_path[STR_L]; + char db_path[STR_L] = ""; make_db_name(db_path, opt->confDir); return util_is_file_rw(db_path); } /* check if db has the correct tables */ int check_initialized_DB(sqlite3 *db) { - char sql[STR_M]; + char sql[STR_M] = ""; dbh_form_query_select_all_tables(sql); sqlite3_stmt *stmt; @@ -81,7 +81,7 @@ void close_DB(DB *db) { DB init_make_DB(const UserOpt *opt) { sqlite3 *db; - char db_path[STR_L]; + char db_path[STR_L] = ""; int rc; make_db_name(db_path, opt->confDir); @@ -96,7 +96,7 @@ DB init_make_DB(const UserOpt *opt) { DB open_DB(const UserOpt *opt) { sqlite3 *db; int rc; - char db_path[STR_L]; + char db_path[STR_L] = ""; make_db_name(db_path, opt->confDir); rc = sqlite3_open(db_path, &db); @@ -113,7 +113,7 @@ DB open_DB(const UserOpt *opt) { } void init_make_tables(DB *db) { - char sql[STR_L]; + char sql[STR_L] = ""; dbh_form_query_make_tables(sql); int rc = sqlite3_exec(db->ptr, sql, 0, 0, 0); @@ -128,7 +128,7 @@ int get_next_valid_id_from_table(DB *db, const char* tableName) { sqlite3_stmt *stmt; int rc; - char sql[STR_M]; + char sql[STR_M] = ""; dbh_form_query_select_id_from(sql, tableName); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); @@ -153,7 +153,7 @@ int insert_to_program_table(DB *db, const char *name) { sqlite3_stmt *stmt; int rc; - char sql[STR_L]; + char sql[STR_L] = ""; dbh_form_query_insert_program(sql); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); @@ -182,7 +182,7 @@ int insert_to_config_table(DB *db, const char *path, const int secret, const int sqlite3_stmt *stmt; int rc; - char sql[STR_L]; + char sql[STR_L] = ""; dbh_form_query_insert_config(sql); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); if (rc != SQLITE_OK) { @@ -212,7 +212,7 @@ int insert_to_rel_table(DB *db, const int pid, const int cid) { sqlite3_stmt *stmt; int rc; - char sql[STR_M]; + char sql[STR_M] = ""; dhb_form_query_insert_relationship(sql); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); if (rc != SQLITE_OK) { @@ -237,7 +237,7 @@ int get_program_id(DB *db, const char* name) { sqlite3_stmt *stmt; int rc; - char sql[STR_M]; + char sql[STR_M] = ""; dhb_form_query_find_program(sql); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); @@ -266,7 +266,7 @@ int get_config_id(DB *db, const char* path) { sqlite3_stmt *stmt; int rc; - char sql[STR_M]; + char sql[STR_M] = ""; dhb_form_query_find_config(sql); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); @@ -294,7 +294,7 @@ int program_has_primary_config(DB *db, const int pid, char *ret, int *sec) { sqlite3_stmt *stmt; int rc; - char sql[STR_L]; + char sql[STR_L] = ""; char condition[STR_S] = TBL_PROGRAM; strcat(condition, "."); @@ -332,7 +332,7 @@ int program_has_primary_config(DB *db, const int pid, char *ret, int *sec) { } int add_get_or_insert_config_to_db(DB *db, const int pid, const char *path, const int secret, const int prime, const char *home) { - char tpath[STR_L]; + char tpath[STR_L] = ""; if (!swap_home_with_tilde(tpath, path, home)) { strcpy(tpath, path); } @@ -420,7 +420,7 @@ int edit_get_prime_config_from_program(DB *db, char *pName, char *ret, int *secr /* program exists */ if (pid > -1) { - char path[STR_M]; + char path[STR_M] = ""; if (program_has_primary_config(db, pid, path, secret) == 1) { if (!str_is_empty(path)) { if (ret) { @@ -454,7 +454,7 @@ int edit_get_config(DB *db, const char *pName, char *ret, const char *cName, int strcat(condition, "."); strcat(condition, COL_PROGRAM_ID); - char sql[STR_L]; + char sql[STR_L] = ""; dbh_form_query_select_from_joined_eq(sql, selection, condition); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); @@ -465,7 +465,7 @@ int edit_get_config(DB *db, const char *pName, char *ret, const char *cName, int int flag = -1; while (sqlite3_step(stmt) == SQLITE_ROW) { - char confName[STR_M]; + char confName[STR_M] = ""; if (cName) { char *tmp = strdup((char *)sqlite3_column_text(stmt, 0)); if (strcmp(cName, basename(tmp)) == 0) { @@ -517,7 +517,7 @@ int get_program_paths(DB *db, cklist *ckl, const char* pName, int bname, int att strcat(condition, "."); strcat(condition, COL_PROGRAM_ID); - char sql[STR_L]; + char sql[STR_L] = ""; dbh_form_query_select_from_joined_eq(sql, selection, condition); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); @@ -568,7 +568,7 @@ int list_get_paths(DB *db, cklist *ckl, int bName, int attr, const char *home) { sqlite3_stmt *stmt; int rc; - char sql[STR_M]; + char sql[STR_M] = ""; dbh_form_query_select_paths_with_attributes(sql); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); @@ -617,7 +617,7 @@ int list_get_programs(DB *db, cklist *ckl) { sqlite3_stmt *stmt; int rc; - char sql[STR_M]; + char sql[STR_M] = ""; dbh_form_query_select_programs(sql); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); @@ -637,7 +637,7 @@ int list_get_path_program_tree(DB *db, cklist *ckl, int bName, int attr, const c sqlite3_stmt *stmt; int rc; - char sql[STR_M]; + char sql[STR_M] = ""; dbh_form_query_select_programs(sql); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); @@ -653,7 +653,7 @@ int list_get_path_program_tree(DB *db, cklist *ckl, int bName, int attr, const c sqlite3_stmt *stmt2; int rc2; - char sql2[STR_L]; + char sql2[STR_L] = ""; char selection[STR_M] = COL_CONFIG_PATH; strcat(selection, ","); @@ -716,7 +716,7 @@ int delete_prog(DB *db, int pid) { sqlite3_stmt *stmt; int rc; - char sql[STR_M]; + char sql[STR_M] = ""; dbh_form_query_delete_x_from_y(sql, COL_PROGRAM_ID, TBL_PROGRAM); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); @@ -737,7 +737,7 @@ int delete_conf(DB *db, int cid) { sqlite3_stmt *stmt; int rc; - char sql[STR_M]; + char sql[STR_M] = ""; dbh_form_query_delete_x_from_y(sql, COL_CONFIG_ID, TBL_CONFIG); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); @@ -759,7 +759,7 @@ int get_pid_from_cid(DB *db, int cid) { sqlite3_stmt *stmt; int rc; - char sql[STR_M]; + char sql[STR_M] = ""; dbh_form_query_get_pid_from_cid(sql); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); @@ -785,7 +785,7 @@ int get_program_relations(DB *db, int pid) { sqlite3_stmt *stmt; int rc; - char sql[STR_M]; + char sql[STR_M] = ""; dbh_form_query_count_program_relations(sql); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); @@ -823,7 +823,7 @@ int remove_conf_rel(DB *db, int cid) { int pid = get_pid_from_cid(db, cid); - char sql[STR_M]; + char sql[STR_M] = ""; dbh_form_query_delete_x_from_y(sql, COL_REL_CONFIG_ID, TBL_REL); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); if (rc != SQLITE_OK) { @@ -844,7 +844,7 @@ int remove_all_configs(DB *db, int pid) { sqlite3_stmt *stmt; int rc; - char sql[STR_M]; + char sql[STR_M] = ""; dbh_form_query_select_from_joined_eq(sql, COL_REL_CONFIG_ID, COL_REL_PROGRAM_ID); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); if (rc != SQLITE_OK) { @@ -944,7 +944,7 @@ int restore_program(DB *db, Conf *conf, const char *pName) { sqlite3_stmt *stmt; int rc; - char sql[STR_L]; + char sql[STR_L] = ""; char selection[STR_M] = COL_CONFIG_PATH; strcat(selection, ","); @@ -965,7 +965,7 @@ int restore_program(DB *db, Conf *conf, const char *pName) { int err_flag = 0; while (sqlite3_step(stmt) == SQLITE_ROW) { int secret = sqlite3_column_int(stmt, 1); - char filePath[STR_L]; + char filePath[STR_L] = ""; strcpy(filePath, secret ? conf->scrt_dir : conf->vc_dir); strcat(filePath, "/"); strcat(filePath, pName); @@ -984,7 +984,7 @@ int restore_configs_exists(DB *db, Conf *conf, const char *pName, cklist *from, sqlite3_stmt *stmt; int rc; - char sql[STR_L]; + char sql[STR_L] = ""; char selection[STR_M] = COL_CONFIG_PATH; strcat(selection, ","); @@ -1004,7 +1004,7 @@ int restore_configs_exists(DB *db, Conf *conf, const char *pName, cklist *from, sqlite3_bind_text(stmt, 1, pName, -1, 0); int err_flag = 0; while (sqlite3_step(stmt) == SQLITE_ROW) { - char filePath[STR_L]; + char filePath[STR_L] = ""; strcpy(filePath, /*secret*/ sqlite3_column_int(stmt, 1) ? conf->scrt_dir : conf->vc_dir); strcat(filePath, "/"); strcat(filePath, pName); |