Hi Sean,

What do you think about this: [0]

In attr_cb() the +10 to attr pointer I need to do better.
While looking at the code, in attr_cb() do we leak the attr string? I
can't find where it's free'd :)

No, the string is declared as const char in both attr_cb and at_util_parse_attr(). So it is returning a pointer to a buffer owned by GAtChat.

<snip>

  static void attr_cb(gboolean ok, GAtResult *result, gpointer user_data)
  {
-       struct cb_data *cbd = user_data;
+       struct custom_cb_data *ccd = user_data;
+       struct cb_data *cbd = ccd->cbd;
        ofono_devinfo_query_cb_t cb = cbd->cb;
        const char *prefix = cbd->user;
        struct ofono_error error;
@@ -57,21 +69,33 @@ static void attr_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
                return;
        }
+ if (ccd->vendor == OFONO_VENDOR_QUECTEL_SERIAL &&
+                       (!strcmp(prefix, "+CGMI:") ||
+                        !strcmp(prefix, "+CGMR:"))) {
+               if (!strncmp("Revision: ", attr, 10)) {
+                       cb(&error, attr+10, cbd->data);
+                       return;

https://people.gnome.org/~ryanl/glib-docs/glib-String-Utility-Functions.html#g-str-has-prefix

+               }
+       }
+
        cb(&error, attr, cbd->data);
  }

<snip>

@@ -111,15 +141,18 @@ static void at_query_revision(struct ofono_devinfo *info,
  static void at_query_serial(struct ofono_devinfo *info,
                                ofono_devinfo_query_cb_t cb, void *data)
  {
-       struct cb_data *cbd = cb_data_new(cb, data);
-       GAtChat *chat = ofono_devinfo_get_data(info);
+       struct custom_cb_data *ccd = g_new0(struct custom_cb_data, 1);
+       struct dev_data *dev = ofono_devinfo_get_data(info);
+       ccd->cbd = cb_data_new(cb, data);
+       ccd->vendor = dev->vendor;

Why not just put everything you need from cb_data into your custom data object instead of trying to allocate cb_data.

- cbd->user = "+CGSN:";
+       ccd->cbd->user = "+CGSN:";
- if (g_at_chat_send(chat, "AT+CGSN", NULL, attr_cb, cbd, g_free) > 0)
+       if (g_at_chat_send(dev->chat, "AT+CGSN", NULL, attr_cb, ccd, g_free) > 
0)
                return;
- g_free(cbd);
+       g_free(ccd->cbd);
+       g_free(ccd);
CALLBACK_WITH_FAILURE(cb, NULL, data);
  }

<snip>

@@ -146,11 +184,11 @@ static int at_devinfo_probe(struct ofono_devinfo *info, 
unsigned int vendor,
static void at_devinfo_remove(struct ofono_devinfo *info)
  {
-       GAtChat *chat = ofono_devinfo_get_data(info);
+       struct dev_data *dev = ofono_devinfo_get_data(info);
- ofono_devinfo_set_data(info, NULL);
+       g_at_chat_unref(dev->chat);

free dev?
- g_at_chat_unref(chat);
+       ofono_devinfo_set_data(info, NULL);
  }
static const struct ofono_devinfo_driver driver = {


Regards,
-Denis
_______________________________________________
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org

Reply via email to