[Pkg-telepathy-commits] [telepathy-mission-control-6] 253/280: mcd_keyfile_get_variant: add support for int16, uint16

Simon McVittie smcv at debian.org
Thu Mar 27 20:07:30 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository telepathy-mission-control-6.

commit 77e52ce80eb8705a039b7070515b89efb48863a5
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Wed Feb 5 14:55:13 2014 +0000

    mcd_keyfile_get_variant: add support for int16, uint16
    
    If we're opportunistically migrating parameters according to
    CM-specified types, we need to cope with uint16 ('q') for port numbers.
    
    Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71093
    Reviewed-by: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
---
 src/mcd-storage.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/src/mcd-storage.c b/src/mcd-storage.c
index 481c3dc..90f6247 100644
--- a/src/mcd-storage.c
+++ b/src/mcd-storage.c
@@ -914,6 +914,29 @@ mcd_keyfile_get_variant (GKeyFile *keyfile,
           }
         break;
 
+      case G_VARIANT_CLASS_INT16:
+          {
+            GError *e = NULL;
+            gint v_int = g_key_file_get_integer (keyfile, group,
+                key, &e);
+
+            if (e != NULL)
+              {
+                g_propagate_error (error, e);
+              }
+            else if (v_int < G_MININT16 || v_int > G_MAXINT16)
+              {
+                g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
+                    "integer %d out of range [%d,%d]",
+                    v_int, G_MININT16, G_MAXINT16);
+              }
+            else
+              {
+                ret = g_variant_new_int16 (v_int);
+              }
+          }
+        break;
+
       case G_VARIANT_CLASS_INT32:
           {
             GError *e = NULL;
@@ -948,6 +971,28 @@ mcd_keyfile_get_variant (GKeyFile *keyfile,
           }
         break;
 
+      case G_VARIANT_CLASS_UINT16:
+          {
+            GError *e = NULL;
+            gint v_int = g_key_file_get_integer (keyfile, group,
+                key, &e);
+
+            if (e != NULL)
+              {
+                g_propagate_error (error, e);
+              }
+            else if (v_int < 0 || (unsigned) v_int > G_MAXUINT16)
+              {
+                g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
+                    "integer %d out of range [0,%d]", v_int, G_MAXUINT16);
+              }
+            else
+              {
+                ret = g_variant_new_uint16 (v_int);
+              }
+          }
+        break;
+
       case G_VARIANT_CLASS_UINT32:
           {
             GError *e = NULL;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-mission-control-6.git



More information about the Pkg-telepathy-commits mailing list