diff options
author | 2010-10-11 17:29:55 +0200 | |
---|---|---|
committer | 2010-10-11 17:29:55 +0200 | |
commit | b063ce92559c2e91837214d5eeb82a7fa1a8c42a (patch) | |
tree | 6db214202a49ad254ff7f3a8c1bd2a9ababc178c | |
parent | Fix regex for grep 2.7 and later (bug #338414) (diff) | |
download | conf-update-b063ce92559c2e91837214d5eeb82a7fa1a8c42a.tar.gz conf-update-b063ce92559c2e91837214d5eeb82a7fa1a8c42a.tar.bz2 conf-update-b063ce92559c2e91837214d5eeb82a7fa1a8c42a.zip |
Fix compilation warnings
-rw-r--r-- | conf-update.c | 16 | ||||
-rw-r--r-- | core.c | 15 | ||||
-rw-r--r-- | core.h | 4 | ||||
-rw-r--r-- | index.c | 4 | ||||
-rw-r--r-- | modified.c | 14 | ||||
-rw-r--r-- | modified.h | 2 |
6 files changed, 33 insertions, 22 deletions
diff --git a/conf-update.c b/conf-update.c index 8afbe0f..5143500 100644 --- a/conf-update.c +++ b/conf-update.c @@ -3,8 +3,9 @@ int main(int argc, char **argv) { bool cont, menu_changed, firstrun, doit; bool *tmp_index; - char *config_protect, *config_protect_mask,*cmd, *myfile, *highest; - char *esc_highest, *esc_myfile; + char *config_protect = "", *config_protect_mask = ""; + char *cmd = "", *myfile = "", *highest = ""; + char *esc_highest = "", *esc_myfile = ""; char **result, **envvars, **protected, **masked, **md5_cache; char **md5sum_cache, **myupdate, **merged_updates_report = NULL; char **removed_updates_report = NULL; @@ -139,7 +140,6 @@ int main(int argc, char **argv) { strcat(cmd, " "); strcat(cmd, esc_highest); strcat(cmd, " | grep \"^[+-][^+-]\" | grep -v \"^[-+]#\" | grep -v \"^[-+][[:space:]]*$\""); - free(myfile); free(esc_myfile); free(esc_highest); @@ -271,7 +271,10 @@ int main(int argc, char **argv) { case KEY_ENTER: if (item_userptr(current_item(mymenu))) { endwin(); - show_diff(*((char **)item_userptr(current_item(mymenu)))); + int ret = show_diff(*((char **)item_userptr(current_item(mymenu)))); + if (!ret) { + fprintf(stderr, "show_diff failed with error code: %d\n", ret); + } reset_prog_mode(); } break; @@ -280,7 +283,10 @@ int main(int argc, char **argv) { case 'E': if (item_userptr(current_item(mymenu))) { endwin(); - edit_update(*((char **)item_userptr(current_item(mymenu)))); + int ret = edit_update(*((char **)item_userptr(current_item(mymenu)))); + if (!ret) { + fprintf(stderr, "edit_update failed with error code: %d\n", ret); + } reset_prog_mode(); } break; @@ -72,12 +72,14 @@ void merge(char *update, char **index) { free(real_file); } -void show_diff(char *update) { +int show_diff(char *update) { extern struct configuration config; char *realfile = get_real_filename(update); char *esc_realfile = g_shell_quote(realfile); char *esc_update = g_shell_quote(update); char *cmd = (char *)calloc(strlen(config.diff_tool) + strlen(" % % | ") + strlen(esc_update) + strlen(esc_realfile) + strlen(config.pager) + 1, sizeof(char)); + int ret; + strcpy(cmd, config.diff_tool); strcat(cmd, " "); strcat(cmd, esc_realfile); @@ -87,25 +89,28 @@ void show_diff(char *update) { strcat(cmd, " | "); strcat(cmd, config.pager); } + ret = system(cmd); free(realfile); g_free(esc_realfile); g_free(esc_update); - system(cmd); free(cmd); + return ret; } -void edit_update(char *update) { +int edit_update(char *update) { extern struct configuration config; char *esc_update = g_shell_quote(update); char *cmd = calloc(strlen(config.edit_tool) + strlen(" ") + strlen(esc_update), sizeof(char)); + int ret; strcpy(cmd, config.edit_tool); strcat(cmd, " "); strcat(cmd, esc_update); - system(cmd); + ret = system(cmd); g_free(esc_update); free(cmd); + return ret; } char **merge_interactively(char *update, char **index) { @@ -168,6 +173,6 @@ void display_help() { "\tSelecting a directory will select all its updates\n"; - fprintf(stderr, str); + fprintf(stderr, "%s", str); exit(EXIT_SUCCESS); } @@ -3,7 +3,7 @@ char *get_highest_update(char **index, char *update); bool is_last_entry(const char *entry); bool is_valid_entry(const char *entry); void merge(char *update, char **index); -void show_diff(char *update); -void edit_update(char *update); +int show_diff(char *update); +int edit_update(char *update); char **merge_interactively(char *update, char **index); void display_help(); @@ -50,9 +50,9 @@ void remove_menu(MENU *mymenu) { unpost_menu(mymenu); for (i=0;i<item_count(mymenu);i++) { - free(item_name(item_list[i])); + free((char *)item_name(item_list[i])); free_item(item_list[i]); } - free_menu(mymenu); free(item_list); + free_menu(mymenu); } @@ -6,7 +6,7 @@ bool user_modified(char *file) { char *filedump = NULL; size_t len = 0, len2 = 0; char *md5sum; - char filemd5[MD5_DIGEST_LENGTH]; + unsigned char filemd5[MD5_DIGEST_LENGTH]; char hexdigest[32]; bool user_mod = TRUE; if (access(MD5SUM_INDEX, R_OK) != 0) { @@ -20,7 +20,7 @@ bool user_modified(char *file) { filepipe = fopen(file, "r"); exit_error(filepipe, file); if (getdelim(&filedump, &len2, EOF, filepipe) != -1) { - MD5(filedump, strlen(filedump), filemd5); + MD5((unsigned char *)filedump, strlen(filedump), filemd5); md52hex(filemd5, hexdigest); if (!strncmp(md5sum, hexdigest, 32)) { user_mod = FALSE; @@ -36,7 +36,7 @@ bool user_modified(char *file) { } } -void md52hex(char *md5sum, char *hexdigest) { +void md52hex(unsigned char *md5sum, char *hexdigest) { // this one is stolen from python's md5module.c char c; int i, j = 0; @@ -56,11 +56,11 @@ void calc_md5(char *file, char* hexdigest) { char *dump = NULL; size_t len = 0; - char md5sum[MD5_DIGEST_LENGTH]; + unsigned char md5sum[MD5_DIGEST_LENGTH]; fp = fopen(file, "r"); if (getdelim(&dump, &len, EOF, fp) != -1) { - MD5(dump, strlen(dump), md5sum); + MD5((unsigned char *)dump, strlen(dump), md5sum); md52hex(md5sum, hexdigest); free(dump); } @@ -72,11 +72,11 @@ void md5sum_update(char *file, char *hexdigest) { char *dump = NULL; size_t len = 0; char *entry; + oldpipe = fopen(MD5SUM_INDEX, "r"); exit_error(oldpipe, MD5SUM_INDEX); - getdelim(&dump, &len, EOF, oldpipe); - if ((entry = strstr(dump, file))) { + if ((getdelim(&dump, &len, EOF, oldpipe) != -1) && (entry = strstr(dump, file))) { entry = strchr(entry, '\n') - 32; strncpy(entry, hexdigest, 32); exit_error(freopen(MD5SUM_INDEX, "w", oldpipe), MD5SUM_INDEX); @@ -1,5 +1,5 @@ bool user_modified(char *file); -void md52hex(char *md5sum, char *hexdigest); +void md52hex(unsigned char *md5sum, char *hexdigest); void calc_md5(char *file, char* hexdigest); void md5sum_update_file(char *file, char *hexdigest); void md5sum_update(char *file, char *hexdigest); |