Skip to content

Commit 6b9527f

Browse files
committed
bin/xbps-query: cleanup error returns
1 parent 9b4970f commit 6b9527f

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

bin/xbps-query/ownedby.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,17 @@ repo_match_cb(struct xbps_handle *xhp,
146146

147147
r = xbps_pkg_path_or_url(xhp, bfile, sizeof(bfile), obj);
148148
if (r < 0) {
149-
xbps_error_printf("could not get package path: %s\n", strerror(-r));
150-
return -r;
149+
return xbps_error_errno(
150+
r, "could not get package path: %s\n", strerror(-r));
151151
}
152+
errno = 0;
152153
filesd = xbps_archive_fetch_plist(bfile, "/files.plist");
153154
if (!filesd) {
154-
xbps_error_printf("%s: couldn't fetch files.plist from %s: %s\n",
155-
pkgver, bfile, strerror(errno));
156-
return EINVAL;
155+
if (errno == 0)
156+
errno = EINVAL;
157+
return xbps_error_errno(errno,
158+
"%s: couldn't fetch files.plist from %s: %s\n", pkgver,
159+
bfile, strerror(errno));
157160
}
158161
files_keys = xbps_dictionary_all_keys(filesd);
159162
for (unsigned int i = 0; i < xbps_array_count(files_keys); i++) {
@@ -175,7 +178,7 @@ repo_ownedby_cb(struct xbps_repo *repo, void *arg, bool *done UNUSED)
175178

176179
ffd->repouri = repo->uri;
177180
allkeys = xbps_dictionary_all_keys(repo->idx);
178-
rv = xbps_array_foreach_cb_multi(repo->xhp, allkeys, repo->idx, repo_match_cb, ffd);
181+
rv = -xbps_array_foreach_cb_multi(repo->xhp, allkeys, repo->idx, repo_match_cb, ffd);
179182
xbps_object_release(allkeys);
180183

181184
return rv;

bin/xbps-query/search.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ search_cb(struct xbps_handle *xhp UNUSED, xbps_object_t pkgd,
9696
abort();
9797

9898
if (!xbps_dictionary_get_cstring_nocopy(pkgd, "short_desc", &desc)) {
99-
xbps_error_printf("%s: missing short_desc property\n", pkgver);
100-
return -EINVAL;
99+
return xbps_error_errno(
100+
EINVAL, "%s: missing short_desc property\n", pkgver);
101101
}
102102

103103
if (ctx->repo_mode && xbps_match_virtual_pkg_in_dict(pkgd, ctx->pattern))

0 commit comments

Comments
 (0)