diff --git a/bin/xbps-bin/main.c b/bin/xbps-bin/main.c index 774f431528..543e4ef7e5 100644 --- a/bin/xbps-bin/main.c +++ b/bin/xbps-bin/main.c @@ -67,6 +67,8 @@ static int list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done) { const char *pkgname, *version, *short_desc; + (void)arg; + (void)*loop_done; assert(prop_object_type(obj) == PROP_TYPE_DICTIONARY); @@ -94,6 +96,8 @@ static int show_missing_dep_cb(prop_object_t obj, void *arg, bool *loop_done) { const char *pkgname, *version; + (void)arg; + (void)loop_done; prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); prop_dictionary_get_cstring_nocopy(obj, "version", &version); @@ -170,11 +174,14 @@ main(int argc, char **argv) if (strcasecmp(argv[0], "install") == 0) { rv = xbps_install_binary_pkg(argv[1], root, flags); if (rv != 0 && rv != EEXIST) { - dict = xbps_get_pkg_deps_dictionary(); - if (dict == NULL && errno == ENOENT) + if (rv == ENOENT) { printf("Unable to locate %s in " "repository pool.\n", argv[1]); - else if (dict && errno == ENOENT) + exit(EXIT_FAILURE); + } + + dict = xbps_get_pkg_deps_dictionary(); + if (dict && errno == ENOENT) show_missing_deps(dict, argv[1]); exit(EXIT_FAILURE); diff --git a/bin/xbps-repo/util.c b/bin/xbps-repo/util.c index a24fb9c01a..cafd7b6dfb 100644 --- a/bin/xbps-repo/util.c +++ b/bin/xbps-repo/util.c @@ -127,6 +127,9 @@ search_string_in_pkgs(prop_object_t obj, void *arg, bool *loop_done) const char *repofile; char *plist; + (void)arg; + (void)loop_done; + assert(prop_object_type(obj) == PROP_TYPE_STRING); /* Get the location of pkgindex file. */ @@ -244,6 +247,9 @@ show_pkg_namedesc(prop_object_t obj, void *arg, bool *loop_done) { const char *pkgname, *desc, *ver, *string = arg; + (void)arg; + (void)loop_done; + assert(prop_object_type(obj) == PROP_TYPE_DICTIONARY); assert(string != NULL); @@ -264,6 +270,8 @@ list_strings_in_array2(prop_object_t obj, void *arg, bool *loop_done) static uint16_t count; const char *sep; + (void)loop_done; + assert(prop_object_type(obj) == PROP_TYPE_STRING); if (arg == NULL) { @@ -286,6 +294,8 @@ list_strings_in_array2(prop_object_t obj, void *arg, bool *loop_done) int list_strings_in_array(prop_object_t obj, void *arg, bool *loop_done) { + (void)arg; + (void)loop_done; assert(prop_object_type(obj) == PROP_TYPE_STRING); printf("%s\n", prop_string_cstring_nocopy(obj)); diff --git a/include/install.h b/include/install.h index 9b943b56c7..3c214f6d57 100644 --- a/include/install.h +++ b/include/install.h @@ -27,7 +27,7 @@ #define _XBPS_INSTALL_H_ /* From lib/install.c, lib/depends.c and lib/unpack.c */ -int xbps_install_pkg_deps(prop_dictionary_t, const char *, int); +int xbps_install_pkg_deps(const char *, const char *, int); int xbps_install_binary_pkg(const char *, const char *, int); int xbps_install_binary_pkg_fini(prop_dictionary_t, prop_dictionary_t, const char *, int); diff --git a/lib/depends.c b/lib/depends.c index 80bd1b38e3..be44187309 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -591,15 +591,19 @@ find_pkg_deps_from_repo(prop_dictionary_t repo, prop_dictionary_t pkg, } int -xbps_install_pkg_deps(prop_dictionary_t pkg, const char *destdir, int flags) +xbps_install_pkg_deps(const char *pkgname, const char *destdir, int flags) { prop_array_t required, missing; prop_object_t obj; prop_object_iterator_t iter; int rv = 0; - assert(pkg != NULL); - + /* + * If origin object in chaindeps is not the same, bail out. + */ + obj = prop_dictionary_get(chaindeps, "origin"); + if (obj == NULL || !prop_string_equals_cstring(obj, pkgname)) + return EINVAL; /* * If there are missing deps, bail out. */ diff --git a/lib/install.c b/lib/install.c index 12500e0231..bb16117877 100644 --- a/lib/install.c +++ b/lib/install.c @@ -166,7 +166,7 @@ install_binpkg_repo_cb(prop_object_t obj, void *arg, bool *cbloop_done) /* * Install all required dependencies and the package itself. */ - if ((rv = xbps_install_pkg_deps(pkgrd, destdir, cb->flags)) == 0) { + if ((rv = xbps_install_pkg_deps(pkgname, destdir, cb->flags)) == 0) { rv = xbps_install_binary_pkg_fini(repod, pkgrd, destdir, cb->flags); prop_object_release(repod); diff --git a/lib/sha256.c b/lib/sha256.c index 07f3e1a7a6..78b4571177 100644 --- a/lib/sha256.c +++ b/lib/sha256.c @@ -104,7 +104,7 @@ /*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/ /* Hash constant words K for SHA-256: */ -const static sha2_word32 K256[64] = { +static const sha2_word32 K256[64] = { 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, @@ -124,7 +124,7 @@ const static sha2_word32 K256[64] = { }; /* Initial hash value H for SHA-256: */ -const static sha2_word32 sha256_initial_hash_value[8] = { +static const sha2_word32 sha256_initial_hash_value[8] = { 0x6a09e667UL, 0xbb67ae85UL, 0x3c6ef372UL, diff --git a/lib/sortdeps.c b/lib/sortdeps.c index c915dc9e0c..42cca621c7 100644 --- a/lib/sortdeps.c +++ b/lib/sortdeps.c @@ -128,7 +128,8 @@ xbps_sort_pkg_deps(prop_dictionary_t chaindeps) prop_object_iterator_t iter; struct sorted_dependency *sdep, *sdep2; uint32_t maxprio = 0; - size_t curidx = 0, indirdepscnt = 0, dirdepscnt = 0, cnt = 0; + size_t indirdepscnt = 0, dirdepscnt = 0, cnt = 0; + ssize_t curidx = 0; const char *curpkg, *rundep; char *pkgname; int rv = 0; diff --git a/vars.mk b/vars.mk index 7824af0be8..34fc2c9f4c 100644 --- a/vars.mk +++ b/vars.mk @@ -10,4 +10,4 @@ INSTALL_STRIPPED ?= -s LDFLAGS += -L$(TOPDIR)/lib -L$(PREFIX)/lib -lxbps CPPFLAGS += -I$(TOPDIR)/include CFLAGS += -Wstack-protector -fstack-protector-all -CFLAGS += -O2 -Wall -Werror -fPIC -DPIC +CFLAGS += -O2 -Wall -Wextra -Werror -fPIC -DPIC