[PATCH 04/15] stkutil: Refactor struct stk_frames_info

Andrzej Zaborowski andrew.zaborowski at intel.com
Fri Jun 11 03:39:49 PDT 2010


---
 src/stkutil.c |   11 +++++++++--
 src/stkutil.h |    4 +++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/stkutil.c b/src/stkutil.c
index 9012234..56c57b1 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -1628,6 +1628,7 @@ static gboolean parse_dataobj_frames_info(struct comprehension_tlv_iter *iter,
 	struct stk_frames_info *fi = user;
 	const unsigned char *data;
 	unsigned char len = comprehension_tlv_iter_get_length(iter);
+	unsigned int i;
 
 	if (len < 1)
 		return FALSE;
@@ -1640,12 +1641,18 @@ static gboolean parse_dataobj_frames_info(struct comprehension_tlv_iter *iter,
 	if ((len == 1 && data[0] != 0) || (len > 1 && data[0] == 0))
 		return FALSE;
 
+	if (len % 2 == 0)
+		return FALSE;
+
 	if (len == 1)
 		return TRUE;
 
 	fi->id = data[0];
-	fi->len = len - 1;
-	memcpy(fi->list, data + 1, fi->len);
+	fi->len = (len - 1) / 2;
+	for (i = 0; i < len; i++) {
+		fi->list[i].height = data[i * 2 + 1] & 0x1f;
+		fi->list[i].width = data[i * 2 + 2] & 0x7f;
+	}
 
 	return TRUE;
 }
diff --git a/src/stkutil.h b/src/stkutil.h
index d5b3c02..d349cca 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -813,7 +813,9 @@ struct stk_frame_layout {
  */
 struct stk_frames_info {
 	unsigned char id;
-	unsigned char list[126];
+	struct {
+		unsigned char width, height;
+	} list[63];
 	unsigned int len;
 };
 
-- 
1.7.1.86.g0e460.dirty



More information about the ofono mailing list