summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/cleanupdelta.c2
-rw-r--r--src/util/pactree.c30
-rw-r--r--src/util/testdb.c2
-rw-r--r--src/util/testpkg.c5
4 files changed, 16 insertions, 23 deletions
diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c
index 5112b1a8..98291706 100644
--- a/src/util/cleanupdelta.c
+++ b/src/util/cleanupdelta.c
@@ -78,7 +78,7 @@ static void checkdbs(const char *dbpath, alpm_list_t *dbnames) {
db = alpm_db_register_sync(handle, dbname);
if(db == NULL) {
fprintf(stderr, "error: could not register sync database (%s)\n",
- alpm_strerrorlast());
+ alpm_strerror(alpm_errno(handle)));
return;
}
checkpkgs(alpm_db_get_pkgcache(db));
diff --git a/src/util/pactree.c b/src/util/pactree.c
index 6c869426..1dee61bf 100644
--- a/src/util/pactree.c
+++ b/src/util/pactree.c
@@ -88,19 +88,6 @@ int reverse = 0;
int unique = 0;
const char *dbpath = DBPATH;
-static int alpm_local_init(void)
-{
- enum _pmerrno_t err;
-
- handle = alpm_initialize(ROOTDIR, dbpath, &err);
- if(!handle) {
- return -1;
- }
-
- db_local = alpm_option_get_localdb(handle);
- return 0;
-}
-
static int parse_options(int argc, char *argv[])
{
int opt, option_index = 0;
@@ -327,22 +314,27 @@ static void walk_deps(pmpkg_t *pkg, int depth)
int main(int argc, char *argv[])
{
- int ret;
+ int ret = 0;
+ enum _pmerrno_t err;
const char *target_name;
pmpkg_t *pkg;
- ret = parse_options(argc, argv);
- if(ret != 0) {
+ if(parse_options(argc, argv) != 0) {
usage();
+ ret = 1;
goto finish;
}
- ret = alpm_local_init();
- if(ret != 0) {
- fprintf(stderr, "error: cannot initialize alpm: %s\n", alpm_strerrorlast());
+ handle = alpm_initialize(ROOTDIR, dbpath, &err);
+ if(!handle) {
+ fprintf(stderr, "error: cannot initialize alpm: %s\n",
+ alpm_strerror(err));
+ ret = 1;
goto finish;
}
+ db_local = alpm_option_get_localdb(handle);
+
/* we only care about the first non option arg for walking */
target_name = argv[optind];
diff --git a/src/util/testdb.c b/src/util/testdb.c
index bda67d52..0bd78202 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -155,7 +155,7 @@ static int check_syncdbs(alpm_list_t *dbnames) {
db = alpm_db_register_sync(handle, dbname);
if(db == NULL) {
fprintf(stderr, "error: could not register sync database (%s)\n",
- alpm_strerrorlast());
+ alpm_strerror(alpm_errno(handle)));
ret = 1;
goto cleanup;
}
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index 5b8831de..c6f02e34 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -60,7 +60,8 @@ int main(int argc, char *argv[])
if(alpm_pkg_load(handle, argv[1], 1, PM_PGP_VERIFY_OPTIONAL, &pkg) == -1
|| pkg == NULL) {
- switch(pm_errno) {
+ enum _pmerrno_t err = alpm_errno(handle);
+ switch(err) {
case PM_ERR_PKG_OPEN:
printf("Cannot open the given file.\n");
break;
@@ -69,7 +70,7 @@ int main(int argc, char *argv[])
printf("Package is invalid.\n");
break;
default:
- printf("libalpm error: %s\n", alpm_strerrorlast());
+ printf("libalpm error: %s\n", alpm_strerror(err));
break;
}
retval = 1;