2014-01-28 13:22:39

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 0/6] Small set of AVCTP fixes

From: Andrei Emeltchenko <[email protected]>

AVCTP issues found during writing test cases.

Andrei Emeltchenko (6):
android/avctp: Use predefined HEADER_LENGTH instead of sizeof
android/avctp: Fix wrong error message
avctp: Use already calculated avc header
avctp: trivial: Do not break short line
avctp: Use predefined HEADER_LENGTH instead of sizeof
avctp: Fix wrong error message

android/avctp.c | 14 +++++++-------
profiles/audio/avctp.c | 17 ++++++++---------
2 files changed, 15 insertions(+), 16 deletions(-)

--
1.8.3.2



2014-01-28 13:22:44

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 5/6] avctp: Use predefined HEADER_LENGTH instead of sizeof

From: Andrei Emeltchenko <[email protected]>

Make code consistent with using HEADER_LENGTH already defined and used
instead of sizeof(). Remove also ugly type conversion.
---
profiles/audio/avctp.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 570d609..0a1a457 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -924,24 +924,24 @@ static gboolean session_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
if (ret <= 0)
goto failed;

- if ((unsigned int) ret < sizeof(struct avctp_header)) {
+ if (ret < AVCTP_HEADER_LENGTH) {
error("Too small AVCTP packet");
goto failed;
}

avctp = (struct avctp_header *) buf;

- ret -= sizeof(struct avctp_header);
- if ((unsigned int) ret < sizeof(struct avc_header)) {
+ ret -= AVCTP_HEADER_LENGTH;
+ if (ret < AVC_HEADER_LENGTH) {
error("Too small AVCTP packet");
goto failed;
}

- avc = (struct avc_header *) (buf + sizeof(struct avctp_header));
+ avc = (struct avc_header *) (buf + AVCTP_HEADER_LENGTH);

- ret -= sizeof(struct avc_header);
+ ret -= AVC_HEADER_LENGTH;

- operands = (uint8_t *) avc + sizeof(struct avc_header);
+ operands = (uint8_t *) avc + AVC_HEADER_LENGTH;
operand_count = ret;

if (avctp->cr == AVCTP_RESPONSE) {
--
1.8.3.2


2014-01-28 13:22:45

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 6/6] avctp: Fix wrong error message

From: Andrei Emeltchenko <[email protected]>

---
profiles/audio/avctp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 0a1a457..9f87859 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -933,7 +933,7 @@ static gboolean session_cb(GIOChannel *chan, GIOCondition cond, gpointer data)

ret -= AVCTP_HEADER_LENGTH;
if (ret < AVC_HEADER_LENGTH) {
- error("Too small AVCTP packet");
+ error("Too small AVC packet");
goto failed;
}

--
1.8.3.2


2014-01-28 13:22:43

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 4/6] avctp: trivial: Do not break short line

From: Andrei Emeltchenko <[email protected]>

---
profiles/audio/avctp.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 78bf1fd..570d609 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -904,8 +904,7 @@ failed:
return FALSE;
}

-static gboolean session_cb(GIOChannel *chan, GIOCondition cond,
- gpointer data)
+static gboolean session_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
{
struct avctp *session = data;
struct avctp_channel *control = session->control;
--
1.8.3.2


2014-01-28 13:22:40

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 1/6] android/avctp: Use predefined HEADER_LENGTH instead of sizeof

From: Andrei Emeltchenko <[email protected]>

Make code consistent with using HEADER_LENGTH defined. Remove also type
conversion.
---
android/avctp.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/android/avctp.c b/android/avctp.c
index 6f9b33b..4ebf2ff 100644
--- a/android/avctp.c
+++ b/android/avctp.c
@@ -818,24 +818,24 @@ static gboolean session_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
if (ret <= 0)
goto failed;

- if ((unsigned int) ret < sizeof(struct avctp_header)) {
+ if (ret < AVCTP_HEADER_LENGTH) {
error("Too small AVCTP packet");
goto failed;
}

avctp = (struct avctp_header *) buf;

- ret -= sizeof(struct avctp_header);
- if ((unsigned int) ret < sizeof(struct avc_header)) {
+ ret -= AVCTP_HEADER_LENGTH;
+ if (ret < AVC_HEADER_LENGTH) {
error("Too small AVCTP packet");
goto failed;
}

- avc = (struct avc_header *) (buf + sizeof(struct avctp_header));
+ avc = (struct avc_header *) (buf + AVCTP_HEADER_LENGTH);

- ret -= sizeof(struct avc_header);
+ ret -= AVC_HEADER_LENGTH;

- operands = (uint8_t *) avc + sizeof(struct avc_header);
+ operands = (uint8_t *) avc + AVC_HEADER_LENGTH;
operand_count = ret;

if (avctp->cr == AVCTP_RESPONSE) {
--
1.8.3.2


2014-01-28 13:22:42

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 3/6] avctp: Use already calculated avc header

From: Andrei Emeltchenko <[email protected]>

This removes long (81 characters) line as a side effect.
---
profiles/audio/avctp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 6fd1454..78bf1fd 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -942,7 +942,7 @@ static gboolean session_cb(GIOChannel *chan, GIOCondition cond,

ret -= sizeof(struct avc_header);

- operands = buf + sizeof(struct avctp_header) + sizeof(struct avc_header);
+ operands = (uint8_t *) avc + sizeof(struct avc_header);
operand_count = ret;

if (avctp->cr == AVCTP_RESPONSE) {
--
1.8.3.2


2014-01-28 13:22:41

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 2/6] android/avctp: Fix wrong error message

From: Andrei Emeltchenko <[email protected]>

---
android/avctp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/avctp.c b/android/avctp.c
index 4ebf2ff..d308ec1 100644
--- a/android/avctp.c
+++ b/android/avctp.c
@@ -827,7 +827,7 @@ static gboolean session_cb(GIOChannel *chan, GIOCondition cond, gpointer data)

ret -= AVCTP_HEADER_LENGTH;
if (ret < AVC_HEADER_LENGTH) {
- error("Too small AVCTP packet");
+ error("Too small AVC packet");
goto failed;
}

--
1.8.3.2