Re: [pacman-dev] [PATCH v3 2/4] Represent bitfields as ints, not enums

2016-10-17 Thread Allan McRae
On 13/10/16 06:13, ivy.fos...@gmail.com wrote:
> From: Ivy Foster 
> 
> Many bitfield variables are declared to be enums, because they are
> generated using bitwise operations on enums such. However, their
> actual values aren't necessary members of their parent enum, so
> declaring them 'int' is more accurate.
>

Looks good to me.

A


[pacman-dev] [PATCH v3 2/4] Represent bitfields as ints, not enums

2016-10-12 Thread ivy . foster
From: Ivy Foster 

Many bitfield variables are declared to be enums, because they are
generated using bitwise operations on enums such. However, their
actual values aren't necessary members of their parent enum, so
declaring them 'int' is more accurate.

Signed-off-by: Ivy Foster 
---
 lib/libalpm/alpm.c   |  2 +-
 lib/libalpm/alpm.h   | 33 +
 lib/libalpm/be_local.c   |  8 
 lib/libalpm/be_package.c |  8 
 lib/libalpm/be_sync.c| 26 +-
 lib/libalpm/db.c | 10 +-
 lib/libalpm/db.h | 16 ++--
 lib/libalpm/handle.c | 12 ++--
 lib/libalpm/handle.h |  6 +++---
 lib/libalpm/package.c|  4 ++--
 lib/libalpm/package.h| 13 -
 lib/libalpm/sync.c   | 16 
 lib/libalpm/trans.c  |  4 ++--
 lib/libalpm/trans.h  |  6 --
 lib/libalpm/util.h   |  2 ++
 src/pacman/conf.c| 17 -
 src/pacman/conf.h| 24 +---
 src/pacman/package.c |  2 +-
 src/pacman/sync.c|  2 +-
 src/pacman/upgrade.c |  8 
 src/pacman/util.c|  2 +-
 src/pacman/util.h|  3 ++-
 src/util/cleanupdelta.c  |  4 ++--
 src/util/pactree.c   |  4 ++--
 src/util/testpkg.c   |  4 ++--
 25 files changed, 125 insertions(+), 111 deletions(-)

diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 6b7fa7a..5225e4f 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -152,7 +152,7 @@ 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
 #ifdef ENABLE_NLS
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 0f8274b..2d2491d 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -917,14 +917,14 @@ int alpm_option_set_checkspace(alpm_handle_t *handle, int 
checkspace);
 const char *alpm_option_get_dbext(alpm_handle_t *handle);
 int alpm_option_set_dbext(alpm_handle_t *handle, const char *dbext);
 
-alpm_siglevel_t alpm_option_get_default_siglevel(alpm_handle_t *handle);
-int alpm_option_set_default_siglevel(alpm_handle_t *handle, alpm_siglevel_t 
level);
+int alpm_option_get_default_siglevel(alpm_handle_t *handle);
+int alpm_option_set_default_siglevel(alpm_handle_t *handle, int level);
 
-alpm_siglevel_t alpm_option_get_local_file_siglevel(alpm_handle_t *handle);
-int alpm_option_set_local_file_siglevel(alpm_handle_t *handle, alpm_siglevel_t 
level);
+int alpm_option_get_local_file_siglevel(alpm_handle_t *handle);
+int alpm_option_set_local_file_siglevel(alpm_handle_t *handle, int level);
 
-alpm_siglevel_t alpm_option_get_remote_file_siglevel(alpm_handle_t *handle);
-int alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, 
alpm_siglevel_t level);
+int alpm_option_get_remote_file_siglevel(alpm_handle_t *handle);
+int alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, int level);
 
 /** @} */
 
@@ -957,7 +957,7 @@ alpm_list_t *alpm_get_syncdbs(alpm_handle_t *handle);
  * @return an alpm_db_t* on success (the value), NULL on error
  */
 alpm_db_t *alpm_register_syncdb(alpm_handle_t *handle, const char *treename,
-   alpm_siglevel_t level);
+   int level);
 
 /** Unregister all package databases.
  * @param handle the context handle
@@ -983,7 +983,7 @@ const char *alpm_db_get_name(const alpm_db_t *db);
  * @param db pointer to the package database
  * @return the signature verification level
  */
-alpm_siglevel_t alpm_db_get_siglevel(alpm_db_t *db);
+int alpm_db_get_siglevel(alpm_db_t *db);
 
 /** Check the validity of a database.
  * This is most useful for sync databases and verifying signature status.
@@ -1050,14 +1050,14 @@ typedef enum _alpm_db_usage_ {
  * @param usage a bitmask of alpm_db_usage_t values
  * @return 0 on success, or -1 on error
  */
-int alpm_db_set_usage(alpm_db_t *db, alpm_db_usage_t usage);
+int alpm_db_set_usage(alpm_db_t *db, int usage);
 
 /** Gets the usage of a database.
  * @param db pointer to the package database to get the status of
  * @param usage pointer to an alpm_db_usage_t to store db's status
  * @return 0 on success, or -1 on error
  */
-int alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t *usage);
+int alpm_db_get_usage(alpm_db_t *db, int *usage);
 
 /** @} */
 
@@ -1081,7 +1081,7 @@ int alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t 
*usage);
  * @return 0 on success, -1 on error (pm_errno is set accordingly)
  */
 int alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full,
-   alpm_siglevel_t level, alpm_pkg_t **pkg);
+   int level, alpm_pkg_t **pkg);
 
 /** Find a package in a list by name.
  * @param haystack a list of alpm_pkg_t
@@ -1318,7 +1318,7 @@ const char *alpm_pkg_get_base64_sig(alpm_pkg_t *pkg);
  * @param pkg a pointer to package
  * @return an enum member gi