From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCHv9 08/16] provision: Add provisioning plugin
Date: Wed, 12 Oct 2011 16:56:21 -0500 [thread overview]
Message-ID: <4E960D05.6020204@gmail.com> (raw)
In-Reply-To: <1317820719-23609-9-git-send-email-oleg.zhurakivskyy@intel.com>
[-- Attachment #1: Type: text/plain, Size: 2471 bytes --]
Hi Oleg,
<snip>
> +static int provision_get_settings(const char *mcc, const char *mnc,
> + const char *spn,
> + struct ofono_gprs_provision_data **settings,
> + int *count)
> +{
> + GSList *l;
> + GSList *apns;
> + GError *error = NULL;
> + int ap_count;
> + int i;
> +
> + DBG("Provisioning for MCC %s, MNC %s, SPN '%s'", mcc, mnc, spn);
> +
> + apns = mbpi_lookup(mcc, mnc, FALSE, &error);
> + if (apns == NULL) {
> + if (error != NULL) {
> + ofono_error("%s", error->message);
> + g_error_free(error);
> + }
> +
> + return -ENOENT;
> + }
> +
> + ap_count = g_slist_length(apns);
> +
> + DBG("Found %d APs", ap_count);
> +
> + *settings = g_try_malloc_n(ap_count,
> + sizeof(struct ofono_gprs_provision_data));
Please use g_try_new0 instead of g_try_malloc_n. The result will be a
bit prettier.
> + if (*settings == NULL) {
> + ofono_error("Provisioning failed: %s", g_strerror(errno));
> +
> + for (l = apns; l; l = l->next)
> + mbpi_provision_data_free(l->data);
> +
> + g_slist_free(apns);
> +
> + return -ENOMEM;
> + }
> +
> + *count = ap_count;
> +
> + for (l = apns, i = 0; l; l = l->next, i++) {
> + struct ofono_gprs_provision_data *ap = l->data;
> +
> + DBG("Name: '%s'", ap->name);
> + DBG("APN: '%s'", ap->apn);
> + DBG("Username: '%s'", ap->username);
> + DBG("Password: '%s'", ap->password);
> +
> + *(*settings + i) = *ap;
Please don't use this particular syntax, we prefer using memcpy for this.
> +
> + memset(*settings + i, 0,
> + sizeof(struct ofono_gprs_provision_data));
Do you mean to memset the contents of ap here? The way I read this code
you're setting an entry in the return array and immediately resetting it
to 0.
> + mbpi_provision_data_free(ap);
using g_free(ap) might be the easier solution.
> + }
> +
> + g_slist_free(apns);
> +
> + return 0;
> +}
> +
> +static struct ofono_gprs_provision_driver provision_driver = {
> + .name = "Provisioning",
> + .get_settings = provision_get_settings
> +};
> +
> +static int provision_init(void)
> +{
> + return ofono_gprs_provision_driver_register(&provision_driver);
> +}
> +
> +static void provision_exit(void)
> +{
> + ofono_gprs_provision_driver_unregister(&provision_driver);
> +}
> +
> +OFONO_PLUGIN_DEFINE(provision, "Provisioning Plugin", VERSION,
> + OFONO_PLUGIN_PRIORITY_DEFAULT,
> + provision_init, provision_exit)
Regards,
-Denis
next prev parent reply other threads:[~2011-10-12 21:56 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-05 13:18 [PATCHv9 00/16] Provisioning plugin Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 01/16] mbpi: Remove unused includes Oleg Zhurakivskyy
2011-10-12 21:30 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 02/16] mbpi: Split gsm_start() for readability Oleg Zhurakivskyy
2011-10-12 21:31 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 03/16] mbpi: Reflow gsm_end() Oleg Zhurakivskyy
2011-10-12 21:31 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 04/16] mbpi: Fix handling of the usage element Oleg Zhurakivskyy
2011-10-12 21:31 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 05/16] mbpi: Improve mbpi_lookup() error reporting Oleg Zhurakivskyy
2011-10-12 21:32 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 06/16] lookup-apn: Remove unused includes Oleg Zhurakivskyy
2011-10-12 21:33 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 07/16] lookup-apn: Fix crash on no APNs found Oleg Zhurakivskyy
2011-10-12 21:35 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 08/16] provision: Add provisioning plugin Oleg Zhurakivskyy
2011-10-12 21:56 ` Denis Kenzior [this message]
2011-10-13 11:29 ` Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 09/16] mbpi: Add filename and line information on error Oleg Zhurakivskyy
2011-10-12 22:00 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 10/16] mbpi: Add mbpi_ap_type() Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 11/16] lookup-apn: Use mbpi_ap_type() Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 12/16] mbpi: Rename mbpi_provision_data_free() into mbpi_ap_free() Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 13/16] lookup-apn: Use mbpi_ap_free() Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 14/16] mbpi: Minor style issues Oleg Zhurakivskyy
2011-10-05 13:18 ` [PATCHv9 15/16] lookup-apn: Follow plugin's duplicates approach Oleg Zhurakivskyy
2011-10-12 22:01 ` Denis Kenzior
2011-10-05 13:18 ` [PATCHv9 16/16] lookup-apn: Minor style issues Oleg Zhurakivskyy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E960D05.6020204@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox