ModemManager: Fix GetInfo() dbus calls while port connected



Hi all,

Currently, if you GetInfo() via dbus while the port in the modem is
connected, ModemManager spits a g_return_if_fail() warning:

        modem-manager[21377]: mm_modem_base_get_card_info: assertion
        `port != NULL' failed

When the port is connected and there is no secondary port to use,
get_best_at_port() will return NULL and set the GError to
MM_MODEM_ERROR_CONNECTED. But, the card info will probably already be
cached by the base modem, so there won't be any need to send any command
to the modem.

The following patch allows NULL ports passed to
mm_modem_base_get_card_info() only if port_error is given; so that:
 - If there are cached results the error is ignored and cached results
are returned, or
 - If there are no cached results, the port_error is returned.

Cheers,

-- 
Aleksander
>From 832a0b80032bad42d8112916722360d67218a546 Mon Sep 17 00:00:00 2001
From: Aleksander Morgado <aleksander lanedo com>
Date: Wed, 6 Apr 2011 17:08:06 +0200
Subject: [PATCH] modem-base: allow NULL ports in get_card_info() if port_error given

So that cached values can be returned if querying while the port is connected.
---
 src/mm-modem-base.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mm-modem-base.c b/src/mm-modem-base.c
index ee5e1c8..9afc1bf 100644
--- a/src/mm-modem-base.c
+++ b/src/mm-modem-base.c
@@ -526,12 +526,12 @@ mm_modem_base_get_card_info (MMModemBase *self,
     MMModemBasePrivate *priv;
     MMCallbackInfo *info;
     gboolean cached = FALSE;
-    GError *error = port_error;
+    GError *error = NULL;
 
     g_return_if_fail (self != NULL);
     g_return_if_fail (MM_IS_MODEM_BASE (self));
-    g_return_if_fail (port != NULL);
-    g_return_if_fail (MM_IS_AT_SERIAL_PORT (port));
+    /* Either we get a proper AT port, or we get a port_error */
+    g_return_if_fail ((port != NULL && MM_IS_AT_SERIAL_PORT (port)) || port_error != NULL);
     g_return_if_fail (callback != NULL);
 
     priv = MM_MODEM_BASE_GET_PRIVATE (self);
-- 
1.7.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]