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.
This commit is contained in:
Aleksander Morgado
2012-03-08 15:30:14 +01:00
parent cc6d4a97fb
commit 7bfc56c2a8

View File

@@ -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 (