[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] 6310i ToDo writing improved
From: |
Balint Reczey |
Subject: |
Re: [PATCH] 6310i ToDo writing improved |
Date: |
Sun, 19 Dec 2004 19:31:25 +0000 (GMT) |
--- Pawel Kot <address@hidden> wrote:
> On Sun, 19 Dec 2004, Balint Reczey wrote:
>
> Hi,
>
> > This patch hopefully fixes ToDo writing.
> > The previous patch did not fix all problems, the
> phone
> > appended memory random characters to todo texts
> even
> > after patching.
> > 0x0E, /* length of
> text + 1*/
> I need to test this on other phones. I didn't have
> such problems with my
> 6310 but will verify that.
> > req[10 + length ] = '\0'; // kind of
> padding
> > req[10 + length + 1] = '\0'; //
> Looks ugly. Very ugly. Why do you need both fields
> zeroed? Perhaps it's
Probably beacause of the two byte unicode format.
I dont't have protocol definition, but sending just
one byte padding caused an appended random character
after the todo text.
> better to zero all req[] table. Or at least:
Zeroing all values is obsolete since sm_message_send()
does not send them.
> req[10+length] = req[11+length] = 0;
> looks much nicer.
:-).
> > free(req);
> Looks very incorrect to me. req is allocated
> statically and I belive it
> will segfault is most cases.
Mea culpa, it was left from a test.
Balint
___________________________________________________________
Win a castle for NYE with your mates and Yahoo! Messenger
http://uk.messenger.yahoo.com
Index: gnokii/common/phones/nk6510.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/phones/nk6510.c,v
retrieving revision 1.160
diff -u -r1.160 nk6510.c
--- gnokii/common/phones/nk6510.c 19 Dec 2004 15:34:34 -0000 1.160
+++ gnokii/common/phones/nk6510.c 19 Dec 2004 19:00:18 -0000
@@ -4105,7 +4105,9 @@
{
unsigned char req[300] = {FBUS_FRAME_HEADER, 0x01,
0x02, /* prority */
- 0x0D, 0x80, 0x00, 0x00, 0x01}; /*
Location */
+ 0x0E, /* length of text + 1*/
+ 0x80, 0x00,
+ 0x00, 0x01}; /* Location */
unsigned char text[257];
int length;
gn_error error;
@@ -4118,10 +4120,17 @@
req[9] = data->todo->location % 256;
length = char_unicode_encode(text, data->todo->text,
strlen(data->todo->text));
+
+ if (length > GN_TODO_MAX_LENGTH) return GN_ERR_ENTRYTOOLONG;
+
+ req[5] = length + 1;
+
memcpy(req + 10, text, length);
-
+
+ req[10 + length ] = '\0'; // kind of padding
+ req[10 + length + 1] = '\0'; //
dprintf("Setting ToDo\n");
- if (sm_message_send(length, NK6510_MSG_TODO, req, state)) return
GN_ERR_NOTREADY;
+ if (sm_message_send(length+12, NK6510_MSG_TODO, req, state)) return
GN_ERR_NOTREADY;
error = sm_block(NK6510_MSG_TODO, data, state);
if (error == GN_ERR_NONE) {
error = NK6510_GetToDo_Internal(data, state,
data->todo->location);