[MM] [PATCH] sms_get_done(): Check for the correct return value from sscanf()



The "%n" format in sscanf() is tricky; it's best avoided if we don't
actually need it.

(dropped through the cracks of my upstreaming process a little while ago, sorry)

    - Nathan
From fc3f0e40f1c7196f38789f585dca98f22fb13601 Mon Sep 17 00:00:00 2001
From: Nathan Williams <njw chromium org>
Date: Fri, 24 Jun 2011 21:12:00 -0400
Subject: [PATCH] sms_get_done(): Check for the correct return value from sscanf().

Remove an unused variable so it's more obvious what the correct value is.
Fixes live (vs. list) SMS reception on ToT.

BUG=none
TEST=Send SMS to device, see that it shows up in Chrome.

Change-Id: I9c76fb15ef229fe83672e2eee8ae37d7e6ab7b9e
Reviewed-on: http://gerrit.chromium.org/gerrit/3216
Reviewed-by: Nathan J. Williams <njw chromium org>
Tested-by: Nathan J. Williams <njw chromium org>
---
 src/mm-generic-gsm.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index 8e18222..3f7c9ab 100644
--- a/src/mm-generic-gsm.c
+++ b/src/mm-generic-gsm.c
@@ -4472,7 +4472,7 @@ sms_get_done (MMAtSerialPort *port,
 {
     MMCallbackInfo *info = (MMCallbackInfo *) user_data;
     GHashTable *properties;
-    int rv, status, tpdu_len, offset;
+    int rv, status, tpdu_len;
     char pdu[SMS_MAX_PDU_LEN + 1];
 
     /* If the modem has already been removed, return without
@@ -4486,9 +4486,9 @@ sms_get_done (MMAtSerialPort *port,
     }
 
     /* 344 == SMS_MAX_PDU_LEN */
-    rv = sscanf (response->str, "+CMGR: %d,,%d %344s %n",
-                 &status, &tpdu_len, pdu, &offset);
-    if (rv != 4) {
+    rv = sscanf (response->str, "+CMGR: %d,,%d %344s",
+                 &status, &tpdu_len, pdu);
+    if (rv != 3) {
         info->error = g_error_new (MM_MODEM_ERROR,
                                    MM_MODEM_ERROR_GENERAL,
                                    "Failed to parse CMGR response (parsed %d items)",
-- 
1.7.3.1



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