lib: change xbps_dbg_printf to not require xbps_handle

This allows to simplify a lot of code by not having to pass around
the xbps handle everywhere just to print some debug information.
This commit is contained in:
Duncan Overbruck
2022-12-24 13:46:33 +01:00
parent 1a3d1ea56c
commit de484e9369
39 changed files with 288 additions and 300 deletions

View File

@@ -196,8 +196,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata UNUSED)
if (xscd->desc)
printf("%s\n", xscd->desc);
else
xbps_dbg_printf(xscd->xhp,
"%s: unknown state %d\n", xscd->arg, xscd->state);
xbps_dbg_printf("%s: unknown state %d\n", xscd->arg, xscd->state);
break;
}

View File

@@ -384,15 +384,15 @@ exec_transaction(struct xbps_handle *xhp, unsigned int maxcols, bool yes, bool d
goto proceed;
}
} else {
xbps_dbg_printf(xhp, "Empty transaction dictionary: %s\n",
xbps_dbg_printf("Empty transaction dictionary: %s\n",
strerror(errno));
}
goto out;
}
proceed:
#ifdef FULL_DEBUG
xbps_dbg_printf(xhp, "Dictionary before transaction happens:\n");
xbps_dbg_printf_append(xhp, "%s",
xbps_dbg_printf("Dictionary before transaction happens:\n");
xbps_dbg_printf_append("%s",
xbps_dictionary_externalize(xhp->transd));
#endif

View File

@@ -146,7 +146,7 @@ repo_match_cb(struct xbps_handle *xhp,
assert(bfile);
filesd = xbps_archive_fetch_plist(bfile, "/files.plist");
if (filesd == NULL) {
xbps_dbg_printf(xhp, "%s: couldn't fetch files.plist from %s: %s\n",
xbps_dbg_printf("%s: couldn't fetch files.plist from %s: %s\n",
pkgver, bfile, strerror(errno));
return EINVAL;
}

View File

@@ -296,7 +296,7 @@ cat_file(struct xbps_handle *xhp, const char *pkg, const char *file)
if (url == NULL)
return EINVAL;
xbps_dbg_printf(xhp, "matched pkg at %s\n", url);
xbps_dbg_printf("matched pkg at %s\n", url);
rv = xbps_archive_fetch_file_into_fd(url, file, STDOUT_FILENO);
free(url);
return rv;
@@ -317,7 +317,7 @@ repo_cat_file(struct xbps_handle *xhp, const char *pkg, const char *file)
if (url == NULL)
return EINVAL;
xbps_dbg_printf(xhp, "matched pkg at %s\n", url);
xbps_dbg_printf("matched pkg at %s\n", url);
rv = xbps_archive_fetch_file_into_fd(url, file, STDOUT_FILENO);
free(url);
return rv;

View File

@@ -88,7 +88,7 @@ cleaner_cb(struct xbps_handle *xhp, xbps_object_t obj,
}
if (strcmp(binpkgarch, xhp->target_arch ? xhp->target_arch : xhp->native_arch) != 0 &&
strcmp(binpkgarch, "noarch") != 0) {
xbps_dbg_printf(xhp, "%s: ignoring binpkg with unmatched arch\n", binpkg);
xbps_dbg_printf("%s: ignoring binpkg with unmatched arch\n", binpkg);
return 0;
}
@@ -150,7 +150,7 @@ clean_cachedir(struct xbps_handle *xhp, bool drun)
if ((ext = strrchr(dp->d_name, '.')) == NULL)
continue;
if (strcmp(ext, ".xbps")) {
xbps_dbg_printf(xhp, "ignoring unknown file: %s\n", dp->d_name);
xbps_dbg_printf("ignoring unknown file: %s\n", dp->d_name);
continue;
}
xbps_array_add_cstring(array, dp->d_name);

View File

@@ -46,7 +46,7 @@ struct CleanerCbInfo {
};
static int
idx_cleaner_cb(struct xbps_handle *xhp,
idx_cleaner_cb(struct xbps_handle *xhp UNUSED,
xbps_object_t obj,
const char *key UNUSED,
void *arg,
@@ -59,7 +59,7 @@ idx_cleaner_cb(struct xbps_handle *xhp,
xbps_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dbg_printf(xhp, "%s: checking %s [%s] ...\n", info->repourl, pkgver, arch);
xbps_dbg_printf("%s: checking %s [%s] ...\n", info->repourl, pkgver, arch);
filen = xbps_xasprintf("%s/%s.%s.xbps", info->repourl, pkgver, arch);
if (access(filen, R_OK) == -1) {