Skip to content

Commit 4086c36

Browse files
committed
lib,bin: xbps_pkgdb_lock already logs errors
avoid printing another less specific error message.
1 parent 290f2e7 commit 4086c36

File tree

6 files changed

+26
-18
lines changed

6 files changed

+26
-18
lines changed

bin/xbps-alternatives/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ main(int argc, char **argv)
351351

352352
/* in set mode pkgdb must be locked and flushed on success */
353353
if (xbps_pkgdb_lock(&xh) < 0) {
354-
xbps_error_printf("failed to lock pkgdb: %s\n", strerror(rv));
355354
xbps_end(&xh);
356355
exit(EXIT_FAILURE);
357356
}

bin/xbps-install/main.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,20 +238,24 @@ main(int argc, char **argv)
238238

239239
/* Sync remote repository data and import keys from remote repos */
240240
if (syncf && !drun) {
241-
if ((rv = xbps_rpool_sync(&xh, NULL)) != 0)
242-
exit(rv);
241+
if ((rv = xbps_rpool_sync(&xh, NULL)) != 0) {
242+
xbps_end(&xh);
243+
exit(EXIT_FAILURE);
244+
}
243245
rv = xbps_rpool_foreach(&xh, repo_import_key_cb, NULL);
244-
if (rv != 0)
245-
exit(rv);
246+
if (rv != 0) {
247+
xbps_end(&xh);
248+
exit(EXIT_FAILURE);
249+
}
246250
}
247251

248252
if (syncf && !update && (argc == optind))
249253
exit(EXIT_SUCCESS);
250254

251255
if (!(xh.flags & XBPS_FLAG_DOWNLOAD_ONLY) && !drun) {
252-
if ((rv = xbps_pkgdb_lock(&xh)) != 0) {
253-
xbps_error_printf("Failed to lock the pkgdb: %s\n", strerror(rv));
254-
exit(rv);
256+
if (xbps_pkgdb_lock(&xh) < 0) {
257+
xbps_end(&xh);
258+
exit(EXIT_FAILURE);
255259
}
256260
}
257261

bin/xbps-pkgdb/main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,11 @@ main(int argc, char **argv)
201201
exit(EXIT_FAILURE);
202202
}
203203

204-
if ((rv = xbps_pkgdb_lock(&xh)) != 0) {
205-
xbps_error_printf("failed to lock pkgdb: %s\n", strerror(rv));
204+
if (xbps_pkgdb_lock(&xh) < 0) {
205+
xbps_end(&xh);
206206
exit(EXIT_FAILURE);
207207
}
208+
208209
if (update_format) {
209210
/* nothing to do; xbps_pkgdb_lock() runs the conversion for us */
210211
goto out;

bin/xbps-reconfigure/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ main(int argc, char **argv)
178178
exit(EXIT_FAILURE);
179179
}
180180

181-
if ((rv = xbps_pkgdb_lock(&xh)) != 0) {
182-
xbps_error_printf("failed to lock pkgdb: %s\n", strerror(rv));
181+
if (xbps_pkgdb_lock(&xh) < 0) {
182+
xbps_end(&xh);
183183
exit(EXIT_FAILURE);
184184
}
185185

bin/xbps-remove/main.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,17 @@ main(int argc, char **argv)
267267

268268
if (clean_cache > 0) {
269269
rv = clean_cachedir(&xh, clean_cache > 1, drun);
270-
if (!orphans || rv)
271-
exit(rv);;
270+
if (rv) {
271+
xbps_end(&xh);
272+
exit(EXIT_FAILURE);
273+
}
274+
if (!orphans)
275+
exit(EXIT_SUCCESS);
272276
}
273277

274-
if (!drun && (rv = xbps_pkgdb_lock(&xh)) != 0) {
275-
xbps_error_printf("failed to lock pkgdb: %s\n", strerror(rv));
276-
exit(rv);
278+
if (!drun && xbps_pkgdb_lock(&xh) < 0) {
279+
xbps_end(&xh);
280+
exit(EXIT_FAILURE);
277281
}
278282

279283
if (orphans) {

lib/pkgdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ xbps_pkgdb_lock(struct xbps_handle *xhp)
7272

7373
if (access(xhp->rootdir, W_OK) == -1 && errno != ENOENT) {
7474
return xbps_error_errno(errno,
75-
"failed to check whether the rootdir is writable: "
75+
"failed to check whether the root directory is writable: "
7676
"%s: %s\n",
7777
xhp->rootdir, strerror(errno));
7878
}

0 commit comments

Comments
 (0)