[pacman-dev] [PATCH v2 2/2] Make pacman build cleanly with clang's -Wassign-enum

ivy.foster at gmail.com ivy.foster at gmail.com
Sun Sep 4 03:14:50 UTC 2016


From: Ivy Foster <ivy.foster at gmail.com>

In many cases, it was enough to add error or "none" values to enums,
to account for cases where functions returned either an enumerated
value or 0/-1.

A common code pattern in pacman is to use enums to create bitfields
representing various option combinations. Since they are not
technically part of the enumerated type used to build them, these
bitfields have been reassigned to type int.

Signed-off-by: Ivy Foster <ivy.foster at gmail.com>
---
 configure.ac             |  1 +
 lib/libalpm/alpm.c       |  4 +--
 lib/libalpm/alpm.h       | 15 +++++++--
 lib/libalpm/be_package.c |  2 +-
 lib/libalpm/be_sync.c    |  4 +--
 lib/libalpm/db.c         | 20 ++++++------
 lib/libalpm/db.h         |  2 +-
 lib/libalpm/dload.c      |  2 +-
 lib/libalpm/package.c    | 84 ++++++++++++++++++++++++------------------------
 lib/libalpm/package.h    |  2 +-
 lib/libalpm/signing.c    |  6 ++--
 lib/libalpm/sync.c       | 10 +++---
 lib/libalpm/trans.c      |  2 +-
 lib/libalpm/util.h       |  2 +-
 src/pacman/conf.c        |  4 +--
 src/pacman/conf.h        | 12 +++----
 src/pacman/database.c    |  2 +-
 src/util/cleanupdelta.c  |  2 +-
 src/util/pactree.c       |  2 +-
 src/util/testpkg.c       |  2 +-
 20 files changed, 96 insertions(+), 84 deletions(-)

diff --git a/configure.ac b/configure.ac
index 51288e7..2f9aeab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -430,6 +430,7 @@ fi
 AC_MSG_CHECKING(for excessive compiler warning flags)
 if test "x$warningflags" = "xyes" ; then
 	AC_MSG_RESULT(yes)
+	CFLAGS_ADD([-Wassign-enum], [WARNING_CFLAGS])
 	CFLAGS_ADD([-Wcast-align], [WARNING_CFLAGS])
 	CFLAGS_ADD([-Wclobbered], [WARNING_CFLAGS])
 	CFLAGS_ADD([-Wempty-body], [WARNING_CFLAGS])
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 6b7fa7a..6338429 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -152,9 +152,9 @@ const char SYMEXPORT *alpm_version(void)
 /** Get the capabilities of the library.
  * @return a bitmask of the capabilities
  * */
-enum alpm_caps SYMEXPORT alpm_capabilities(void)
+int SYMEXPORT alpm_capabilities(void)
 {
-	return 0
+	return ALPM_CAPABILITY_NONE
 #ifdef ENABLE_NLS
 		| ALPM_CAPABILITY_NLS
 #endif
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 7955585..cb3aa51 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -53,7 +53,8 @@ typedef struct __alpm_trans_t alpm_trans_t;
  * @{
  */
 typedef enum _alpm_errno_t {
-	ALPM_ERR_MEMORY = 1,
+	ALPM_ERR_OK = 0,
+	ALPM_ERR_MEMORY,
 	ALPM_ERR_SYSTEM,
 	ALPM_ERR_BADPERMS,
 	ALPM_ERR_NOT_A_FILE,
@@ -143,6 +144,7 @@ typedef int64_t alpm_time_t;
 
 /** Package install reasons. */
 typedef enum _alpm_pkgreason_t {
+	ALPM_PKG_REASON_ERROR = -1,
 	/** Explicitly requested by the user. */
 	ALPM_PKG_REASON_EXPLICIT = 0,
 	/** Installed as a dependency for another package. */
@@ -151,6 +153,7 @@ typedef enum _alpm_pkgreason_t {
 
 /** Location a package object was loaded from. */
 typedef enum _alpm_pkgfrom_t {
+	ALPM_PKG_FROM_ERROR = -1,
 	ALPM_PKG_FROM_FILE = 1,
 	ALPM_PKG_FROM_LOCALDB,
 	ALPM_PKG_FROM_SYNCDB
@@ -158,6 +161,7 @@ typedef enum _alpm_pkgfrom_t {
 
 /** Method used to validate a package. */
 typedef enum _alpm_pkgvalidation_t {
+	ALPM_PKG_VALIDATION_ERROR = -1,
 	ALPM_PKG_VALIDATION_UNKNOWN = 0,
 	ALPM_PKG_VALIDATION_NONE = (1 << 0),
 	ALPM_PKG_VALIDATION_MD5SUM = (1 << 1),
@@ -193,6 +197,9 @@ typedef enum _alpm_fileconflicttype_t {
 
 /** PGP signature verification options */
 typedef enum _alpm_siglevel_t {
+	ALPM_SIG_ERROR = -1,
+	ALPM_SIG_NONE = 0,
+
 	ALPM_SIG_PACKAGE = (1 << 0),
 	ALPM_SIG_PACKAGE_OPTIONAL = (1 << 1),
 	ALPM_SIG_PACKAGE_MARGINAL_OK = (1 << 2),
@@ -1037,6 +1044,7 @@ alpm_list_t *alpm_db_get_groupcache(alpm_db_t *db);
 alpm_list_t *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles);
 
 typedef enum _alpm_db_usage_ {
+	ALPM_DB_USAGE_NONE = 0,
 	ALPM_DB_USAGE_SYNC = 1,
 	ALPM_DB_USAGE_SEARCH = (1 << 1),
 	ALPM_DB_USAGE_INSTALL = (1 << 2),
@@ -1439,6 +1447,8 @@ alpm_pkg_t *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_sync);
 
 /** Transaction flags */
 typedef enum _alpm_transflag_t {
+	ALPM_TRANS_FLAG_ERROR = -1,
+	ALPM_TRANS_FLAG_NONE = 0,
 	/** Ignore dependency checks. */
 	ALPM_TRANS_FLAG_NODEPS = 1,
 	/** Ignore file conflicts and overwrite files. */
@@ -1606,13 +1616,14 @@ int alpm_release(alpm_handle_t *handle);
 int alpm_unlock(alpm_handle_t *handle);
 
 enum alpm_caps {
+	ALPM_CAPABILITY_NONE = 0,
 	ALPM_CAPABILITY_NLS = (1 << 0),
 	ALPM_CAPABILITY_DOWNLOADER = (1 << 1),
 	ALPM_CAPABILITY_SIGNATURES = (1 << 2)
 };
 
 const char *alpm_version(void);
-enum alpm_caps alpm_capabilities(void);
+int alpm_capabilities(void);
 
 void alpm_fileconflict_free(alpm_fileconflict_t *conflict);
 void alpm_depmissing_free(alpm_depmissing_t *miss);
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 430d2ae..befcba3 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -274,7 +274,7 @@ int _alpm_pkg_validate_internal(alpm_handle_t *handle,
 		alpm_siglist_t **sigdata, alpm_pkgvalidation_t *validation)
 {
 	int has_sig;
-	handle->pm_errno = 0;
+	handle->pm_errno = ALPM_ERR_OK;
 
 	if(pkgfile == NULL || strlen(pkgfile) == 0) {
 		RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1);
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 32a669d..2cd722e 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -186,7 +186,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
 	/* Sanity checks */
 	ASSERT(db != NULL, return -1);
 	handle = db->handle;
-	handle->pm_errno = 0;
+	handle->pm_errno = ALPM_ERR_OK;
 	ASSERT(db != handle->db_local, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
 	ASSERT(db->servers != NULL, RET_ERR(handle, ALPM_ERR_SERVER_NONE, -1));
 
@@ -320,7 +320,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
 		_alpm_log(handle, ALPM_LOG_DEBUG, "failed to sync db: %s\n",
 				alpm_strerror(handle->pm_errno));
 	} else {
-		handle->pm_errno = 0;
+		handle->pm_errno = ALPM_ERR_OK;
 	}
 
 	_alpm_handle_unlock(handle);
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index f70f83c..913ea6a 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -112,7 +112,7 @@ int SYMEXPORT alpm_db_unregister(alpm_db_t *db)
 	ASSERT(db != NULL, return -1);
 	/* Do not unregister a database if a transaction is on-going */
 	handle = db->handle;
-	handle->pm_errno = 0;
+	handle->pm_errno = ALPM_ERR_OK;
 	ASSERT(handle->trans == NULL, RET_ERR(handle, ALPM_ERR_TRANS_NOT_NULL, -1));
 
 	if(db == handle->db_local) {
@@ -179,7 +179,7 @@ int SYMEXPORT alpm_db_add_server(alpm_db_t *db, const char *url)
 
 	/* Sanity checks */
 	ASSERT(db != NULL, return -1);
-	db->handle->pm_errno = 0;
+	db->handle->pm_errno = ALPM_ERR_OK;
 	ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1));
 
 	newurl = sanitize_url(url);
@@ -206,7 +206,7 @@ int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url)
 
 	/* Sanity checks */
 	ASSERT(db != NULL, return -1);
-	db->handle->pm_errno = 0;
+	db->handle->pm_errno = ALPM_ERR_OK;
 	ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1));
 
 	newurl = sanitize_url(url);
@@ -237,7 +237,7 @@ const char SYMEXPORT *alpm_db_get_name(const alpm_db_t *db)
 /** Get the signature verification level for a database. */
 alpm_siglevel_t SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db)
 {
-	ASSERT(db != NULL, return -1);
+	ASSERT(db != NULL, return ALPM_SIG_ERROR);
 	if(db->siglevel & ALPM_SIG_USE_DEFAULT) {
 		return db->handle->siglevel;
 	} else {
@@ -249,7 +249,7 @@ alpm_siglevel_t SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db)
 int SYMEXPORT alpm_db_get_valid(alpm_db_t *db)
 {
 	ASSERT(db != NULL, return -1);
-	db->handle->pm_errno = 0;
+	db->handle->pm_errno = ALPM_ERR_OK;
 	return db->ops->validate(db);
 }
 
@@ -258,7 +258,7 @@ alpm_pkg_t SYMEXPORT *alpm_db_get_pkg(alpm_db_t *db, const char *name)
 {
 	alpm_pkg_t *pkg;
 	ASSERT(db != NULL, return NULL);
-	db->handle->pm_errno = 0;
+	db->handle->pm_errno = ALPM_ERR_OK;
 	ASSERT(name != NULL && strlen(name) != 0,
 			RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, NULL));
 
@@ -273,7 +273,7 @@ alpm_pkg_t SYMEXPORT *alpm_db_get_pkg(alpm_db_t *db, const char *name)
 alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(alpm_db_t *db)
 {
 	ASSERT(db != NULL, return NULL);
-	db->handle->pm_errno = 0;
+	db->handle->pm_errno = ALPM_ERR_OK;
 	return _alpm_db_get_pkgcache(db);
 }
 
@@ -281,7 +281,7 @@ alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(alpm_db_t *db)
 alpm_group_t SYMEXPORT *alpm_db_get_group(alpm_db_t *db, const char *name)
 {
 	ASSERT(db != NULL, return NULL);
-	db->handle->pm_errno = 0;
+	db->handle->pm_errno = ALPM_ERR_OK;
 	ASSERT(name != NULL && strlen(name) != 0,
 			RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, NULL));
 
@@ -292,7 +292,7 @@ alpm_group_t SYMEXPORT *alpm_db_get_group(alpm_db_t *db, const char *name)
 alpm_list_t SYMEXPORT *alpm_db_get_groupcache(alpm_db_t *db)
 {
 	ASSERT(db != NULL, return NULL);
-	db->handle->pm_errno = 0;
+	db->handle->pm_errno = ALPM_ERR_OK;
 
 	return _alpm_db_get_groupcache(db);
 }
@@ -301,7 +301,7 @@ alpm_list_t SYMEXPORT *alpm_db_get_groupcache(alpm_db_t *db)
 alpm_list_t SYMEXPORT *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
 {
 	ASSERT(db != NULL, return NULL);
-	db->handle->pm_errno = 0;
+	db->handle->pm_errno = ALPM_ERR_OK;
 
 	return _alpm_db_search(db, needles);
 }
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index e696298..ae21e75 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -72,7 +72,7 @@ struct __alpm_db_t {
 	alpm_list_t *servers;
 	struct db_operations *ops;
 	/* flags determining validity, local, loaded caches, etc. */
-	enum _alpm_dbstatus_t status;
+	int status;
 	alpm_siglevel_t siglevel;
 	alpm_db_usage_t usage;
 };
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index f4e6a27..10e4a0d 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -412,7 +412,7 @@ static int curl_download_internal(struct dload_payload *payload,
 	/* shortcut to our handle within the payload */
 	alpm_handle_t *handle = payload->handle;
 	CURL *curl = get_libcurl_handle(handle);
-	handle->pm_errno = 0;
+	handle->pm_errno = ALPM_ERR_OK;
 
 	/* make sure these are NULL */
 	FREE(payload->tempfile_name);
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index f08df8b..4cac2d1 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -60,7 +60,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
 	int retval;
 
 	ASSERT(pkg != NULL, return -1);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	/* We only inspect packages from sync repositories */
 	ASSERT(pkg->origin == ALPM_PKG_FROM_SYNCDB,
 			RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1));
@@ -184,196 +184,196 @@ struct pkg_operations default_pkg_ops = {
 const char SYMEXPORT *alpm_pkg_get_filename(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->filename;
 }
 
 const char SYMEXPORT *alpm_pkg_get_base(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_base(pkg);
 }
 
 const char SYMEXPORT *alpm_pkg_get_name(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->name;
 }
 
 const char SYMEXPORT *alpm_pkg_get_version(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->version;
 }
 
 alpm_pkgfrom_t SYMEXPORT alpm_pkg_get_origin(alpm_pkg_t *pkg)
 {
-	ASSERT(pkg != NULL, return -1);
-	pkg->handle->pm_errno = 0;
+	ASSERT(pkg != NULL, return ALPM_PKG_FROM_ERROR);
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->origin;
 }
 
 const char SYMEXPORT *alpm_pkg_get_desc(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_desc(pkg);
 }
 
 const char SYMEXPORT *alpm_pkg_get_url(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_url(pkg);
 }
 
 alpm_time_t SYMEXPORT alpm_pkg_get_builddate(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return -1);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_builddate(pkg);
 }
 
 alpm_time_t SYMEXPORT alpm_pkg_get_installdate(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return -1);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_installdate(pkg);
 }
 
 const char SYMEXPORT *alpm_pkg_get_packager(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_packager(pkg);
 }
 
 const char SYMEXPORT *alpm_pkg_get_md5sum(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->md5sum;
 }
 
 const char SYMEXPORT *alpm_pkg_get_sha256sum(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->sha256sum;
 }
 
 const char SYMEXPORT *alpm_pkg_get_base64_sig(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->base64_sig;
 }
 
 const char SYMEXPORT *alpm_pkg_get_arch(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_arch(pkg);
 }
 
 off_t SYMEXPORT alpm_pkg_get_size(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return -1);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->size;
 }
 
 off_t SYMEXPORT alpm_pkg_get_isize(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return -1);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_isize(pkg);
 }
 
 alpm_pkgreason_t SYMEXPORT alpm_pkg_get_reason(alpm_pkg_t *pkg)
 {
-	ASSERT(pkg != NULL, return -1);
-	pkg->handle->pm_errno = 0;
+	ASSERT(pkg != NULL, return ALPM_PKG_REASON_ERROR);
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_reason(pkg);
 }
 
 alpm_pkgvalidation_t SYMEXPORT alpm_pkg_get_validation(alpm_pkg_t *pkg)
 {
-	ASSERT(pkg != NULL, return -1);
-	pkg->handle->pm_errno = 0;
+	ASSERT(pkg != NULL, return ALPM_PKG_VALIDATION_ERROR);
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_validation(pkg);
 }
 
 alpm_list_t SYMEXPORT *alpm_pkg_get_licenses(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_licenses(pkg);
 }
 
 alpm_list_t SYMEXPORT *alpm_pkg_get_groups(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_groups(pkg);
 }
 
 alpm_list_t SYMEXPORT *alpm_pkg_get_depends(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_depends(pkg);
 }
 
 alpm_list_t SYMEXPORT *alpm_pkg_get_optdepends(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_optdepends(pkg);
 }
 
 alpm_list_t SYMEXPORT *alpm_pkg_get_conflicts(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_conflicts(pkg);
 }
 
 alpm_list_t SYMEXPORT *alpm_pkg_get_provides(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_provides(pkg);
 }
 
 alpm_list_t SYMEXPORT *alpm_pkg_get_replaces(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_replaces(pkg);
 }
 
 alpm_list_t SYMEXPORT *alpm_pkg_get_deltas(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->deltas;
 }
 
 alpm_filelist_t SYMEXPORT *alpm_pkg_get_files(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_files(pkg);
 }
 
 alpm_list_t SYMEXPORT *alpm_pkg_get_backup(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->get_backup(pkg);
 }
 
@@ -382,7 +382,7 @@ alpm_db_t SYMEXPORT *alpm_pkg_get_db(alpm_pkg_t *pkg)
 	/* Sanity checks */
 	ASSERT(pkg != NULL, return NULL);
 	ASSERT(pkg->origin != ALPM_PKG_FROM_FILE, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 
 	return pkg->origin_data.db;
 }
@@ -391,7 +391,7 @@ alpm_db_t SYMEXPORT *alpm_pkg_get_db(alpm_pkg_t *pkg)
 void SYMEXPORT *alpm_pkg_changelog_open(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->changelog_open(pkg);
 }
 
@@ -400,7 +400,7 @@ size_t SYMEXPORT alpm_pkg_changelog_read(void *ptr, size_t size,
 		const alpm_pkg_t *pkg, void *fp)
 {
 	ASSERT(pkg != NULL, return 0);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->changelog_read(ptr, size, pkg, fp);
 }
 
@@ -408,7 +408,7 @@ size_t SYMEXPORT alpm_pkg_changelog_read(void *ptr, size_t size,
 int SYMEXPORT alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp)
 {
 	ASSERT(pkg != NULL, return -1);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->changelog_close(pkg, fp);
 }
 
@@ -416,7 +416,7 @@ int SYMEXPORT alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp)
 struct archive SYMEXPORT *alpm_pkg_mtree_open(alpm_pkg_t * pkg)
 {
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->mtree_open(pkg);
 }
 
@@ -425,7 +425,7 @@ int SYMEXPORT alpm_pkg_mtree_next(const alpm_pkg_t * pkg, struct archive *archiv
 	struct archive_entry **entry)
 {
 	ASSERT(pkg != NULL, return -1);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->mtree_next(pkg, archive, entry);
 }
 
@@ -433,14 +433,14 @@ int SYMEXPORT alpm_pkg_mtree_next(const alpm_pkg_t * pkg, struct archive *archiv
 int SYMEXPORT alpm_pkg_mtree_close(const alpm_pkg_t * pkg, struct archive *archive)
 {
 	ASSERT(pkg != NULL, return -1);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->mtree_close(pkg, archive);
 }
 
 int SYMEXPORT alpm_pkg_has_scriptlet(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return -1);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 	return pkg->ops->has_scriptlet(pkg);
 }
 
@@ -448,7 +448,7 @@ static void find_requiredby(alpm_pkg_t *pkg, alpm_db_t *db, alpm_list_t **reqs,
 		int optional)
 {
 	const alpm_list_t *i;
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 
 	for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
 		alpm_pkg_t *cachepkg = i->data;
@@ -478,7 +478,7 @@ static alpm_list_t *compute_requiredby(alpm_pkg_t *pkg, int optional)
 	alpm_db_t *db;
 
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 
 	if(pkg->origin == ALPM_PKG_FROM_FILE) {
 		/* The sane option; search locally for things that require this. */
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 114d225..4dce542 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -130,7 +130,7 @@ struct __alpm_pkg_t {
 		char *file;
 	} origin_data;
 
-	alpm_dbinfrq_t infolevel;
+	int infolevel;
 	alpm_pkgvalidation_t validation;
 	alpm_pkgfrom_t origin;
 	alpm_pkgreason_t reason;
diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c
index 6557c20..527e763 100644
--- a/lib/libalpm/signing.c
+++ b/lib/libalpm/signing.c
@@ -771,7 +771,7 @@ int _alpm_check_pgp_helper(alpm_handle_t *handle, const char *path,
 	if(ret && handle->pm_errno == ALPM_ERR_SIG_MISSING) {
 		if(optional) {
 			_alpm_log(handle, ALPM_LOG_DEBUG, "missing optional signature\n");
-			handle->pm_errno = 0;
+			handle->pm_errno = ALPM_ERR_OK;
 			ret = 0;
 		} else {
 			_alpm_log(handle, ALPM_LOG_DEBUG, "missing required signature\n");
@@ -931,7 +931,7 @@ int SYMEXPORT alpm_pkg_check_pgp_signature(alpm_pkg_t *pkg,
 {
 	ASSERT(pkg != NULL, return -1);
 	ASSERT(siglist != NULL, RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1));
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 
 	return _alpm_gpgme_checksig(pkg->handle, pkg->filename,
 			pkg->base64_sig, siglist);
@@ -948,7 +948,7 @@ int SYMEXPORT alpm_db_check_pgp_signature(alpm_db_t *db,
 {
 	ASSERT(db != NULL, return -1);
 	ASSERT(siglist != NULL, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1));
-	db->handle->pm_errno = 0;
+	db->handle->pm_errno = ALPM_ERR_OK;
 
 	return _alpm_gpgme_checksig(db->handle, _alpm_db_path(db), NULL, siglist);
 }
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 00b68d0..41b95f6 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -57,7 +57,7 @@ alpm_pkg_t SYMEXPORT *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_syn
 	alpm_pkg_t *spkg = NULL;
 
 	ASSERT(pkg != NULL, return NULL);
-	pkg->handle->pm_errno = 0;
+	pkg->handle->pm_errno = ALPM_ERR_OK;
 
 	for(i = dbs_sync; !spkg && i; i = i->next) {
 		alpm_db_t *db = i->data;
@@ -460,7 +460,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
 				   transaction. The packages will be removed from the actual
 				   transaction when the transaction packages are replaced with a
 				   dependency-reordered list below */
-				handle->pm_errno = 0;
+				handle->pm_errno = ALPM_ERR_OK;
 				if(data) {
 					alpm_list_free_inner(*data,
 							(alpm_list_fn_free)alpm_depmissing_free);
@@ -1140,7 +1140,7 @@ static int check_validity(alpm_handle_t *handle,
 	EVENT(handle, &event);
 
 	for(i = handle->trans->add; i; i = i->next, current++) {
-		struct validity v = { i->data, NULL, NULL, 0, 0, 0 };
+		struct validity v = { i->data, NULL, NULL, ALPM_SIG_NONE, 0, 0 };
 		int percent = (int)(((double)current_bytes / total_bytes) * 100);
 
 		PROGRESS(handle, ALPM_PROGRESS_INTEGRITY_START, "", percent,
@@ -1195,7 +1195,7 @@ static int check_validity(alpm_handle_t *handle,
 		}
 		alpm_list_free(errors);
 
-		if(!handle->pm_errno) {
+		if(handle->pm_errno == ALPM_ERR_OK) {
 			RET_ERR(handle, ALPM_ERR_PKG_INVALID, -1);
 		}
 		return -1;
@@ -1280,7 +1280,7 @@ static int load_packages(alpm_handle_t *handle, alpm_list_t **data,
 	EVENT(handle, &event);
 
 	if(errors) {
-		if(!handle->pm_errno) {
+		if(handle->pm_errno == ALPM_ERR_OK) {
 			RET_ERR(handle, ALPM_ERR_PKG_INVALID, -1);
 		}
 		return -1;
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 1398470..1d23864 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -418,7 +418,7 @@ cleanup:
 alpm_transflag_t SYMEXPORT alpm_trans_get_flags(alpm_handle_t *handle)
 {
 	/* Sanity checks */
-	CHECK_HANDLE(handle, return -1);
+	CHECK_HANDLE(handle, return ALPM_TRANS_FLAG_ERROR);
 	ASSERT(handle->trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));
 
 	return handle->trans->flags;
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 5a2c105..b9c5c17 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -77,7 +77,7 @@ void _alpm_alloc_fail(size_t size);
 
 #define DOUBLE_EQ(x, y) (fabs((x) - (y)) < DBL_EPSILON)
 
-#define CHECK_HANDLE(handle, action) do { if(!(handle)) { action; } (handle)->pm_errno = 0; } while(0)
+#define CHECK_HANDLE(handle, action) do { if(!(handle)) { action; } (handle)->pm_errno = ALPM_ERR_OK; } while(0)
 
 /** Standard buffer size used throughout the library. */
 #ifdef BUFSIZ
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 25de7af..a2d5555 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -328,7 +328,7 @@ int config_set_arch(const char *arch)
 static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage,
 		alpm_siglevel_t *storage_mask, const char *file, int linenum)
 {
-	alpm_siglevel_t level = *storage, mask = *storage_mask;
+	int level = *storage, mask = *storage_mask;
 	alpm_list_t *i;
 	int ret = 0;
 
@@ -1005,7 +1005,7 @@ static int _parse_directive(const char *file, int linenum, const char *name,
 			section->repo = calloc(sizeof(config_repo_t), 1);
 			section->repo->name = strdup(name);
 			section->repo->siglevel = ALPM_SIG_USE_DEFAULT;
-			section->repo->usage = 0;
+			section->repo->usage = ALPM_DB_USAGE_NONE;
 			config->repos = alpm_list_add(config->repos, section->repo);
 		}
 		return 0;
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 2ddeadb..d7bc1bc 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -96,13 +96,13 @@ typedef struct __config_t {
 	unsigned short noask;
 	unsigned int ask;
 	alpm_transflag_t flags;
-	alpm_siglevel_t siglevel;
-	alpm_siglevel_t localfilesiglevel;
-	alpm_siglevel_t remotefilesiglevel;
+	int siglevel;
+	int localfilesiglevel;
+	int remotefilesiglevel;
 
-	alpm_siglevel_t siglevel_mask;
-	alpm_siglevel_t localfilesiglevel_mask;
-	alpm_siglevel_t remotefilesiglevel_mask;
+	int siglevel_mask;
+	int localfilesiglevel_mask;
+	int remotefilesiglevel_mask;
 
 	/* conf file options */
 	/* I Love Candy! */
diff --git a/src/pacman/database.c b/src/pacman/database.c
index 0197903..a62c082 100644
--- a/src/pacman/database.c
+++ b/src/pacman/database.c
@@ -61,7 +61,7 @@ static int change_install_reason(alpm_list_t *targets)
 	}
 
 	/* Lock database */
-	if(trans_init(0, 0) == -1) {
+	if(trans_init(ALPM_TRANS_FLAG_NONE, 0) == -1) {
 		return 1;
 	}
 
diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c
index 043acf1..d107811 100644
--- a/src/util/cleanupdelta.c
+++ b/src/util/cleanupdelta.c
@@ -68,7 +68,7 @@ static void checkdbs(alpm_list_t *dbnames)
 {
 	alpm_db_t *db = NULL;
 	alpm_list_t *i;
-	const alpm_siglevel_t level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL;
+	const int level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL;
 
 	for(i = dbnames; i; i = alpm_list_next(i)) {
 		const char *dbname = i->data;
diff --git a/src/util/pactree.c b/src/util/pactree.c
index 67be9f9..2463f40 100644
--- a/src/util/pactree.c
+++ b/src/util/pactree.c
@@ -128,7 +128,7 @@ static int register_syncs(void)
 	FILE *fp;
 	char *section = NULL;
 	char line[LINE_MAX];
-	const alpm_siglevel_t level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL;
+	const int level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL;
 
 	fp = fopen(configfile, "r");
 	if(!fp) {
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index 89e8dbd..b176e6b 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -43,7 +43,7 @@ int main(int argc, char *argv[])
 	alpm_handle_t *handle;
 	alpm_errno_t err;
 	alpm_pkg_t *pkg = NULL;
-	const alpm_siglevel_t level = ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL;
+	const int level = ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL;
 
 	if(argc != 2) {
 		fprintf(stderr, "testpkg (pacman) v" PACKAGE_VERSION "\n\n"
-- 
2.9.3


More information about the pacman-dev mailing list