From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 11/19] stkutil: Add setup menu proactive command parser
Date: Tue, 11 May 2010 14:21:26 -0500 [thread overview]
Message-ID: <201005111421.27125.denkenz@gmail.com> (raw)
In-Reply-To: <1273487942-27213-11-git-send-email-yang.gu@intel.com>
[-- Attachment #1: Type: text/plain, Size: 3998 bytes --]
Hi Yang,
> @@ -281,8 +281,9 @@ static gboolean parse_dataobj_alpha_id(struct
> comprehension_tlv_iter *iter, char *utf8;
>
> len = comprehension_tlv_iter_get_length(iter);
> - if (len < 1)
> - return FALSE;
> +
> + if (len == 0)
> + return TRUE;
>
> data = comprehension_tlv_iter_get_data(iter);
> utf8 = sim_string_to_utf8(data, len);
There is no mention that the Alpha identifier can be present and empty, so
returning TRUE on a len 0 is not actually correct. The only exception so far
seems to be text string which explicitly allows NULL strings.
> @@ -373,8 +374,10 @@ static gboolean parse_dataobj_item(struct
> comprehension_tlv_iter *iter, char *utf8;
>
> len = comprehension_tlv_iter_get_length(iter);
> - if (len < 2)
> - return FALSE;
> +
> + if (len == 0)
> + return TRUE;
> +
>
Same with this one...
> data = comprehension_tlv_iter_get_data(iter);
>
> @@ -2006,6 +2009,7 @@ static gboolean parse_dataobj(struct
> comprehension_tlv_iter *iter, GSList *l;
> va_list args;
> gboolean minimum_set = TRUE;
> + GSList **list = NULL;
>
> va_start(args, type);
>
> @@ -2022,29 +2026,74 @@ static gboolean parse_dataobj(struct
> comprehension_tlv_iter *iter, entries = g_slist_prepend(entries, entry);
> }
>
> -
> if (comprehension_tlv_iter_next(iter) != TRUE)
> goto out;
>
> entries = g_slist_reverse(entries);
>
> - for (l = entries; l; l = l->next) {
> + for (l = entries; l;) {
> dataobj_handler handler;
> struct dataobj_handler_entry *entry = l->data;
> + unsigned short tag;
> + gboolean ret;
> + void *dataobj;
>
> handler = handler_for_type(entry->type);
> - if (handler == NULL)
> + if (handler == NULL) {
> + l = l->next;
> continue;
> + }
>
> - if (comprehension_tlv_iter_get_tag(iter) == entry->type) {
> - if (handler(iter, entry->data))
> - entry->parsed = TRUE;
> - if (comprehension_tlv_iter_next(iter) == FALSE)
> - break;
> + tag = comprehension_tlv_iter_get_tag(iter);
> + if (tag != entry->type) {
> + l = l->next;
> + continue;
> }
> +
> + if (tag == STK_DATA_OBJECT_TYPE_PROVISIONING_FILE_REFERENCE ||
> + tag == STK_DATA_OBJECT_TYPE_ITEM) {
> +
> + if (tag == STK_DATA_OBJECT_TYPE_ITEM)
> + dataobj = g_try_new0(struct stk_item, 1);
> + else
> + dataobj = g_try_new0(struct stk_file, 1);
> +
> + if (!dataobj)
> + goto out;
> +
> + if (!list)
> + list = entry->data;
> +
> + ret = handler(iter, dataobj);
> + } else
> + ret = handler(iter, entry->data);
> +
> + if (ret)
> + entry->parsed = TRUE;
> +
> + if (tag == STK_DATA_OBJECT_TYPE_PROVISIONING_FILE_REFERENCE ||
> + tag == STK_DATA_OBJECT_TYPE_ITEM) {
> +
> + if (tag == STK_DATA_OBJECT_TYPE_ITEM) {
> + struct stk_item *item = dataobj;
> + /* either return is FALSE or item is empty */
> + if (item->id == 0)
> + g_free(item);
> + else
> + *list = g_slist_prepend(*list, item);
> + } else
> + *list = g_slist_prepend(*list, dataobj);
> + } else
> + l = l->next;
> +
> + if (comprehension_tlv_iter_next(iter) == FALSE)
> + break;
> }
>
I really don't like this. I understand why you're doing it this way, but lets
try to make this more elegant. Either add another FLAG saying that the items
are actually in a list, or parse the item list separately.
e.g.
parse_dataobj(iter, STK_DATA_OBJECT_TYPE_ALPHA_ID,
DATAOBJ_FLAG_MANDATORY | DATAOBJ_FLAG_MINIMUM,
&obj->alpha_id,
STK_DATA_OBJECT_TYPE_ITEM,
DATAOBJ_FLAG_MANDATORY | DATAOBJ_FLAG_MINIMUM | DATAOBJ_FLAG_LIST,
&obj->items, ...
or
/* Parse only until item list */
parse_dataobj(iter, STK_DATA_OBJECT_TYPE_ALPHA_ID,
DATAOBJ_FLAG_MANDATORY | DATAOBJ_FLAG_MINIMUM,
&obj->alpha_id,
STK_DATA_OBJECT_TYPE_ITEM,
STK_DATA_OBJECT_TYPE_INVALID);
/* Manually parse item list */
...
/* Parse rest */
...
Regards,
-Denis
next prev parent reply other threads:[~2010-05-11 19:21 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-10 10:38 [PATCH 01/19] stkutil: Free default text for get input parser Yang Gu
2010-05-10 10:38 ` [PATCH 02/19] test-stkutil: Add unit test " Yang Gu
2010-05-11 19:25 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 03/19] stk: Unify variable names to use abbreviation Yang Gu
2010-05-11 19:25 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 04/19] test-stkutil: Use enum for icon_id Yang Gu
2010-05-11 19:25 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 05/19] stkutil: Add play tone proactive command parser Yang Gu
2010-05-11 19:26 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 06/19] Replace check_text with check_common_text Yang Gu
2010-05-11 19:26 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 07/19] stkutil: Refactor parser for tone objects Yang Gu
2010-05-11 19:26 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 08/19] test-stkutil: Add unit test for play tone parser Yang Gu
2010-05-11 19:27 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 09/19] stkutil: Add poll interval proactive command parser Yang Gu
2010-05-11 19:23 ` Denis Kenzior
2010-05-12 9:03 ` Gu, Yang
2010-05-12 14:21 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 10/19] test-stkutil: Add unit test for poll interval parser Yang Gu
2010-05-10 10:38 ` [PATCH 11/19] stkutil: Add setup menu proactive command parser Yang Gu
2010-05-11 19:21 ` Denis Kenzior [this message]
2010-05-12 8:53 ` Gu, Yang
2010-05-12 14:43 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 12/19] test-stkutil: Add unit test for setup menu parser Yang Gu
2010-05-10 10:38 ` [PATCH 13/19] stkutil: Add select item proactive command parser Yang Gu
2010-05-10 10:38 ` [PATCH 14/19] test-stkutil: Add unit test for select item parser Yang Gu
2010-05-10 10:38 ` [PATCH 15/19] test-stkutil: Use dedicated functions to check Yang Gu
2010-05-10 10:38 ` [PATCH 16/19] stkutil: Parse cdma tpdu in send sms parser Yang Gu
2010-05-11 19:38 ` Denis Kenzior
2010-05-10 10:39 ` [PATCH 17/19] test-stkutil: Refactor test for " Yang Gu
2010-05-10 10:39 ` [PATCH 18/19] stkutil: Add setup call proactive command parser Yang Gu
2010-05-10 10:39 ` [PATCH 19/19] test-stkutil: Add unit test for setup call parser Yang Gu
2010-05-11 19:24 ` [PATCH 01/19] stkutil: Free default text for get input parser 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=201005111421.27125.denkenz@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.