summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2018-07-11 00:39:41 +0000
committerJason Woodward2018-07-10 21:28:54 -0400
commit1542c7abc9165097c5fb25c18092c0f81d806a1f (patch)
tree0cae263068677e2b62220ff337639b37433591e6
parentd333df34001ac847d42c6df2a1e6ba5e31efa6cf (diff)
downloadslapt-get-1542c7abc9165097c5fb25c18092c0f81d806a1f.tar.gz
remove useless truth checks
-rw-r--r--src/action.c14
-rw-r--r--src/configuration.c2
-rw-r--r--src/curl.c2
-rw-r--r--src/gpgme.c12
-rw-r--r--src/main.c2
-rw-r--r--src/package.c50
-rw-r--r--src/transaction.c28
7 files changed, 55 insertions, 55 deletions
diff --git a/src/action.c b/src/action.c
index 9ff34b2..cb73df2 100644
--- a/src/action.c
+++ b/src/action.c
@@ -77,7 +77,7 @@ void slapt_pkg_action_install(const slapt_rc_config *global_config,
installed_pkg = slapt_get_newest_pkg(installed_pkgs, pkg->name);
/* if it is not already installed, install it */
- if (installed_pkg == NULL || global_config->no_upgrade == true) {
+ if (installed_pkg == NULL || global_config->no_upgrade) {
if (slapt_add_deps_to_trans(global_config, tran, avail_pkgs,
installed_pkgs, pkg) == 0) {
slapt_pkg_list_t *conflicts = slapt_is_conflicted(tran, avail_pkgs, installed_pkgs, pkg);
@@ -117,7 +117,7 @@ void slapt_pkg_action_install(const slapt_rc_config *global_config,
/* it is already installed, attempt an upgrade */
if (
((slapt_cmp_pkgs(installed_pkg, pkg)) < 0) ||
- (global_config->re_install == true)) {
+ (global_config->re_install)) {
if (slapt_add_deps_to_trans(global_config, tran, avail_pkgs,
installed_pkgs, pkg) == 0) {
slapt_pkg_list_t *conflicts = slapt_is_conflicted(tran, avail_pkgs,
@@ -291,7 +291,7 @@ void slapt_pkg_action_remove(const slapt_rc_config *global_config,
slapt_add_remove_to_transaction(tran, pkg);
}
- if (global_config->remove_obsolete == true) {
+ if (global_config->remove_obsolete) {
slapt_pkg_list_t *obsolete = slapt_get_obsolete_pkgs(global_config, avail_pkgs, installed_pkgs);
slapt_pkg_list_t_foreach(pkg, obsolete) {
@@ -478,7 +478,7 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
printf(gettext("Done\n"));
tran = slapt_init_transaction();
- if (global_config->dist_upgrade == true) {
+ if (global_config->dist_upgrade) {
char *essential[] = {"pkgtools", "glibc-solibs", "glibc", "aaa_elflibs", "xz", "sed", "tar", "gzip", NULL};
int epi = 0;
slapt_pkg_info_t *newest_slaptget = NULL;
@@ -627,13 +627,13 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
cmp_r = slapt_cmp_pkgs(installed_pkg, update_pkg);
if (
/* either it's greater, or we want to reinstall */
- cmp_r < 0 || (global_config->re_install == true) ||
+ cmp_r < 0 || (global_config->re_install) ||
/*
* or this is a dist upgrade and the versions are the save
* except for the arch
*/
(
- global_config->dist_upgrade == true &&
+ global_config->dist_upgrade &&
cmp_r == 0 &&
cmp_pkg_arch(installed_pkg->version,
update_pkg->version) != 0)) {
@@ -646,7 +646,7 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
if (
(slapt_add_deps_to_trans(global_config, tran, avail_pkgs,
installed_pkgs, update_pkg) == 0) &&
- (global_config->ignore_dep == true || (conflicts->pkg_count == 0))) {
+ (global_config->ignore_dep || (conflicts->pkg_count == 0))) {
if (cmp_r == 0)
slapt_add_reinstall_to_transaction(tran, installed_pkg, update_pkg);
else
diff --git a/src/configuration.c b/src/configuration.c
index 358a4ef..3d91ae0 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -404,7 +404,7 @@ int slapt_write_rc_config(const slapt_rc_config *global_config, const char *loca
SLAPT_PRIORITY_T priority = src->priority;
const char *token = SLAPT_SOURCE_TOKEN;
- if (src->disabled == true)
+ if (src->disabled)
token = SLAPT_DISABLED_SOURCE_TOKEN;
if (priority > SLAPT_PRIORITY_DEFAULT) {
diff --git a/src/curl.c b/src/curl.c
index 4bcba0d..9a74e20 100644
--- a/src/curl.c
+++ b/src/curl.c
@@ -245,7 +245,7 @@ const char *slapt_download_pkg(const slapt_rc_config *global_config,
pkg->mirror, pkg->name, pkg->version,
(dl_total_size > 1024) ? dl_total_size / 1024.0 : dl_total_size,
(dl_total_size > 1024) ? "MB" : "kB");
- if (global_config->dl_stats == true)
+ if (global_config->dl_stats)
printf("\n");
}
diff --git a/src/gpgme.c b/src/gpgme.c
index 563cc46..4823754 100644
--- a/src/gpgme.c
+++ b/src/gpgme.c
@@ -75,7 +75,7 @@ FILE *slapt_get_pkg_source_checksums_signature(const slapt_rc_config *global_con
checksum_head = slapt_head_mirror_data(url, location);
if (checksum_head == NULL) {
- if (interactive == true)
+ if (interactive)
printf(gettext("Not Found\n"));
free(filename);
free(local_head);
@@ -95,7 +95,7 @@ FILE *slapt_get_pkg_source_checksums_signature(const slapt_rc_config *global_con
} else {
const char *err = NULL;
- if (global_config->dl_stats == true)
+ if (global_config->dl_stats)
printf("\n");
if ((tmp_checksum_f = slapt_open_file(filename, "w+b")) == NULL)
@@ -105,7 +105,7 @@ FILE *slapt_get_pkg_source_checksums_signature(const slapt_rc_config *global_con
global_config, url,
location);
if (!err) {
- if (interactive == true)
+ if (interactive)
printf(gettext("Done\n"));
} else {
@@ -143,7 +143,7 @@ FILE *slapt_get_pkg_source_gpg_key(const slapt_rc_config *global_config,
char *key_head = NULL;
char *filename = slapt_gen_filename_from_url(url, SLAPT_GPG_KEY);
char *local_head = slapt_read_head_cache(filename);
- bool interactive = global_config->progress_cb == NULL && global_config->dl_stats == false
+ bool interactive = global_config->progress_cb == NULL && !global_config->dl_stats
? true
: false;
@@ -151,7 +151,7 @@ FILE *slapt_get_pkg_source_gpg_key(const slapt_rc_config *global_config,
key_head = slapt_head_mirror_data(url, SLAPT_GPG_KEY);
if (key_head == NULL) {
- if (interactive == true)
+ if (interactive)
printf(gettext("Not Found\n"));
free(filename);
free(local_head);
@@ -179,7 +179,7 @@ FILE *slapt_get_pkg_source_gpg_key(const slapt_rc_config *global_config,
SLAPT_GPG_KEY);
if (!err) {
- if (interactive == true)
+ if (interactive)
printf(gettext("Done\n"));
} else {
fprintf(stderr, gettext("Failed to download: %s\n"), err);
diff --git a/src/main.c b/src/main.c
index 3691504..d98f957 100644
--- a/src/main.c
+++ b/src/main.c
@@ -278,7 +278,7 @@ int main(int argc, char *argv[])
case INSTALL:
case INSTALL_DISK_SET:
case REMOVE:
- if (global_config->remove_obsolete == true)
+ if (global_config->remove_obsolete)
break;
/* fall through */
diff --git a/src/package.c b/src/package.c
index 14f87bd..4a384b7 100644
--- a/src/package.c
+++ b/src/package.c
@@ -851,7 +851,7 @@ void slapt_free_pkg(slapt_pkg_info_t *pkg)
void slapt_free_pkg_list(slapt_pkg_list_t *list)
{
- if (list->free_pkgs == true) {
+ if (list->free_pkgs) {
slapt_pkg_list_t_foreach(pkg, list) {
slapt_free_pkg(pkg);
}
@@ -865,7 +865,7 @@ bool slapt_is_excluded(const slapt_rc_config *global_config,
{
int name_reg_ret = -1, version_reg_ret = -1, location_reg_ret = -1;
- if (global_config->ignore_excludes == true)
+ if (global_config->ignore_excludes)
return false;
/* maybe EXCLUDE= isn't defined in our rc? */
@@ -985,7 +985,7 @@ int slapt_cmp_pkgs(slapt_pkg_info_t *a, slapt_pkg_info_t *b)
/* if either of the two packages is installed, we look
for the same version to bail out early if possible */
- if (a->installed == true || b->installed == true)
+ if (a->installed || b->installed)
if (strcasecmp(a->version, b->version) == 0)
return equal;
@@ -1288,7 +1288,7 @@ int slapt_get_pkg_dependencies(const slapt_rc_config *global_config,
* don't go any further if the required member is empty
* or disable_dep_check is set
*/
- if (global_config->disable_dep_check == true ||
+ if (global_config->disable_dep_check ||
strcmp(pkg->required, "") == 0 ||
strcmp(pkg->required, " ") == 0 ||
strcmp(pkg->required, " ") == 0)
@@ -1322,7 +1322,7 @@ int slapt_get_pkg_dependencies(const slapt_rc_config *global_config,
}
/* if this pkg is excluded */
- if ((slapt_is_excluded(global_config, tmp_pkg)) && (global_config->ignore_dep == false)) {
+ if ((slapt_is_excluded(global_config, tmp_pkg)) && !global_config->ignore_dep) {
if (slapt_get_exact_pkg(installed_pkgs, tmp_pkg->name, tmp_pkg->version) == NULL) {
slapt_add_pkg_err_to_list(conflict_err, pkg->name, tmp_pkg->name);
slapt_free_list(dep_parts);
@@ -1342,7 +1342,7 @@ int slapt_get_pkg_dependencies(const slapt_rc_config *global_config,
global_config, avail_pkgs, installed_pkgs, tmp_pkg,
deps, conflict_err, missing_err);
- if (dep_check_return == -1 && global_config->ignore_dep == false) {
+ if (dep_check_return == -1 && !global_config->ignore_dep) {
slapt_free_list(dep_parts);
return -1;
} else {
@@ -1642,7 +1642,7 @@ slapt_pkg_list_t *slapt_is_required_by(const slapt_rc_config *global_config,
/*
* don't go any further if disable_dep_check is set
*/
- if (global_config->disable_dep_check == true)
+ if (global_config->disable_dep_check)
return required_by_list;
required_by(avail, installed_pkgs, pkgs_to_install, pkgs_to_remove, pkg, required_by_list);
@@ -1768,7 +1768,7 @@ static void required_by(slapt_pkg_list_t *avail,
slapt_free_list(satisfies);
/* we couldn't find an installed pkg that satisfies the |or */
- if (has_alternative == false && found == true) {
+ if (!has_alternative && found) {
if (slapt_get_exact_pkg(required_by_list, avail_pkg->name, avail_pkg->version) == NULL) {
slapt_add_pkg_to_pkg_list(required_by_list, avail_pkg);
required_by(avail, installed_pkgs, pkgs_to_install, pkgs_to_remove, avail_pkg, required_by_list);
@@ -1865,7 +1865,7 @@ int slapt_update_pkg_cache(const slapt_rc_config *global_config)
const char *source_url = source->url;
SLAPT_PRIORITY_T source_priority = source->priority;
- if (source->disabled == true)
+ if (source->disabled)
continue;
/* download our SLAPT_PKG_LIST */
@@ -1907,7 +1907,7 @@ int slapt_update_pkg_cache(const slapt_rc_config *global_config)
printf("%s\n", gettext("Verified"));
} else if (verified == SLAPT_CHECKSUMS_MISSING_KEY) {
printf("%s\n", gettext("No key for verification"));
- } else if ((global_config->gpgme_allow_unauth == true) && (slapt_pkg_sign_is_unauthenticated(verified) == true)) {
+ } else if ((global_config->gpgme_allow_unauth) && (slapt_pkg_sign_is_unauthenticated(verified))) {
printf("%s%s\n", slapt_strerror(verified), gettext(", but accepted as an exception"));
} else {
printf("%s\n", gettext(slapt_strerror(verified)));
@@ -1972,7 +1972,7 @@ int slapt_update_pkg_cache(const slapt_rc_config *global_config)
}
/* set the priority of the package based on the source, plus 1 for the patch priority */
- if (global_config->use_priority == true)
+ if (global_config->use_priority)
patch_pkg->priority = source_priority + 1;
else
patch_pkg->priority = source_priority;
@@ -2198,7 +2198,7 @@ slapt_code_t slapt_verify_downloaded_pkg(const slapt_rc_config *global_config,
*/
/* if not checking the md5 checksum and the sizes match, assume its good */
- if (global_config->no_md5_check == true)
+ if (global_config->no_md5_check)
return SLAPT_OK;
/* check to see that we actually have an md5 checksum */
@@ -2318,7 +2318,7 @@ void slapt_purge_old_cached_pkgs(const slapt_rc_config *global_config,
free(tmp_pkg_version);
if (tmp_pkg == NULL) {
- if (global_config->no_prompt == true) {
+ if (global_config->no_prompt) {
unlink(file->d_name);
} else {
if (slapt_ask_yes_no(gettext("Delete %s ? [y/N]"), file->d_name) == 1)
@@ -2574,7 +2574,7 @@ slapt_pkg_list_t *slapt_get_pkg_source_packages(const slapt_rc_config *global_co
FILE *tmp_pkg_f = NULL;
const char *err = NULL;
- if (global_config->dl_stats == true)
+ if (global_config->dl_stats)
printf("\n");
if ((tmp_pkg_f = slapt_open_file(pkg_filename, "w+b")) == NULL)
@@ -2661,7 +2661,7 @@ slapt_pkg_list_t *slapt_get_pkg_source_packages(const slapt_rc_config *global_co
FILE *tmp_pkg_f = NULL;
const char *err = NULL;
- if (global_config->dl_stats == true)
+ if (global_config->dl_stats)
printf("\n");
if ((tmp_pkg_f = slapt_open_file(pkg_filename, "w+b")) == NULL)
@@ -2751,7 +2751,7 @@ slapt_pkg_list_t *slapt_get_pkg_source_patches(const slapt_rc_config *global_con
FILE *tmp_patch_f = NULL;
const char *err = NULL;
- if (global_config->dl_stats == true)
+ if (global_config->dl_stats)
printf("\n");
if ((tmp_patch_f = slapt_open_file(patch_filename, "w+b")) == NULL)
@@ -2787,7 +2787,7 @@ slapt_pkg_list_t *slapt_get_pkg_source_patches(const slapt_rc_config *global_con
slapt_clear_head_cache(patch_filename);
}
- if (global_config->dl_stats == true)
+ if (global_config->dl_stats)
printf("\n");
}
@@ -2822,7 +2822,7 @@ slapt_pkg_list_t *slapt_get_pkg_source_patches(const slapt_rc_config *global_con
FILE *tmp_patch_f = NULL;
const char *err = NULL;
- if (global_config->dl_stats == true)
+ if (global_config->dl_stats)
printf("\n");
if ((tmp_patch_f = slapt_open_file(patch_filename, "w+b")) == NULL)
@@ -2850,7 +2850,7 @@ slapt_pkg_list_t *slapt_get_pkg_source_patches(const slapt_rc_config *global_con
printf(gettext("Done\n"));
}
- if (global_config->dl_stats == true)
+ if (global_config->dl_stats)
printf("\n");
fclose(tmp_patch_f);
@@ -2890,7 +2890,7 @@ FILE *slapt_get_pkg_source_checksums(const slapt_rc_config *global_config,
FILE *working_checksum_f = NULL;
const char *err = NULL;
- if (global_config->dl_stats == true)
+ if (global_config->dl_stats)
printf("\n");
if ((working_checksum_f = slapt_open_file(filename, "w+b")) == NULL)
@@ -2900,7 +2900,7 @@ FILE *slapt_get_pkg_source_checksums(const slapt_rc_config *global_config,
global_config, url,
SLAPT_CHECKSUM_FILE_GZ);
if (!err) {
- if (global_config->dl_stats == true)
+ if (global_config->dl_stats)
printf("\n");
if (is_interactive)
printf(gettext("Done\n"));
@@ -2960,7 +2960,7 @@ FILE *slapt_get_pkg_source_checksums(const slapt_rc_config *global_config,
if ((tmp_checksum_f = slapt_open_file(filename, "w+b")) == NULL)
exit(EXIT_FAILURE);
- if (global_config->dl_stats == true)
+ if (global_config->dl_stats)
printf("\n");
err = slapt_get_mirror_data_from_source(tmp_checksum_f,
@@ -2987,7 +2987,7 @@ FILE *slapt_get_pkg_source_checksums(const slapt_rc_config *global_config,
if (checksum_head != NULL)
slapt_write_head_cache(checksum_head, filename);
- if (global_config->dl_stats == true)
+ if (global_config->dl_stats)
printf("\n");
}
@@ -3039,7 +3039,7 @@ int slapt_get_pkg_source_changelog(const slapt_rc_config *global_config,
FILE *working_changelog_f = NULL;
const char *err = NULL;
- if (global_config->dl_stats == true)
+ if (global_config->dl_stats)
printf("\n");
if ((working_changelog_f = slapt_open_file(filename, "w+b")) == NULL)
@@ -3049,7 +3049,7 @@ int slapt_get_pkg_source_changelog(const slapt_rc_config *global_config,
global_config, url,
location);
if (!err) {
- if (global_config->dl_stats == true)
+ if (global_config->dl_stats)
printf("\n");
if (is_interactive)
printf(gettext("Done\n"));
diff --git a/src/transaction.c b/src/transaction.c
index f4daec4..e1fc8b9 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -206,7 +206,7 @@ int slapt_handle_transaction(const slapt_rc_config *global_config,
uncompressed_size += u->size_u;
uncompressed_size -= p->size_u;
- if (upgrade->reinstall == true)
+ if (upgrade->reinstall)
continue;
if (line_len < MAX_LINE_LEN) {
@@ -230,7 +230,7 @@ int slapt_handle_transaction(const slapt_rc_config *global_config,
slapt_pkg_info_t *u = reinstall_upgrade->upgrade;
int line_len = len + strlen(u->name) + 1;
- if (reinstall_upgrade->reinstall == false)
+ if (!reinstall_upgrade->reinstall)
continue;
if (line_len < MAX_LINE_LEN) {
@@ -285,15 +285,15 @@ int slapt_handle_transaction(const slapt_rc_config *global_config,
}
/* check we have enough space to download to our working dir */
- if (slapt_disk_space_check(global_config->working_dir, need_to_download_size) == false) {
+ if (!slapt_disk_space_check(global_config->working_dir, need_to_download_size)) {
printf(
gettext("You don't have enough free space in %s\n"),
global_config->working_dir);
exit(EXIT_FAILURE);
}
/* check that we have enough space in the root filesystem */
- if (global_config->download_only == false) {
- if (slapt_disk_space_check("/", uncompressed_size) == false) {
+ if (!global_config->download_only) {
+ if (!slapt_disk_space_check("/", uncompressed_size)) {
printf(gettext("You don't have enough free space in %s\n"), "/");
exit(EXIT_FAILURE);
}
@@ -320,10 +320,10 @@ int slapt_handle_transaction(const slapt_rc_config *global_config,
}
/* prompt */
- if ((global_config->prompt == true) ||
+ if ((global_config->prompt) ||
((tran->upgrade_pkgs->pkg_count > 0 || tran->remove_pkgs->pkg_count > 0 ||
(tran->install_pkgs->pkg_count > 0 &&
- global_config->dist_upgrade == true)) &&
+ global_config->dist_upgrade)) &&
(global_config->no_prompt == false &&
global_config->download_only == false &&
global_config->simulate == false &&
@@ -334,7 +334,7 @@ int slapt_handle_transaction(const slapt_rc_config *global_config,
}
}
- if (global_config->print_uris == true) {
+ if (global_config->print_uris) {
slapt_pkg_list_t_foreach(info, tran->install_pkgs) {
const char *location = info->location + strspn(info->location, "./");
printf("%s%s/%s-%s%s\n",
@@ -352,7 +352,7 @@ int slapt_handle_transaction(const slapt_rc_config *global_config,
}
/* if simulate is requested, just show what could happen and return */
- if (global_config->simulate == true) {
+ if (global_config->simulate) {
slapt_pkg_list_t_foreach(r, tran->remove_pkgs) {
printf(gettext("%s-%s is to be removed\n"), r->name, r->version);
}
@@ -591,7 +591,7 @@ static void _slapt_add_upgrade_to_transaction(slapt_transaction_t *tran,
++tran->upgrade_pkgs->pkg_count;
- if (reinstall == true)
+ if (reinstall)
++tran->upgrade_pkgs->reinstall_count;
}
}
@@ -638,7 +638,7 @@ int slapt_search_upgrade_transaction(slapt_transaction_t *tran,
void slapt_free_transaction(slapt_transaction_t *tran)
{
- if (tran->install_pkgs->free_pkgs == true) {
+ if (tran->install_pkgs->free_pkgs) {
slapt_pkg_list_t_foreach(pkg, tran->install_pkgs) {
slapt_free_pkg(pkg);
}
@@ -646,7 +646,7 @@ void slapt_free_transaction(slapt_transaction_t *tran)
free(tran->install_pkgs->pkgs);
free(tran->install_pkgs);
- if (tran->remove_pkgs->free_pkgs == true) {
+ if (tran->remove_pkgs->free_pkgs) {
slapt_pkg_list_t_foreach(remove_pkg, tran->remove_pkgs) {
slapt_free_pkg(remove_pkg);
}
@@ -662,7 +662,7 @@ void slapt_free_transaction(slapt_transaction_t *tran)
free(tran->upgrade_pkgs->pkgs);
free(tran->upgrade_pkgs);
- if (tran->exclude_pkgs->free_pkgs == true) {
+ if (tran->exclude_pkgs->free_pkgs) {
slapt_pkg_list_t_foreach(exclude_pkg, tran->exclude_pkgs) {
slapt_free_pkg(exclude_pkg);
}
@@ -757,7 +757,7 @@ int slapt_add_deps_to_trans(const slapt_rc_config *global_config,
int dep_return = -1;
slapt_pkg_list_t *deps = NULL;
- if (global_config->disable_dep_check == true)
+ if (global_config->disable_dep_check)
return 0;
if (pkg == NULL)