summaryrefslogtreecommitdiffstats
path: root/src/stkutil.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-03-23 12:31:00 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-03-23 12:31:00 -0500
commit5609034d975b7f114dc076db01dce18dc81c96fc (patch)
treec50bbb0487e0236e3ec77a63d2d305774acba7bf /src/stkutil.c
parent0ef68e31e24a55910804e296644621af3f842ec6 (diff)
downloadofono-5609034d975b7f114dc076db01dce18dc81c96fc.tar.bz2
Style: Fixup some style issues
- Large if statements should be handled as switchcase - Avoid initialization of variables, even if code needs to be rearranged
Diffstat (limited to 'src/stkutil.c')
-rw-r--r--src/stkutil.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/stkutil.c b/src/stkutil.c
index 833073b1..9c83f493 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -424,9 +424,9 @@ static gboolean parse_dataobj_file_list(struct comprehension_tlv_iter *iter,
const unsigned char *data;
unsigned int len;
unsigned int i;
- unsigned int start = 0;
+ unsigned int start;
struct stk_file *sf;
- unsigned char last_type = 0x2f;
+ unsigned char last_type;
if (comprehension_tlv_iter_get_tag(iter) !=
STK_DATA_OBJECT_TYPE_FILE_LIST)
@@ -438,7 +438,14 @@ static gboolean parse_dataobj_file_list(struct comprehension_tlv_iter *iter,
data = comprehension_tlv_iter_get_data(iter);
- for (i = 1; i < len; i += 2) {
+ /* SIM EFs always start with ROOT MF, 0x3f */
+ if (data[1] != 0x3f)
+ return FALSE;
+
+ start = 1;
+ last_type = 0x3f;
+
+ for (i = 3; i < len; i += 2) {
/* Check the validity of file type.
* According to TS 11.11, each file id contains of two bytes,
* in which the first byte is the type of file. For GSM is:
@@ -449,28 +456,38 @@ static gboolean parse_dataobj_file_list(struct comprehension_tlv_iter *iter,
* 0x6f: elementary file under 1st level dedicated file
* 0x4f: elementary file under 2nd level dedicated file
*/
- if (data[i] == 0x3f) {
+ switch (data[i]) {
+ case 0x3f:
if ((last_type != 0x2f) && (last_type != 0x6f) &&
- (last_type != 0x4f))
+ (last_type != 0x4f))
goto error;
+
start = i;
- } else if (data[i] == 0x2f) {
+
+ break;
+ case 0x2f:
if (last_type != 0x3f)
goto error;
- } else if (data[i] == 0x6f) {
+ break;
+ case 0x6f:
if (last_type != 0x7f)
goto error;
- } else if (data[i] == 0x4f) {
+ break;
+ case 0x4f:
if (last_type != 0x5f)
goto error;
- } else if (data[i] == 0x7f) {
+ break;
+ case 0x7f:
if (last_type != 0x3f)
goto error;
- } else if (data[i] == 0x5f) {
+ break;
+ case 0x5f:
if (last_type != 0x7f)
goto error;
- } else
+ break;
+ default:
goto error;
+ }
if ((data[i] == 0x2f) || (data[i] == 0x6f) ||
(data[i] == 0x4f)) {