[Libosinfo] [PATCHv2 3/4] Use 'unsigned int' rather than enum type for flag param

Christophe Fergeau cfergeau at redhat.com
Wed Apr 3 15:47:47 UTC 2013


Setting an enum variable to a value that is not part of the enum
(as will happen when passing a bitwise-or flag param to
osinfo_product_foreach_related) is undefined behaviour in C.
---
 osinfo/osinfo_product.c         | 2 +-
 osinfo/osinfo_product_private.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/osinfo/osinfo_product.c b/osinfo/osinfo_product.c
index f81212d..35a4071 100644
--- a/osinfo/osinfo_product.c
+++ b/osinfo/osinfo_product.c
@@ -392,7 +392,7 @@ static OsinfoList *osinfo_list_append(OsinfoList *appendee,
  * upgrades or clones, or a combination of these, or none.
  */
 void osinfo_product_foreach_related(OsinfoProduct *product,
-                                    OsinfoProductForeachFlag flags,
+                                    unsigned int flags,
                                     OsinfoProductForeach foreach_func,
                                     gpointer user_data)
 {
diff --git a/osinfo/osinfo_product_private.h b/osinfo/osinfo_product_private.h
index b3c279d..c4ecdd5 100644
--- a/osinfo/osinfo_product_private.h
+++ b/osinfo/osinfo_product_private.h
@@ -36,7 +36,7 @@ typedef enum { /*< skip >*/
 } OsinfoProductForeachFlag;
 
 void osinfo_product_foreach_related(OsinfoProduct *product,
-                                    OsinfoProductForeachFlag flags,
+                                    unsigned int flags,
                                     OsinfoProductForeach foreach_func,
                                     gpointer user_data);
 
-- 
1.8.1.4




More information about the Libosinfo mailing list