Added LTO support and fix warnings (maybe-uninitialized).

This commit is contained in:
Juan RP
2019-06-27 17:09:43 +02:00
parent bb96486b12
commit 0677678387
32 changed files with 92 additions and 76 deletions

View File

@@ -1,5 +1,7 @@
-include ../config.mk
RANLIB ?= ranlib
LIBXBPS_MAJOR = 4
LIBXBPS_MINOR = 0
LIBXBPS_MICRO = 0
@@ -84,7 +86,7 @@ libxbps.a: $(LIBFETCH_OBJS) $(LIBPROP_OBJS) $(OBJS)
@printf " [AR]\t\t$@\n"
${SILENT}$(AR) rcs $@ $^
@printf " [RANLIB]\t$@\n"
${SILENT}ranlib $@
${SILENT}$(RANLIB) $@
.PHONY: install
install: all

View File

@@ -43,8 +43,8 @@
int
xbps_init(struct xbps_handle *xhp)
{
char *buf;
const char *repodir, *native_arch;
char *buf = NULL;
const char *repodir = NULL, *native_arch = NULL;
int rv = 0;
size_t size;

View File

@@ -232,7 +232,7 @@ xbps_alternatives_set(struct xbps_handle *xhp, const char *pkgname,
{
xbps_array_t allkeys;
xbps_dictionary_t alternatives, pkg_alternatives, pkgd, prevpkgd, prevpkg_alts;
const char *pkgver, *prevpkgname;
const char *pkgver = NULL, *prevpkgname = NULL;
int rv = 0;
assert(xhp);

View File

@@ -122,7 +122,7 @@ ordered_depends(struct xbps_handle *xhp, xbps_dictionary_t pkgd, bool rpool)
xbps_array_t rdeps, provides;
xbps_string_t str;
struct item *item, *xitem;
const char *pkgver;
const char *pkgver = NULL;
char *pkgn;
assert(xhp);
@@ -141,7 +141,7 @@ ordered_depends(struct xbps_handle *xhp, xbps_dictionary_t pkgd, bool rpool)
for (unsigned int i = 0; i < xbps_array_count(rdeps); i++) {
xbps_dictionary_t curpkgd;
const char *curdep;
const char *curdep = NULL;
char *curdepname;
xbps_array_get_cstring_nocopy(rdeps, i, &curdep);

View File

@@ -36,7 +36,7 @@ xbps_cb_message(struct xbps_handle *xhp, xbps_dictionary_t pkgd, const char *key
xbps_data_t msg;
FILE *f = NULL;
const void *data = NULL;
const char *pkgver;
const char *pkgver = NULL;
size_t len;
char *buf = NULL;
int rv = 0;

View File

@@ -66,7 +66,7 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user UNUSED)
xbps_dictionary_t pkgd, deppkgd;
xbps_object_t obj;
xbps_object_iterator_t iter;
const char *curpkgver, *deppkgver, *reqbydep;
const char *curpkgver = NULL, *deppkgver = NULL, *reqbydep = NULL;
bool automatic = false;
unsigned int i, cnt, reqbycnt;

View File

@@ -121,7 +121,7 @@ xbps_pkg_exec_script(struct xbps_handle *xhp,
xbps_data_t data;
void *buf;
size_t buflen;
const char *pkgver;
const char *pkgver = NULL;
int rv;
assert(xhp);

View File

@@ -159,8 +159,8 @@ pkgdb_map_vpkgs(struct xbps_handle *xhp)
while ((obj = xbps_object_iterator_next(iter))) {
xbps_array_t provides;
xbps_dictionary_t pkgd;
const char *pkgver;
char *pkgname;
const char *pkgver = NULL;
char *pkgname = NULL;
pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
provides = xbps_dictionary_get(pkgd, "provides");
@@ -172,7 +172,7 @@ pkgdb_map_vpkgs(struct xbps_handle *xhp)
assert(pkgname);
for (unsigned int i = 0; i < xbps_array_count(provides); i++) {
const char *vpkg;
const char *vpkg = NULL;
xbps_array_get_cstring_nocopy(provides, i, &vpkg);
if (!xbps_dictionary_set_cstring(xhp->vpkgd, vpkg, pkgname)) {
@@ -358,7 +358,7 @@ generate_full_revdeps_tree(struct xbps_handle *xhp)
while ((obj = xbps_object_iterator_next(iter))) {
xbps_array_t rundeps;
xbps_dictionary_t pkgd;
const char *pkgver;
const char *pkgver = NULL;
pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
rundeps = xbps_dictionary_get(pkgd, "run_depends");
@@ -368,7 +368,7 @@ generate_full_revdeps_tree(struct xbps_handle *xhp)
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
for (unsigned int i = 0; i < xbps_array_count(rundeps); i++) {
xbps_array_t pkg;
const char *pkgdep, *vpkgname;
const char *pkgdep = NULL, *vpkgname = NULL;
char *curpkgname;
bool alloc = false;
@@ -403,7 +403,7 @@ xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
{
xbps_array_t res;
xbps_dictionary_t pkgd;
const char *pkgver;
const char *pkgver = NULL;
char *pkgname;
if ((pkgd = xbps_pkgdb_get_pkg(xhp, pkg)) == NULL)
@@ -430,7 +430,7 @@ xbps_dictionary_t
xbps_pkgdb_get_pkg_files(struct xbps_handle *xhp, const char *pkg)
{
xbps_dictionary_t pkgd, pkgfilesd;
const char *pkgver;
const char *pkgver = NULL;
char *pkgname, *plist;
if (pkg == NULL)

View File

@@ -138,7 +138,7 @@ static xbps_dictionary_t
match_pkg_by_pkgver(xbps_dictionary_t repod, const char *p)
{
xbps_dictionary_t d = NULL;
const char *pkgver;
const char *pkgver = NULL;
char *pkgname;
/* exact match by pkgver */
@@ -162,8 +162,8 @@ static xbps_dictionary_t
match_pkg_by_pattern(xbps_dictionary_t repod, const char *p)
{
xbps_dictionary_t d = NULL;
const char *pkgver;
char *pkgname;
const char *pkgver = NULL;
char *pkgname = NULL;
/* match by pkgpattern in pkgver */
if ((pkgname = xbps_pkgpattern_name(p)) == NULL) {

View File

@@ -454,7 +454,7 @@ revdeps_match(struct xbps_repo *repo, xbps_dictionary_t tpkgd, const char *str)
xbps_array_t revdeps = NULL, pkgdeps, provides;
xbps_object_iterator_t iter;
xbps_object_t obj;
const char *pkgver, *tpkgver, *arch, *vpkg;
const char *pkgver = NULL, *tpkgver = NULL, *arch = NULL, *vpkg = NULL;
iter = xbps_dictionary_iterator(repo->idx);
assert(iter);

View File

@@ -60,7 +60,7 @@ static SIMPLEQ_HEAD(rpool_head, xbps_repo) rpool_queue =
int
xbps_rpool_sync(struct xbps_handle *xhp, const char *uri)
{
const char *repouri;
const char *repouri = NULL;
for (unsigned int i = 0; i < xbps_array_count(xhp->repositories); i++) {
xbps_array_get_cstring_nocopy(xhp->repositories, i, &repouri);
@@ -83,7 +83,7 @@ struct xbps_repo HIDDEN *
xbps_regget_repo(struct xbps_handle *xhp, const char *url)
{
struct xbps_repo *repo;
const char *repouri;
const char *repouri = NULL;
if (SIMPLEQ_EMPTY(&rpool_queue)) {
/* iterate until we have a match */
@@ -137,8 +137,8 @@ xbps_rpool_foreach(struct xbps_handle *xhp,
int (*fn)(struct xbps_repo *, void *, bool *),
void *arg)
{
struct xbps_repo *repo;
const char *repouri;
struct xbps_repo *repo = NULL;
const char *repouri = NULL;
int rv = 0;
bool foundrepo = false, done = false;
unsigned int n = 0;
@@ -204,7 +204,7 @@ find_pkg_revdeps_cb(struct xbps_repo *repo, void *arg, bool *done UNUSED)
{
struct rpool_fpkg *rpf = arg;
xbps_array_t revdeps = NULL;
const char *pkgver;
const char *pkgver = NULL;
revdeps = xbps_repo_get_pkg_revdeps(repo, rpf->pattern);
if (xbps_array_count(revdeps)) {
@@ -225,7 +225,7 @@ find_best_pkg_cb(struct xbps_repo *repo, void *arg, bool *done UNUSED)
{
struct rpool_fpkg *rpf = arg;
xbps_dictionary_t pkgd;
const char *repopkgver;
const char *repopkgver = NULL;
pkgd = xbps_repo_get_pkg(repo, rpf->pattern);
if (pkgd == NULL) {

View File

@@ -388,7 +388,7 @@ static int
collect_file(struct xbps_handle *xhp, const char *file, size_t size,
const char *pkgname, const char *pkgver, unsigned int idx,
const char *sha256, enum type type, bool update, bool preserve,
bool remove)
bool removefile)
{
struct item *item;
@@ -402,7 +402,7 @@ collect_file(struct xbps_handle *xhp, const char *file, size_t size,
goto add;
}
if (remove) {
if (removefile) {
if (item->old.type == 0) {
/*
* File wasn't removed before.
@@ -471,7 +471,7 @@ collect_file(struct xbps_handle *xhp, const char *file, size_t size,
return 0;
add:
if (remove) {
if (removefile) {
item->old.pkgname = strdup(pkgname);
item->old.pkgver = strdup(pkgver);
item->old.type = type;
@@ -496,7 +496,7 @@ add:
* and installed by another package.
*/
if (strcmp(item->new.pkgname, item->old.pkgname) != 0) {
if (remove) {
if (removefile) {
xbps_dbg_printf(xhp, "[files] %s: %s moved to"
" package `%s': %s\n", pkgver, typestr(item->old.type),
item->new.pkgver, file);
@@ -514,7 +514,7 @@ add:
static int
collect_files(struct xbps_handle *xhp, xbps_dictionary_t d,
const char *pkgname, const char *pkgver, unsigned int idx,
bool update, bool preserve, bool remove)
bool update, bool preserve, bool removefile)
{
xbps_array_t a;
xbps_dictionary_t filed;
@@ -528,12 +528,12 @@ collect_files(struct xbps_handle *xhp, xbps_dictionary_t d,
for (i = 0; i < xbps_array_count(a); i++) {
filed = xbps_array_get(a, i);
xbps_dictionary_get_cstring_nocopy(filed, "file", &file);
if (remove)
if (removefile)
xbps_dictionary_get_cstring_nocopy(filed, "sha256", &sha256);
size = 0;
xbps_dictionary_get_uint64(filed, "size", &size);
rv = collect_file(xhp, file, size, pkgname, pkgver, idx, sha256,
TYPE_FILE, update, preserve, remove);
TYPE_FILE, update, preserve, removefile);
if (rv == EEXIST) {
error = true;
continue;
@@ -548,7 +548,7 @@ collect_files(struct xbps_handle *xhp, xbps_dictionary_t d,
xbps_dictionary_get_cstring_nocopy(filed, "file", &file);
size = 0;
xbps_dictionary_get_uint64(filed, "size", &size);
if (remove)
if (removefile)
xbps_dictionary_get_cstring_nocopy(filed, "sha256", &sha256);
#if 0
/* XXX: how to handle conf_file size */
@@ -556,7 +556,7 @@ collect_files(struct xbps_handle *xhp, xbps_dictionary_t d,
size = 0;
#endif
rv = collect_file(xhp, file, size, pkgname, pkgver, idx, sha256,
TYPE_FILE, update, preserve, remove);
TYPE_FILE, update, preserve, removefile);
if (rv == EEXIST) {
error = true;
continue;
@@ -570,7 +570,7 @@ collect_files(struct xbps_handle *xhp, xbps_dictionary_t d,
filed = xbps_array_get(a, i);
xbps_dictionary_get_cstring_nocopy(filed, "file", &file);
rv = collect_file(xhp, file, 0, pkgname, pkgver, idx, NULL,
TYPE_LINK, update, preserve, remove);
TYPE_LINK, update, preserve, removefile);
if (rv == EEXIST) {
error = true;
continue;
@@ -584,7 +584,7 @@ collect_files(struct xbps_handle *xhp, xbps_dictionary_t d,
filed = xbps_array_get(a, i);
xbps_dictionary_get_cstring_nocopy(filed, "file", &file);
rv = collect_file(xhp, file, 0, pkgname, pkgver, idx, NULL,
TYPE_DIR, update, preserve, remove);
TYPE_DIR, update, preserve, removefile);
if (rv == EEXIST) {
error = true;
continue;

View File

@@ -257,7 +257,7 @@ xbps_autoupdate(struct xbps_handle *xhp)
/* a new xbps version is available, check its revdeps */
rdeps = xbps_pkgdb_get_pkg_revdeps(xhp, "xbps");
for (unsigned int i = 0; i < xbps_array_count(rdeps); i++) {
const char *curpkgver;
const char *curpkgver = NULL;
char *curpkgn;
xbps_array_get_cstring_nocopy(rdeps, i, &curpkgver);
@@ -361,7 +361,7 @@ xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkg)
rdeps = xbps_pkgdb_get_pkg_revdeps(xhp, pkg);
for (unsigned int i = 0; i < xbps_array_count(rdeps); i++) {
const char *curpkgver;
const char *curpkgver = NULL;
char *curpkgn;
xbps_array_get_cstring_nocopy(rdeps, i, &curpkgver);
@@ -400,7 +400,7 @@ xbps_transaction_install_pkg(struct xbps_handle *xhp, const char *pkg,
rdeps = xbps_pkgdb_get_pkg_revdeps(xhp, pkg);
for (unsigned int i = 0; i < xbps_array_count(rdeps); i++) {
const char *curpkgver;
const char *curpkgver = NULL;
char *curpkgn;
xbps_array_get_cstring_nocopy(rdeps, i, &curpkgver);

View File

@@ -321,7 +321,7 @@ xbps_transaction_prepare(struct xbps_handle *xhp)
}
/* ... remove dup edges at head */
for (i = 0; i < xbps_array_count(edges); i++) {
const char *pkgver;
const char *pkgver = NULL;
xbps_array_get_cstring_nocopy(edges, i, &pkgver);
xbps_remove_pkg_from_array_by_pkgver(pkgs, pkgver);
}

View File

@@ -151,7 +151,7 @@ xbps_transaction_revdeps(struct xbps_handle *xhp, xbps_array_t pkgs)
for (unsigned int x = 0; x < xbps_array_count(pkgrdeps); x++) {
xbps_array_t rundeps;
xbps_dictionary_t revpkgd;
const char *curpkgver, *revpkgver, *curdep, *curtract;
const char *curpkgver = NULL, *revpkgver, *curdep = NULL, *curtract;
char *curpkgname, *curdepname;
bool found = false;

View File

@@ -120,7 +120,7 @@ collect_shlibs(struct xbps_handle *xhp, xbps_array_t pkgs, bool req)
continue;
for (unsigned int i = 0; i < xbps_array_count(shobjs); i++) {
const char *shlib;
const char *shlib = NULL;
xbps_array_get_cstring_nocopy(shobjs, i, &shlib);
xbps_dbg_printf(xhp, "%s: registering %s for %s\n",
@@ -153,7 +153,7 @@ xbps_transaction_shlibs(struct xbps_handle *xhp, xbps_array_t pkgs, xbps_array_t
while ((obj = xbps_object_iterator_next(iter))) {
xbps_array_t array;
const char *pkgver, *shlib;
const char *pkgver = NULL, *shlib = NULL;
char *buf;
shlib = xbps_dictionary_keysym_cstring_nocopy(obj);

View File

@@ -411,6 +411,9 @@ xbps_xasprintf(const char *fmt, ...)
int
xbps_pkgpattern_match(const char *pkg, const char *pattern)
{
assert(pkg);
assert(pattern);
/* simple match on "pkg" against "pattern" */
if (strcmp(pattern, pkg) == 0)
return 1;
@@ -462,7 +465,7 @@ xbps_pkg_reverts(xbps_dictionary_t pkg, const char *pkgver)
unsigned int i;
xbps_array_t reverts;
const char *version = xbps_pkg_version(pkgver);
const char *revertver;
const char *revertver = NULL;
if ((reverts = xbps_dictionary_get(pkg, "reverts")) == NULL)
return false;