diff --git a/lib/download.c b/lib/download.c index 9098b9af..94e5ec3c 100644 --- a/lib/download.c +++ b/lib/download.c @@ -104,6 +104,9 @@ xbps_fetch_file(const char *uri, int fd = -1, rv = 0; bool restart = false; + assert(uri != NULL); + assert(outputdir != NULL); + fetchLastErrCode = 0; fetchTimeout = 30; /* 30 seconds of timeout */ diff --git a/lib/humanize_number.c b/lib/humanize_number.c index 0689215a..9b22d954 100644 --- a/lib/humanize_number.c +++ b/lib/humanize_number.c @@ -156,6 +156,8 @@ humanize_number(char *buf, size_t len, int64_t bytes, int xbps_humanize_number(char *buf, int64_t bytes) { + assert(buf != NULL); + return humanize_number(buf, 6, bytes, "B", HN_AUTOSCALE, HN_DECIMAL|HN_NOSPACE); } diff --git a/lib/package_config_files.c b/lib/package_config_files.c index 9902cb16..b22ba9aa 100644 --- a/lib/package_config_files.c +++ b/lib/package_config_files.c @@ -92,7 +92,9 @@ xbps_entry_install_conf_file(prop_dictionary_t filesd, assert(filesd != NULL); assert(entry != NULL); + assert(entry_pname != NULL); assert(pkgname != NULL); + assert(version != NULL); iter = xbps_get_array_iter_from_dict(filesd, "conf_files"); if (iter == NULL) diff --git a/lib/package_remove_obsoletes.c b/lib/package_remove_obsoletes.c index 298d6e39..8508a799 100644 --- a/lib/package_remove_obsoletes.c +++ b/lib/package_remove_obsoletes.c @@ -49,6 +49,9 @@ xbps_remove_obsoletes(prop_dictionary_t oldd, prop_dictionary_t newd) int rv = 0; bool found, dodirs = false, dolinks = false; + assert(oldd != NULL); + assert(newd != NULL); + again: iter = xbps_get_array_iter_from_dict(oldd, array_str); if (iter == NULL) diff --git a/lib/package_requiredby.c b/lib/package_requiredby.c index e2faceb8..6f3694df 100644 --- a/lib/package_requiredby.c +++ b/lib/package_requiredby.c @@ -129,6 +129,8 @@ xbps_requiredby_pkg_remove(const char *pkgname) char *plist; int rv = 0; + assert(pkgname != NULL); + plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, XBPS_REGPKGDB); if (plist == NULL) @@ -169,6 +171,9 @@ xbps_requiredby_pkg_add(prop_array_t regar, prop_dictionary_t pkg) char *rdepname; int rv = 0; + assert(regar != NULL); + assert(pkg != NULL); + prop_dictionary_get_cstring_nocopy(pkg, "pkgver", &pkgver); rdeps = prop_dictionary_get(pkg, "run_depends"); if (rdeps == NULL || prop_array_count(rdeps) == 0) diff --git a/lib/package_state.c b/lib/package_state.c index bbfd5413..cb90b3ad 100644 --- a/lib/package_state.c +++ b/lib/package_state.c @@ -59,6 +59,7 @@ set_new_state(prop_dictionary_t dict, pkg_state_t state) const struct state *stp; const char *pkgname; + assert(dict != NULL); for (stp = states; stp->string != NULL; stp++) if (state == stp->number) @@ -102,6 +103,7 @@ xbps_get_pkg_state_installed(const char *pkgname, pkg_state_t *state) prop_dictionary_t pkgd; assert(pkgname != NULL); + assert(state != NULL); pkgd = xbps_find_pkg_dict_installed(pkgname, false); if (pkgd == NULL) @@ -119,6 +121,7 @@ int xbps_get_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t *state) { assert(dict != NULL); + assert(state != NULL); if ((*state = get_state(dict)) == 0) return EINVAL; @@ -143,6 +146,8 @@ xbps_set_pkg_state_installed(const char *pkgname, pkg_state_t state) int rv = 0; bool newpkg = false; + assert(pkgname != NULL); + plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, XBPS_REGPKGDB); if (plist == NULL) diff --git a/lib/plist.c b/lib/plist.c index 7b8dd3cb..6f58e12c 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -200,6 +200,8 @@ xbps_find_pkg_dict_installed(const char *str, bool bypattern) prop_dictionary_t d, pkgd, rpkgd = NULL; pkg_state_t state = 0; + assert(str != NULL); + if ((d = xbps_regpkgdb_dictionary_get()) == NULL) return NULL; @@ -489,6 +491,8 @@ _xbps_uncompress_plist_data(char *xml, size_t len) ssize_t totalsize = 0; int rv = 0; + assert(xml != NULL); + /* Decompress the mmap'ed buffer with zlib */ strm.zalloc = Z_NULL; strm.zfree = Z_NULL; diff --git a/lib/repository_findpkg.c b/lib/repository_findpkg.c index 1029ff58..4c0ebfe3 100644 --- a/lib/repository_findpkg.c +++ b/lib/repository_findpkg.c @@ -59,6 +59,8 @@ set_pkg_state(prop_dictionary_t pkgd, const char *pkgname) pkg_state_t state = 0; int rv = 0; + assert(pkgd != NULL); + rv = xbps_set_pkg_state_dictionary(pkgd, XBPS_PKG_STATE_NOT_INSTALLED); if (rv != 0) return rv; diff --git a/lib/repository_plist.c b/lib/repository_plist.c index 82201c02..e9484b2b 100644 --- a/lib/repository_plist.c +++ b/lib/repository_plist.c @@ -152,6 +152,9 @@ xbps_repository_get_pkg_plist_dict_from_url(const char *url, const char *plistf) const char *curpath, *comptype; int i = 0; + assert(url != NULL); + assert(plistf != NULL); + if ((a = open_archive(url)) == NULL) return NULL; @@ -198,6 +201,9 @@ xbps_repository_get_pkg_plist_dict(const char *pkgname, const char *plistf) char *url; int rv = 0; + assert(pkgname != NULL); + assert(plistf != NULL); + if ((rv = xbps_repository_pool_init()) != 0) { errno = rv; return NULL; diff --git a/lib/repository_pool.c b/lib/repository_pool.c index b3a4e404..39731132 100644 --- a/lib/repository_pool.c +++ b/lib/repository_pool.c @@ -217,6 +217,8 @@ xbps_repository_pool_foreach( int rv = 0; bool done = false; + assert(fn != NULL); + if (!repolist_initialized) return EINVAL; diff --git a/lib/repository_sync_index.c b/lib/repository_sync_index.c index 0a253384..eb78c81b 100644 --- a/lib/repository_sync_index.c +++ b/lib/repository_sync_index.c @@ -95,6 +95,7 @@ xbps_repository_sync_pkg_index(const char *uri, int rv = 0; bool only_sync = false; + assert(uri != NULL); tmp_metafile = rpidx = lrepodir = lrepofile = NULL; if (uname(&un) == -1) diff --git a/lib/util.c b/lib/util.c index b4061c35..99d0b182 100644 --- a/lib/util.c +++ b/lib/util.c @@ -78,6 +78,8 @@ xbps_get_file_hash(const char *file) int fd; bool need_guard = false; + assert(file != NULL); + if ((fd = open(file, O_RDONLY)) == -1) { free(buf); return NULL; @@ -126,6 +128,9 @@ xbps_check_file_hash(const char *file, const char *sha256) { char *res; + assert(file != NULL); + assert(sha256 != NULL); + res = xbps_get_file_hash(file); if (res == NULL) return errno; @@ -342,6 +347,8 @@ get_pkg_index_remote_plist(const char *uri) { char *uri_fixed, *repodir; + assert(uri != NULL); + uri_fixed = xbps_get_remote_repo_string(uri); if (uri_fixed == NULL) return NULL; @@ -379,6 +386,9 @@ xbps_get_binpkg_repo_uri(prop_dictionary_t pkg_repod, const char *repoloc) const char *filen, *arch, *cdir; char *lbinpkg = NULL; + assert(pkg_repod != NULL); + assert(repoloc != NULL); + if (!prop_dictionary_get_cstring_nocopy(pkg_repod, "filename", &filen)) return NULL; @@ -413,6 +423,7 @@ xbps_pkg_has_rundeps(prop_dictionary_t pkg) prop_array_t array; assert(pkg != NULL); + array = prop_dictionary_get(pkg, "run_depends"); if (array && prop_array_count(array) > 0) return true;