diff --git a/lib/package_config_files.c b/lib/package_config_files.c index ba20df43..40273410 100644 --- a/lib/package_config_files.c +++ b/lib/package_config_files.c @@ -45,7 +45,7 @@ xbps_entry_is_a_conf_file(prop_dictionary_t propsd, assert(entry_pname != NULL); array = prop_dictionary_get(propsd, "conf_files"); - if (array == NULL || prop_array_count(array) == 0) + if (prop_array_count(array) == 0) return false; for (i = 0; i < prop_array_count(array); i++) { diff --git a/lib/package_conflicts.c b/lib/package_conflicts.c index 8153a016..05ad76fe 100644 --- a/lib/package_conflicts.c +++ b/lib/package_conflicts.c @@ -44,7 +44,7 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, char *pkgname, *repopkgname, *buf; pkg_cflicts = prop_dictionary_get(pkg_repod, "conflicts"); - if (pkg_cflicts == NULL || prop_array_count(pkg_cflicts) == 0) + if (prop_array_count(pkg_cflicts) == 0) return; trans_cflicts = prop_dictionary_get(xhp->transd, "conflicts"); diff --git a/lib/package_orphans.c b/lib/package_orphans.c index 56491154..446e7fe4 100644 --- a/lib/package_orphans.c +++ b/lib/package_orphans.c @@ -107,8 +107,7 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, prop_array_t orphans_user) prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver); reqby = xbps_pkgdb_get_pkg_revdeps(xhp, curpkgver); - cnt = prop_array_count(reqby); - if (reqby == NULL || (cnt == 0)) { + if (prop_array_count(reqby) == 0) { /* * Add packages with empty revdeps. */ @@ -124,8 +123,6 @@ find_orphans: prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver); rdeps = prop_dictionary_get(pkgd, "run_depends"); - if (rdeps == NULL) - continue; for (x = 0; x < prop_array_count(rdeps); x++) { cnt = 0; prop_array_get_cstring_nocopy(rdeps, x, &deppkgver); diff --git a/lib/package_remove.c b/lib/package_remove.c index 57877d65..b213e7f4 100644 --- a/lib/package_remove.c +++ b/lib/package_remove.c @@ -52,8 +52,7 @@ xbps_remove_pkg_files(struct xbps_handle *xhp, assert(key != NULL); array = prop_dictionary_get(dict, key); - if ((prop_object_type(array) != PROP_TYPE_ARRAY) || - prop_array_count(array) == 0) + if (prop_array_count(array) == 0) return 0; iter = xbps_array_iter_from_dict(dict, key); diff --git a/lib/package_unpack.c b/lib/package_unpack.c index 2563ad9e..57e40fdc 100644 --- a/lib/package_unpack.c +++ b/lib/package_unpack.c @@ -64,8 +64,6 @@ find_pkg_symlink_target(prop_dictionary_t d, const char *file) assert(d); links = prop_dictionary_get(d, "links"); - assert(links); - for (i = 0; i < prop_array_count(links); i++) { rfile = strchr(file, '.') + 1; obj = prop_array_get(links, i); @@ -96,16 +94,16 @@ create_pkg_metaplist(struct xbps_handle *xhp, const char *pkgname, const char *p /* Add objects from XBPS_PKGFILES */ array = prop_dictionary_get(filesd, "files"); - if (array && prop_array_count(array)) + if (prop_array_count(array)) prop_dictionary_set(pkg_metad, "files", array); array = prop_dictionary_get(filesd, "conf_files"); - if (array && prop_array_count(array)) + if (prop_array_count(array)) prop_dictionary_set(pkg_metad, "conf_files", array); array = prop_dictionary_get(filesd, "links"); - if (array && prop_array_count(array)) + if (prop_array_count(array)) prop_dictionary_set(pkg_metad, "links", array); array = prop_dictionary_get(filesd, "dirs"); - if (array && prop_array_count(array)) + if (prop_array_count(array)) prop_dictionary_set(pkg_metad, "dirs", array); /* Add install/remove scripts data objects */ diff --git a/lib/pkgdb.c b/lib/pkgdb.c index 29d2fd57..21a11b42 100644 --- a/lib/pkgdb.c +++ b/lib/pkgdb.c @@ -151,8 +151,6 @@ xbps_pkgdb_foreach_reverse_cb(struct xbps_handle *xhp, return rv; allkeys = prop_dictionary_all_keys(xhp->pkgdb); - assert(allkeys); - for (i = prop_array_count(allkeys); i > 0; i--) { obj = prop_array_get(allkeys, i); pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj); @@ -267,7 +265,7 @@ generate_full_revdeps_tree(struct xbps_handle *xhp) while ((obj = prop_object_iterator_next(iter))) { pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj); rundeps = prop_dictionary_get(pkgd, "run_depends"); - if (rundeps == NULL || !prop_array_count(rundeps)) + if (!prop_array_count(rundeps)) continue; for (i = 0; i < prop_array_count(rundeps); i++) { diff --git a/lib/plist.c b/lib/plist.c index 181b2eaa..ac00e3e1 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -120,9 +120,6 @@ xbps_callback_array_iter_in_dict(struct xbps_handle *xhp, assert(fn != NULL); array = prop_dictionary_get(dict, key); - if (prop_object_type(array) != PROP_TYPE_ARRAY) - return ENOENT; - for (i = 0; i < prop_array_count(array); i++) { obj = prop_array_get(array, i); if (obj == NULL) diff --git a/lib/repo.c b/lib/repo.c index 701fda97..1b29dcdb 100644 --- a/lib/repo.c +++ b/lib/repo.c @@ -226,7 +226,7 @@ revdeps_match(struct xbps_repo *repo, prop_dictionary_t tpkgd, const char *str) continue; pkgdeps = prop_dictionary_get(pkgd, "run_depends"); - if (pkgdeps == NULL || !prop_array_count(pkgdeps)) + if (!prop_array_count(pkgdeps)) continue; /* * Try to match passed in string. diff --git a/lib/repo_pkgdeps.c b/lib/repo_pkgdeps.c index ba08e93e..df17b530 100644 --- a/lib/repo_pkgdeps.c +++ b/lib/repo_pkgdeps.c @@ -392,9 +392,7 @@ xbps_repository_find_deps(struct xbps_handle *xhp, unsigned short depth = 0; pkg_rdeps = prop_dictionary_get(repo_pkgd, "run_depends"); - if (prop_object_type(pkg_rdeps) != PROP_TYPE_ARRAY) - return 0; - else if (prop_array_count(pkg_rdeps) == 0) + if (prop_array_count(pkg_rdeps) == 0) return 0; prop_dictionary_get_cstring_nocopy(repo_pkgd, "pkgver", &pkgver); diff --git a/lib/transaction_ops.c b/lib/transaction_ops.c index 8b9b351c..a9d6487f 100644 --- a/lib/transaction_ops.c +++ b/lib/transaction_ops.c @@ -355,11 +355,7 @@ xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp) int rv = 0; orphans = xbps_find_pkg_orphans(xhp, NULL); - if (prop_object_type(orphans) != PROP_TYPE_ARRAY) - return EINVAL; - - count = prop_array_count(orphans); - if (count == 0) { + if ((count = prop_array_count(orphans)) == 0) { /* no orphans? we are done */ rv = ENOENT; goto out; diff --git a/lib/transaction_sortdeps.c b/lib/transaction_sortdeps.c index bae7fd49..307a6542 100644 --- a/lib/transaction_sortdeps.c +++ b/lib/transaction_sortdeps.c @@ -344,7 +344,7 @@ xbps_transaction_sort(struct xbps_handle *xhp) * it doesn't matter. */ rundeps = prop_dictionary_get(obj, "run_depends"); - if (rundeps == NULL || prop_array_count(rundeps) == 0) { + if (prop_array_count(rundeps) == 0) { xbps_dbg_printf_append(xhp, "\n"); cnt++; continue; diff --git a/lib/util.c b/lib/util.c index 34cac402..f61c1ad5 100644 --- a/lib/util.c +++ b/lib/util.c @@ -215,8 +215,7 @@ xbps_pkg_has_rundeps(prop_dictionary_t pkgd) assert(prop_object_type(pkgd) == PROP_TYPE_DICTIONARY); array = prop_dictionary_get(pkgd, "run_depends"); - if ((prop_object_type(array) == PROP_TYPE_ARRAY) && - prop_array_count(array) > 0) + if (prop_array_count(array)) return true; return false;