diff options
-rw-r--r-- | src/actionhelper.c | 14 | ||||
-rw-r--r-- | src/actionparser.c | 12 | ||||
-rw-r--r-- | src/actions.c | 10 | ||||
-rw-r--r-- | src/ckerrlog.c | 4 | ||||
-rw-r--r-- | src/confparser.c | 10 | ||||
-rw-r--r-- | src/dblayer.c | 64 | ||||
-rw-r--r-- | unit/ck-test.c | 2 |
7 files changed, 58 insertions, 58 deletions
diff --git a/src/actionhelper.c b/src/actionhelper.c index 93b3107..6cc37bd 100644 --- a/src/actionhelper.c +++ b/src/actionhelper.c @@ -36,7 +36,7 @@ void link_config(const AddOpt *opt, const char* newPath) { } int move_config(const AddOpt *opt, char *progDir, char *ret) { - char newPath[STR_L]; + char newPath[STR_L] = ""; char *tmp = strdup(opt->confPath); str_join_dirname_with_basename(newPath, progDir, basename(tmp)); free(tmp); @@ -106,9 +106,9 @@ void get_or_make_program_dir(const AddOpt *opt, const Conf *conf, char *ret) { } void add_make_link(const AddOpt *opt, const Conf *conf) { - char progDir[STR_L]; + char progDir[STR_L] = ""; get_or_make_program_dir(opt, conf, progDir); - char newPath[STR_L]; + char newPath[STR_L] = ""; move_config(opt, progDir, newPath); if (add_err_message(NULL)) { return; @@ -130,13 +130,13 @@ void edit_print_suggested_configs(DB *db, const char *pName) { } int init_create_config_file(UserOpt *opt) { - char absVCdir[STR_L]; + char absVCdir[STR_L] = ""; if (!util_file_exists(list_get_at(opt->args, 0), absVCdir)) { ERR("Version control directory: %s does not exist.", list_get_at(opt->args, 0)); return 1; } - char absSRdir[STR_L]; + char absSRdir[STR_L] = ""; if (!util_file_exists(list_get_at(opt->args, 1), absSRdir)) { ERR("Secret directory: %s does not exist.", list_get_at(opt->args, 1)); return 1; @@ -146,14 +146,14 @@ int init_create_config_file(UserOpt *opt) { util_mkdir(opt->confDir); } - char confName[STR_L]; + char confName[STR_L] = ""; make_config_name(confName, opt->confDir); FILE *f; if ((f = fopen(confName, "w")) == NULL) { return 1; } - char tmp[200]; + char tmp[STR_L] = ""; strcpy(tmp, "version_control_dir = "); strcat(tmp, absVCdir); strcat(tmp, "\n"); diff --git a/src/actionparser.c b/src/actionparser.c index 1648372..5c6abf7 100644 --- a/src/actionparser.c +++ b/src/actionparser.c @@ -209,7 +209,7 @@ void determine_action(UserOpt *opt) { return; } - char actionName[STR_S]; + char actionName[STR_S] = ""; opt->action = parser_get_action(token, actionName); if (opt->action != CK_WRONG_ACTION) { LOG("Action to perform: %s", actionName); @@ -247,7 +247,7 @@ int get_config(UserOpt *opt) { ERR("Config needs a value"); return -1; } - char dir[STR_L]; + char dir[STR_L] = ""; realpath(token, dir); if (!util_is_dir(dir)) { ERR("%s is not a directory", token); @@ -314,7 +314,7 @@ void verbose() { } void get_possible_action_strings(char *dest, CkAction ckAction) { - char buf[STR_M]; + char buf[STR_M] = ""; switch (ckAction) { #define X(ACTION) \ case CKA_##ACTION: \ @@ -337,8 +337,8 @@ void get_possible_action_strings(char *dest, CkAction ckAction) { } void print_parser_error(UserOpt *opt) { - char errStr[STR_L]; - char names[STR_M]; + char errStr[STR_L] = ""; + char names[STR_M] = ""; get_possible_action_strings(names, opt->action); switch (opt->err) { @@ -375,7 +375,7 @@ void print_parser_error(UserOpt *opt) { } void print_parser_help() { - char names[STR_M]; + char names[STR_M] = ""; ckhelp("ck - the config keeper"); ckhelp("Usage:"); get_possible_action_strings(names, CKA_INIT); diff --git a/src/actions.c b/src/actions.c index 5a3befe..965ed5c 100644 --- a/src/actions.c +++ b/src/actions.c @@ -60,7 +60,7 @@ int run_ADD(UserOpt * opt, Conf *conf) { goto error; } add_make_link(&addOpt, conf); - char err[STR_M]; + char err[STR_M] = ""; if (add_err_message(err)) { PRINT_ERR(err); error: @@ -118,8 +118,8 @@ int run_EDIT(UserOpt *opt, Conf *conf) { } list_rewind(opt->args); - char confPath[STR_L]; - char confName[STR_M]; + char confPath[STR_L] = ""; + char confName[STR_M] = ""; int secret = 0; /* Since we are here, args have to be 1 or 2 */ char *pName = list_get(opt->args); @@ -159,7 +159,7 @@ int run_EDIT(UserOpt *opt, Conf *conf) { str_join_dirname_with_basename(confPath, secret ? conf->scrt_dir : conf->vc_dir, confName); char *editor = getenv("EDITOR"); - char command[STR_L]; + char command[STR_L] = ""; if (str_is_empty(editor)) { if (system("which nano > /dev/null 2>&1") != 0) { ERR("Nano not found. Please set $EDITOR to your desired editor."); @@ -293,7 +293,7 @@ int run_SEARCH(UserOpt *opt, Conf *conf) { int run_HELP(UserOpt *opt, Conf *conf) { UNUSED(conf); - char tmp[STR_M]; + char tmp[STR_M] = ""; if (strcmp(list_get(opt->args), "config") == 0) { print_conf_help(); return 0; diff --git a/src/ckerrlog.c b/src/ckerrlog.c index cfafb39..fe4c688 100644 --- a/src/ckerrlog.c +++ b/src/ckerrlog.c @@ -16,7 +16,7 @@ ERRLOG(logger); static int loglvl; -static char buf[STR_M]; +static char buf[STR_M] = ""; #define X(stream) static cklist *stream; CK_STREAMS @@ -44,7 +44,7 @@ void log_command(int argc,const char* argv[]) { void add_ ## stream ## _with_delim(const char *delim, \ const char *txt, \ va_list args) { \ - char tmp[STR_L]; \ + char tmp[STR_L] = ""; \ vsprintf(tmp, txt, args); \ if (stream) { \ list_add(stream, tmp); \ diff --git a/src/confparser.c b/src/confparser.c index 8547867..019cf14 100644 --- a/src/confparser.c +++ b/src/confparser.c @@ -24,7 +24,7 @@ void initialize_conf(Conf *c) { } int read_next_line(char *line, FILE *f) { - char nextLine[STR_L]; + char nextLine[STR_L] = ""; if (fgets(nextLine, STR_L, f) == NULL) { return -1; } @@ -46,7 +46,7 @@ ConfVar match_variables(char *line, char matched[]) { } void make_config_name(char * ret, const char *confPath) { - char tmp[STR_L]; + char tmp[STR_L] = ""; strcpy(tmp, confPath); strcat(tmp, CONFIG_NAME); @@ -56,9 +56,9 @@ void make_config_name(char * ret, const char *confPath) { int config_file_parse(Conf *conf, UserOpt *opt) { LOG("Using '%s' for ck configuration directory", opt->confDir); FILE *confPtr; - char confName[STR_L]; - char line[STR_L]; - char matched[STR_L]; + char confName[STR_L] = ""; + char line[STR_L] = ""; + char matched[STR_L] = ""; make_config_name(confName, opt->confDir); if ((confPtr = fopen(confName, "r")) == NULL) { 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); diff --git a/unit/ck-test.c b/unit/ck-test.c index 36b23d8..d7cf203 100644 --- a/unit/ck-test.c +++ b/unit/ck-test.c @@ -34,7 +34,7 @@ void ck_list_test() { void ck_str_utils_test() { /* make_ck_config_name */ - char ck_conf_path[STR_M]; + char ck_conf_path[STR_M] = ""; str_make_ck_config_name(ck_conf_path, "/test/path/.config", "emacs"); assert(strcmp(ck_conf_path, "emacs/.config") == 0); |