xbps-bin/remove.c: simplify error paths.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20100125151604-jwhoavlbdhr645df
This commit is contained in:
Juan RP 2010-01-25 16:16:04 +01:00
parent bf6b96c651
commit dae134cd48

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2008-2009 Juan Romero Pardines. * Copyright (c) 2008-2010 Juan Romero Pardines.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -49,12 +49,11 @@ xbps_autoremove_pkgs(bool force)
* as dependency and any installed package does not depend * as dependency and any installed package does not depend
* on it currently. * on it currently.
*/ */
orphans = xbps_find_orphan_packages(); orphans = xbps_find_orphan_packages();
if (orphans == NULL) if (orphans == NULL)
return errno; return errno;
if (orphans != NULL && prop_array_count(orphans) == 0) { if (prop_array_count(orphans) == 0) {
printf("There are not orphaned packages currently.\n"); printf("There are not orphaned packages currently.\n");
goto out; goto out;
} }
@ -71,7 +70,7 @@ xbps_autoremove_pkgs(bool force)
if (!prop_dictionary_get_cstring_nocopy(obj, if (!prop_dictionary_get_cstring_nocopy(obj,
"pkgver", &pkgver)) { "pkgver", &pkgver)) {
rv = errno; rv = errno;
goto out2; goto out;
} }
cols += strlen(pkgver) + 4; cols += strlen(pkgver) + 4;
if (cols <= 80) { if (cols <= 80) {
@ -90,14 +89,14 @@ xbps_autoremove_pkgs(bool force)
if (!force && !xbps_noyes("Do you want to continue?")) { if (!force && !xbps_noyes("Do you want to continue?")) {
printf("Cancelled!\n"); printf("Cancelled!\n");
goto out2; goto out;
} }
while ((obj = prop_object_iterator_next(iter)) != NULL) { while ((obj = prop_object_iterator_next(iter)) != NULL) {
if (!prop_dictionary_get_cstring_nocopy(obj, if (!prop_dictionary_get_cstring_nocopy(obj,
"pkgname", &pkgname)) { "pkgname", &pkgname)) {
rv = errno; rv = errno;
goto out2; goto out;
} }
if (!prop_dictionary_get_cstring_nocopy(obj, if (!prop_dictionary_get_cstring_nocopy(obj,
"version", &version)) { "version", &version)) {
@ -106,12 +105,14 @@ xbps_autoremove_pkgs(bool force)
} }
printf("Removing package %s-%s ...\n", pkgname, version); printf("Removing package %s-%s ...\n", pkgname, version);
if ((rv = xbps_remove_pkg(pkgname, version, false, false)) != 0) if ((rv = xbps_remove_pkg(pkgname, version, false, false)) != 0)
goto out2; goto out;
} }
out2:
prop_object_iterator_release(iter);
out: out:
prop_object_release(orphans); if (iter)
prop_object_iterator_release(iter);
if (orphans)
prop_object_release(orphans);
return rv; return rv;
} }