2010-10-15 06:57:06

by Dmitriy Paliy

[permalink] [raw]
Subject: [PATCH 0/2] Fix regression on suspend on opening

Hi,

This fixes regression when doing suspend on opening obex stream. If
obex_write_stream returns length of buffer, it is treated as an error
response later on, which is not correct.

Negative values returned by obex_write_stream are error codes, while
positive ones mean length of buffer. Positive values are never used
afterwards in the code. Therefore, due to this reason, and for being
compliant with obex_read_stream, which also returns 0 only, it was
decided to remove return of positive value representing length at all.

Result of such is also some code cleanup that removes unnecessary return
len when it is zero.

A typo is fixed in comments as well.

Br,
Dmitriy



2010-10-15 07:21:53

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH 0/2] Fix regression on suspend on opening

Hi Dmitriy,

On Fri, Oct 15, 2010, Dmitriy Paliy wrote:
> This fixes regression when doing suspend on opening obex stream. If
> obex_write_stream returns length of buffer, it is treated as an error
> response later on, which is not correct.
>
> Negative values returned by obex_write_stream are error codes, while
> positive ones mean length of buffer. Positive values are never used
> afterwards in the code. Therefore, due to this reason, and for being
> compliant with obex_read_stream, which also returns 0 only, it was
> decided to remove return of positive value representing length at all.
>
> Result of such is also some code cleanup that removes unnecessary return
> len when it is zero.
>
> A typo is fixed in comments as well.

Both patches have been pushed upstream. Thanks. Btw, don't be afraid to
put this kind of explanations in the commit messages themselves since
that info is easier to find in a couple of years time than this cover
letter email.

Johan

2010-10-15 06:57:07

by Dmitriy Paliy

[permalink] [raw]
Subject: [PATCH 1/2] Fix regression on suspend on opening

This fixes regression on suspend on opening when obex_write_stream
returns length of buffer, which is treated as error response
afterwards.
---
src/obex.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/obex.c b/src/obex.c
index d1ac339..4e1db9c 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -683,7 +683,7 @@ add_header:

os->offset += len;

- return len;
+ return 0;
}

static gboolean handle_async_io(void *object, int flags, int err,
--
1.7.0.4


2010-10-15 06:57:08

by Dmitriy Paliy

[permalink] [raw]
Subject: [PATCH 2/2] Code cleanup: unnecessary operation and typo removed

Code cleanup: unnecessary operation 'return len;' removed and typo in
comments immidiately to immediately corrected.
---
src/obex.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/obex.c b/src/obex.c
index 4e1db9c..adfcc95 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -678,7 +678,6 @@ add_header:
if (len == 0) {
g_free(os->buf);
os->buf = NULL;
- return len;
}

os->offset += len;
@@ -818,7 +817,7 @@ static void cmd_get(struct obex_session *os, obex_t *obex, obex_object_t *obj)
OBEX_ObjectAddHeader (obex, obj, OBEX_HDR_BODY,
hd, 0, OBEX_FL_STREAM_START);

- /* Try to write to stream and suspend the stream immidiately
+ /* Try to write to stream and suspend the stream immediately
* if no data available to send. */
err = obex_write_stream(os, obex, obj);
if (err == -EAGAIN) {
--
1.7.0.4