aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-03-08 15:30:14 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-03-16 14:53:23 +0100
commit7bfc56c2a8d1d5d9eb70cdfa803b840c176071b2 (patch)
treebe8a90690242161ab894e511d0cc64a5794963fa
parentcc6d4a97fb0a11c799f1079c6db86b31db7eadf7 (diff)
base-modem-at: set error if NULL port detected
Users of mm_base_modem_at_command_in_port() can now directly pass the result of mm_base_modem_peek_port_primary() or mm_base_modem_peek_port_secondary(), which may be NULL if no such port exists in the modem. So we'll gracefully detect the NULL port and complete the async operation with an error.
-rw-r--r--src/mm-base-modem-at.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mm-base-modem-at.c b/src/mm-base-modem-at.c
index 70b4e41f..6985f41a 100644
--- a/src/mm-base-modem-at.c
+++ b/src/mm-base-modem-at.c
@@ -29,6 +29,18 @@ abort_async_if_port_unusable (MMBaseModem *self,
{
GError *error = NULL;
+ /* If no port given, probably the port dissapeared */
+ if (!port) {
+ g_simple_async_report_error_in_idle (
+ G_OBJECT (self),
+ callback,
+ user_data,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_NOT_FOUND,
+ "Cannot run sequence: port not given");
+ return FALSE;
+ }
+
/* Ensure we don't try to use a connected port */
if (mm_port_get_connected (MM_PORT (port))) {
g_simple_async_report_error_in_idle (