The enum alpm_pkgvalidation_t is essentially a more generic version
of _alpm_csum, so use it instead.

Signed-off-by: Allan McRae <al...@archlinux.org>
---
 lib/libalpm/be_package.c |    4 ++--
 lib/libalpm/package.c    |    2 +-
 lib/libalpm/sync.c       |    2 +-
 lib/libalpm/util.c       |    6 +++---
 lib/libalpm/util.h       |    7 +------
 5 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 0a8bbf3..fc4a05b 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -338,7 +338,7 @@ int _alpm_pkg_validate_internal(alpm_handle_t *handle,
                if(syncpkg->md5sum && !syncpkg->sha256sum) {
                        _alpm_log(handle, ALPM_LOG_DEBUG, "md5sum: %s\n", 
syncpkg->md5sum);
                        _alpm_log(handle, ALPM_LOG_DEBUG, "checking md5sum for 
%s\n", pkgfile);
-                       if(_alpm_test_checksum(pkgfile, syncpkg->md5sum, 
ALPM_CSUM_MD5) != 0) {
+                       if(_alpm_test_checksum(pkgfile, syncpkg->md5sum, 
ALPM_PKG_VALIDATION_MD5SUM) != 0) {
                                RET_ERR(handle, ALPM_ERR_PKG_INVALID_CHECKSUM, 
-1);
                        }
                        syncpkg->validation |= ALPM_PKG_VALIDATION_MD5SUM;
@@ -347,7 +347,7 @@ int _alpm_pkg_validate_internal(alpm_handle_t *handle,
                if(syncpkg->sha256sum) {
                        _alpm_log(handle, ALPM_LOG_DEBUG, "sha256sum: %s\n", 
syncpkg->sha256sum);
                        _alpm_log(handle, ALPM_LOG_DEBUG, "checking sha256sum 
for %s\n", pkgfile);
-                       if(_alpm_test_checksum(pkgfile, syncpkg->sha256sum, 
ALPM_CSUM_SHA256) != 0) {
+                       if(_alpm_test_checksum(pkgfile, syncpkg->sha256sum, 
ALPM_PKG_VALIDATION_SHA256SUM) != 0) {
                                RET_ERR(handle, ALPM_ERR_PKG_INVALID_CHECKSUM, 
-1);
                        }
                        syncpkg->validation |= ALPM_PKG_VALIDATION_SHA256SUM;
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 5abfd72..e881a51 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -67,7 +67,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
 
        fpath = _alpm_filecache_find(pkg->handle, pkg->filename);
 
-       retval = _alpm_test_checksum(fpath, pkg->md5sum, ALPM_CSUM_MD5);
+       retval = _alpm_test_checksum(fpath, pkg->md5sum, 
ALPM_PKG_VALIDATION_MD5SUM);
 
        if(retval == 0) {
                return 0;
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 68630c1..f41ecfa 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -780,7 +780,7 @@ static int validate_deltas(alpm_handle_t *handle, 
alpm_list_t *deltas)
                alpm_delta_t *d = i->data;
                char *filepath = _alpm_filecache_find(handle, d->delta);
 
-               if(_alpm_test_checksum(filepath, d->delta_md5, ALPM_CSUM_MD5)) {
+               if(_alpm_test_checksum(filepath, d->delta_md5, 
ALPM_PKG_VALIDATION_MD5SUM)) {
                        errors = alpm_list_add(errors, filepath);
                } else {
                        FREE(filepath);
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 5986124..5cb75e2 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -904,14 +904,14 @@ char SYMEXPORT *alpm_compute_sha256sum(const char 
*filename)
  * error
  */
 int _alpm_test_checksum(const char *filepath, const char *expected,
-               enum _alpm_csum type)
+               alpm_pkgvalidation_t type)
 {
        char *computed;
        int ret;
 
-       if(type == ALPM_CSUM_MD5) {
+       if(type == ALPM_PKG_VALIDATION_MD5SUM) {
                computed = alpm_compute_md5sum(filepath);
-       } else if(type == ALPM_CSUM_SHA256) {
+       } else if(type == ALPM_PKG_VALIDATION_SHA256SUM) {
                computed = alpm_compute_sha256sum(filepath);
        } else {
                return -1;
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index d5cf012..cc5ac7b 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -105,11 +105,6 @@ struct archive_read_buffer {
        int ret;
 };
 
-enum _alpm_csum {
-       ALPM_CSUM_MD5,
-       ALPM_CSUM_SHA256,
-};
-
 int _alpm_makepath(const char *path);
 int _alpm_makepath_mode(const char *path, mode_t mode);
 int _alpm_copyfile(const char *src, const char *dest);
@@ -130,7 +125,7 @@ int _alpm_str_cmp(const void *s1, const void *s2);
 char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename);
 const char *_alpm_filecache_setup(alpm_handle_t *handle);
 int _alpm_lstat(const char *path, struct stat *buf);
-int _alpm_test_checksum(const char *filepath, const char *expected, enum 
_alpm_csum type);
+int _alpm_test_checksum(const char *filepath, const char *expected, 
alpm_pkgvalidation_t type);
 int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b);
 int _alpm_splitname(const char *target, char **name, char **version,
                unsigned long *name_hash);
-- 
1.7.9.1


Reply via email to