summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2019-07-13 18:11:52 +0000
committerJason Woodward2019-07-20 21:02:15 -0400
commitfac70fa8e5b5f26ff28049a7f3700adcb5c534c8 (patch)
treebb6728e7ddb739fa37ada0ca1adc08b6f9a62736
parent3d69cec327b0465c24e49fb2960eeac6a8ef8a4f (diff)
downloadslapt-get-fac70fa8e5b5f26ff28049a7f3700adcb5c534c8.tar.gz
small cleanups
-rw-r--r--src/package.c39
-rw-r--r--src/package.h2
-rw-r--r--src/slaptcurl.c2
-rw-r--r--src/slaptcurl.h2
-rw-r--r--src/slaptgpgme.c22
5 files changed, 34 insertions, 33 deletions
diff --git a/src/package.c b/src/package.c
index d374dbf..295b7a2 100644
--- a/src/package.c
+++ b/src/package.c
@@ -2275,6 +2275,7 @@ slapt_vector_t *slapt_get_pkg_source_packages(const slapt_rc_config *global_conf
free(pkg_filename);
free(pkg_local_head);
+ free(pkg_head);
return NULL;
}
@@ -2319,12 +2320,12 @@ slapt_vector_t *slapt_get_pkg_source_packages(const slapt_rc_config *global_conf
free(pkg_filename);
free(pkg_local_head);
+ free(pkg_head);
return NULL;
}
/* commit the head data for later comparisons */
- if (pkg_head != NULL)
- slapt_write_head_cache(pkg_head, pkg_filename);
+ slapt_write_head_cache(pkg_head, pkg_filename);
if (is_interactive)
printf(gettext("Done\n"));
@@ -2335,12 +2336,14 @@ slapt_vector_t *slapt_get_pkg_source_packages(const slapt_rc_config *global_conf
slapt_clear_head_cache(pkg_filename);
free(pkg_filename);
free(pkg_local_head);
+ free(pkg_head);
return NULL;
}
}
free(pkg_filename);
free(pkg_local_head);
+ free(pkg_head);
*compressed = 1;
} else { /* fall back to uncompressed package list */
@@ -2394,6 +2397,8 @@ slapt_vector_t *slapt_get_pkg_source_packages(const slapt_rc_config *global_conf
fclose(tmp_pkg_f);
free(pkg_filename);
free(pkg_local_head);
+ if (pkg_head != NULL)
+ free(pkg_head);
return NULL;
}
@@ -2410,6 +2415,8 @@ slapt_vector_t *slapt_get_pkg_source_packages(const slapt_rc_config *global_conf
free(pkg_filename);
free(pkg_local_head);
fclose(tmp_pkg_f);
+ if (pkg_head != NULL)
+ free(pkg_head);
return NULL;
}
@@ -2418,9 +2425,9 @@ slapt_vector_t *slapt_get_pkg_source_packages(const slapt_rc_config *global_conf
free(pkg_filename);
free(pkg_local_head);
+ if (pkg_head != NULL)
+ free(pkg_head);
}
- if (pkg_head != NULL)
- free(pkg_head);
return available_pkgs;
}
@@ -2494,6 +2501,7 @@ slapt_vector_t *slapt_get_pkg_source_patches(const slapt_rc_config *global_confi
free(patch_local_head);
free(patch_filename);
+ free(patch_head);
*compressed = 1;
} else {
@@ -2553,12 +2561,12 @@ slapt_vector_t *slapt_get_pkg_source_patches(const slapt_rc_config *global_confi
fclose(tmp_patch_f);
}
+ if (patch_head != NULL)
+ free(patch_head);
free(patch_local_head);
free(patch_filename);
}
- if (patch_head != NULL)
- free(patch_head);
return patch_pkgs;
}
@@ -2619,8 +2627,7 @@ FILE *slapt_get_pkg_source_checksums(const slapt_rc_config *global_config, const
free(filename);
free(local_head);
fclose(tmp_checksum_f);
- if (checksum_head != NULL)
- free(checksum_head);
+ free(checksum_head);
return NULL;
}
/* make sure we are back at the front of the file */
@@ -2629,6 +2636,7 @@ FILE *slapt_get_pkg_source_checksums(const slapt_rc_config *global_config, const
free(filename);
free(local_head);
+ free(checksum_head);
*compressed = 1;
} else {
@@ -2685,9 +2693,9 @@ FILE *slapt_get_pkg_source_checksums(const slapt_rc_config *global_config, const
free(filename);
free(local_head);
+ if (checksum_head != NULL)
+ free(checksum_head);
}
- if (checksum_head != NULL)
- free(checksum_head);
return tmp_checksum_f;
}
@@ -2762,16 +2770,13 @@ bool slapt_get_pkg_source_changelog(const slapt_rc_config *global_config, const
slapt_clear_head_cache(filename);
free(filename);
free(local_head);
- if (changelog_head != NULL)
- free(changelog_head);
+ free(changelog_head);
return false;
}
}
free(filename);
free(local_head);
-
- if (changelog_head != NULL)
- free(changelog_head);
+ free(changelog_head);
return true;
}
@@ -2805,8 +2810,10 @@ char *slapt_get_pkg_changelog(const slapt_pkg_info_t *pkg)
size_t pls = 1;
int changelog_len = 0;
- if ((working_changelog_f = fopen(filename, "rb")) == NULL)
+ if ((working_changelog_f = fopen(filename, "rb")) == NULL) {
+ free(filename);
return NULL;
+ }
/* used with mmap */
if (stat(filename, &stat_buf) == -1) {
diff --git a/src/package.h b/src/package.h
index 951ec00..e7191fe 100644
--- a/src/package.h
+++ b/src/package.h
@@ -132,8 +132,6 @@ char *slapt_gen_short_pkg_description(slapt_pkg_info_t *);
char *slapt_gen_filename_from_url(const char *url, const char *file);
/* generate the package file name, caller responsible for freeing the returned data */
char *slapt_gen_pkg_file_name(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg);
-/* generate the head cache filename, caller responsible for freeing the returned data */
-char *slapt_gen_head_cache_filename(const char *filename_from_url);
/* generate the download url for a package, caller responsible for freeing the returned data */
char *slapt_gen_pkg_url(slapt_pkg_info_t *pkg);
/* exclude pkg based on pkg name, returns 1 if package is present in the exclude list, 0 if not present */
diff --git a/src/slaptcurl.c b/src/slaptcurl.c
index bbbec0e..935efd4 100644
--- a/src/slaptcurl.c
+++ b/src/slaptcurl.c
@@ -459,7 +459,7 @@ char *slapt_head_mirror_data(const char *wurl, const char *file)
struct slapt_progress_data *slapt_init_progress_data(void)
{
- struct slapt_progress_data *d = malloc(sizeof *d);
+ struct slapt_progress_data *d = slapt_malloc(sizeof *d);
d->bytes = 0;
d->start = time(NULL);
return d;
diff --git a/src/slaptcurl.h b/src/slaptcurl.h
index 605424e..bc05c58 100644
--- a/src/slaptcurl.h
+++ b/src/slaptcurl.h
@@ -33,6 +33,8 @@ const char *slapt_download_pkg(const slapt_rc_config *global_config, slapt_pkg_i
/* this is the default progress callback if global_config->progress_cb == NULL */
int slapt_progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
+/* generate the head cache filename, caller responsible for freeing the returned data */
+char *slapt_gen_head_cache_filename(const char *filename_from_url);
/* do a head request on the mirror data to find out if it's new returns (char *) or NULL */
char *slapt_head_mirror_data(const char *wurl, const char *file);
/* clear head cache storage file */
diff --git a/src/slaptgpgme.c b/src/slaptgpgme.c
index 5907ce9..4f5ac09 100644
--- a/src/slaptgpgme.c
+++ b/src/slaptgpgme.c
@@ -82,7 +82,7 @@ FILE *slapt_get_pkg_source_checksums_signature(const slapt_rc_config *global_con
return NULL;
}
- if (checksum_head != NULL && local_head != NULL && strcmp(checksum_head, local_head) == 0) {
+ if (local_head != NULL && strcmp(checksum_head, local_head) == 0) {
if ((tmp_checksum_f = slapt_open_file(filename, "r")) == NULL)
exit(EXIT_FAILURE);
@@ -109,23 +109,20 @@ FILE *slapt_get_pkg_source_checksums_signature(const slapt_rc_config *global_con
fclose(tmp_checksum_f);
free(filename);
free(local_head);
- if (checksum_head != NULL)
- free(checksum_head);
+ free(checksum_head);
return NULL;
}
/* make sure we are back at the front of the file */
rewind(tmp_checksum_f);
/* if all is good, write it */
- if (checksum_head != NULL)
- slapt_write_head_cache(checksum_head, filename);
+ slapt_write_head_cache(checksum_head, filename);
}
free(filename);
free(local_head);
- if (checksum_head != NULL)
- free(checksum_head);
+ free(checksum_head);
return tmp_checksum_f;
}
@@ -151,7 +148,7 @@ FILE *slapt_get_pkg_source_gpg_key(const slapt_rc_config *global_config, const c
return NULL;
}
- if (key_head != NULL && local_head != NULL && strcmp(key_head, local_head) == 0) {
+ if (local_head != NULL && strcmp(key_head, local_head) == 0) {
if ((tmp_key_f = slapt_open_file(filename, "r")) == NULL)
exit(EXIT_FAILURE);
@@ -175,23 +172,20 @@ FILE *slapt_get_pkg_source_gpg_key(const slapt_rc_config *global_config, const c
fclose(tmp_key_f);
free(filename);
free(local_head);
- if (key_head != NULL)
- free(key_head);
+ free(key_head);
return NULL;
}
rewind(tmp_key_f);
/* if all is good, write it */
- if (key_head != NULL)
- slapt_write_head_cache(key_head, filename);
+ slapt_write_head_cache(key_head, filename);
}
free(filename);
free(local_head);
- if (key_head != NULL)
- free(key_head);
+ free(key_head);
return tmp_key_f;
}