Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/util/testdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/testdb.c')
-rw-r--r--src/util/testdb.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/src/util/testdb.c b/src/util/testdb.c
index 0436a23f..06c01f8d 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -31,9 +31,11 @@
#define BASENAME "testdb"
+pmhandle_t *handle = NULL;
+
static void cleanup(int signum) {
- if(alpm_release() == -1) {
- fprintf(stderr, "error releasing alpm: %s\n", alpm_strerrorlast());
+ if(handle && alpm_release(handle) == -1) {
+ fprintf(stderr, "error releasing alpm\n");
}
exit(signum);
@@ -63,10 +65,10 @@ static int check_localdb_files(void)
snprintf(path, sizeof(path), "%slocal", dbpath);
if(!(dir = opendir(path))) {
fprintf(stderr, "error : %s : %s\n", path, strerror(errno));
- return(1);
+ return 1;
}
- while ((ent = readdir(dir)) != NULL) {
+ while((ent = readdir(dir)) != NULL) {
if(strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0
|| ent->d_name[0] == '.') {
continue;
@@ -85,10 +87,10 @@ static int check_localdb_files(void)
}
if(closedir(dir)) {
fprintf(stderr, "error closing dbpath : %s\n", strerror(errno));
- return(1);
+ return 1;
}
- return(ret);
+ return ret;
}
static int checkdeps(alpm_list_t *pkglist)
@@ -107,7 +109,7 @@ static int checkdeps(alpm_list_t *pkglist)
ret++;
}
FREELIST(data);
- return(ret);
+ return ret;
}
static int checkconflicts(alpm_list_t *pkglist)
@@ -123,7 +125,7 @@ static int checkconflicts(alpm_list_t *pkglist)
ret++;
}
FREELIST(data);
- return(ret);
+ return ret;
}
static int check_localdb(void) {
@@ -133,7 +135,7 @@ static int check_localdb(void) {
ret = check_localdb_files();
if(ret) {
- return(ret);
+ return ret;
}
db = alpm_option_get_localdb();
@@ -145,7 +147,7 @@ static int check_localdb(void) {
pkglist = alpm_db_get_pkgcache(db);
ret += checkdeps(pkglist);
ret += checkconflicts(pkglist);
- return(ret);
+ return ret;
}
static int check_syncdbs(alpm_list_t *dbnames) {
@@ -169,7 +171,7 @@ static int check_syncdbs(alpm_list_t *dbnames) {
cleanup:
alpm_list_free(syncpkglist);
- return(ret);
+ return ret;
}
static void usage(void) {
@@ -184,7 +186,8 @@ static void usage(void) {
int main(int argc, char *argv[])
{
int ret = 0;
- char *dbpath = DBPATH;
+ enum _pmerrno_t err;
+ const char *dbpath = DBPATH;
int a = 1;
alpm_list_t *dbnames = NULL;
@@ -204,19 +207,15 @@ int main(int argc, char *argv[])
a++;
}
- if(alpm_initialize() == -1) {
- fprintf(stderr, "cannot initialize alpm: %s\n", alpm_strerrorlast());
- return(EXIT_FAILURE);
+ handle = alpm_initialize(ROOTDIR, dbpath, &err);
+ if(!handle) {
+ fprintf(stderr, "cannot initialize alpm: %s\n", alpm_strerror(err));
+ return EXIT_FAILURE;
}
/* let us get log messages from libalpm */
alpm_option_set_logcb(output_cb);
- if(alpm_option_set_dbpath(dbpath) != 0) {
- fprintf(stderr, "cannot set dbpath: %s\n", alpm_strerrorlast());
- return(EXIT_FAILURE);
- }
-
if(!dbnames) {
ret = check_localdb();
} else {