All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH_v6 4/5] emulator: add dun_ato_cb() definition and register it in GAtServer
Date: Wed, 25 May 2011 05:43:05 -0500	[thread overview]
Message-ID: <4DDCDD39.3080901@gmail.com> (raw)
In-Reply-To: <1305884296-2601-5-git-send-email-guillaume.zajac@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2193 bytes --]

Hi Guillaume,

On 05/20/2011 04:38 AM, Guillaume Zajac wrote:
> ---
>  src/emulator.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 54 insertions(+), 0 deletions(-)

I applied this patch, but fixed it up for you afterwards:

> +static void dun_ato_cb(GAtServer *server, GAtServerRequestType type,
> +			GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_emulator *em = user_data;
> +	GAtResultIter iter;
> +	int val;
> +
> +	DBG("");
> +
> +	if (em->ppp == NULL) {
> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_NO_CARRIER);
> +		return;
> +	}

Please avoid doing this, syntax checking should be done beforehand (and
perhaps an appropriate error set).  Then the actual validity checking
should be done.

> +
> +	switch (type) {
> +	case G_AT_SERVER_REQUEST_TYPE_SET:
> +		g_at_result_iter_init(&iter, result);
> +		g_at_result_iter_next(&iter, "");
> +
> +		if (g_at_result_iter_next_number(&iter, &val) == FALSE)
> +			goto error;
> +
> +		if (val != 0)
> +			goto error;
> +
> +		g_at_server_send_intermediate(em->server, "CONNECT");
> +		em->source = g_idle_add(resume_ppp, em);
> +		break;
> +
> +	case G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY:
> +		g_at_server_send_intermediate(em->server, "CONNECT");
> +		em->source = g_idle_add(resume_ppp, em);

This should have used set_write_done...

> +		break;
> +
> +	default:
> +error:
> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
> +		break;
> +	}
> +
> +	return;

Please do not ever use return statements at the end of the function
returning void

> +}
> +
>  static struct indicator *find_indicator(struct ofono_emulator *em,
>  						const char *name, int *index)
>  {
> @@ -775,6 +828,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
>  	case OFONO_EMULATOR_TYPE_DUN:
>  		g_at_server_register(em->server, "D", dial_cb, em, NULL);
>  		g_at_server_register(em->server, "H", dun_ath_cb, em, NULL);
> +		g_at_server_register(em->server, "O", dun_ato_cb, em, NULL);
>  		break;
>  	case OFONO_EMULATOR_TYPE_HFP:
>  		g_at_server_set_echo(em->server, FALSE);

Regards,
-Denis

  reply	other threads:[~2011-05-25 10:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20  9:38 [PATCH_v6 0/5] Escape sequence and ATO0 implementation Guillaume Zajac
2011-05-20  9:38 ` [PATCH_v6 1/5] gathdlc: add g_at_hdlc_resume() API Guillaume Zajac
2011-05-25 10:39   ` Denis Kenzior
2011-05-20  9:38 ` [PATCH_v6 2/5] ppp_net: add ppp_net_resume_interface() API Guillaume Zajac
2011-05-25 10:39   ` Denis Kenzior
2011-05-20  9:38 ` [PATCH_v6 3/5] gatppp: add public suspend/resume APIs and suspended state Guillaume Zajac
2011-05-25 10:40   ` Denis Kenzior
2011-05-20  9:38 ` [PATCH_v6 4/5] emulator: add dun_ato_cb() definition and register it in GAtServer Guillaume Zajac
2011-05-25 10:43   ` Denis Kenzior [this message]
2011-05-20  9:38 ` [PATCH_v6 5/5] gsmdial: add escape sequence/ATH0/ATO0 testing option Guillaume Zajac
2011-05-25 10:43   ` Denis Kenzior

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=4DDCDD39.3080901@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.