[telepathy-glib/master] Don't rely on enum types being unsigned

Sjoerd Simons sjoerd.simons at collabora.co.uk
Wed Nov 25 08:37:42 PST 2009


Not all compilers use unsigned types for enums even if all the values are
postive, as such an enum with 3 items doesn't always fit in a 2 bit field.
This can cause interesting bugs.

Force the type to be an unsigned int, this hopefully doesn't break
anything and fixes the bug without breaking ABI etc.

Reviewed-By: Simon McVittie <simon.mcvittie at collabora.co.uk>
---
 telepathy-glib/connection-manager.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/telepathy-glib/connection-manager.h b/telepathy-glib/connection-manager.h
index d8a97fa..c9574a0 100644
--- a/telepathy-glib/connection-manager.h
+++ b/telepathy-glib/connection-manager.h
@@ -90,7 +90,8 @@ struct _TpConnectionManager {
     /* These are really booleans, but gboolean is signed. Thanks, GLib */
     unsigned int running:1;
     unsigned int always_introspect:1;
-    TpCMInfoSource info_source:2;
+    /* TpCMInfoSource, but can't rely on enums being unsigned */
+    unsigned int info_source:2;
     guint reserved_flags:28;
 
     TpConnectionManagerPrivate *priv;
-- 
1.5.6.5



More information about the telepathy-commits mailing list