[PATCH] Fixed wrong MEM1 value passed to +CPMS

Carlo Lobrano c.lobrano at gmail.com
Thu Mar 23 13:29:19 UTC 2017


Let mem1_str defaulting to NULL when current_sms_mem1_storage is
MM_SMS_STORAGE_UNKNOWN

modem_messaging_set_default_storage considers mem1 storage
string valid if *not NULL*, but, previously, when we could not get
current_sms_mem1_storage value right, mem1_str defaulted to "unknown"
and that string was used in +CPMS command, resulting in an ERROR.

---
 src/mm-broadband-modem.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 17b3253..776e6d1 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -5587,7 +5587,7 @@ modem_messaging_set_default_storage (MMIfaceModemMessaging *_self,
     MMBroadbandModem *self = MM_BROADBAND_MODEM (_self);
     gchar *cmd;
     GSimpleAsyncResult *result;
-    gchar *mem1_str;
+    gchar *mem1_str = NULL;
     gchar *mem_str;
 
     result = g_simple_async_result_new (G_OBJECT (self),
@@ -5599,11 +5599,14 @@ modem_messaging_set_default_storage (MMIfaceModemMessaging *_self,
     self->priv->current_sms_mem2_storage = storage;
 
     /* We provide the current sms storage for mem1 if not UNKNOWN */
-    mem1_str = g_ascii_strup (mm_sms_storage_get_string (self->priv->current_sms_mem1_storage), -1);
+    if (self->priv->current_sms_mem1_storage != MM_SMS_STORAGE_UNKNOWN) {
+        mem1_str = g_ascii_strup (mm_sms_storage_get_string (self->priv->current_sms_mem1_storage), -1);
+    }
 
     mem_str = g_ascii_strup (mm_sms_storage_get_string (storage), -1);
     cmd = g_strdup_printf ("+CPMS=\"%s\",\"%s\",\"%s\"",
-                           mem1_str ? mem1_str : "",
+                           /* Empty value is not accepted and SM is the default one */
+                           mem1_str ? mem1_str : "SM",
                            mem_str,
                            mem_str);
     mm_base_modem_at_command (MM_BASE_MODEM (self),
-- 
2.9.3



More information about the ModemManager-devel mailing list