All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 0/2] Minor MIDI profile improvements
@ 2017-02-07 23:40 Felipe F. Tonello
  2017-02-07 23:40 ` [PATCH BlueZ 1/2] profiles/midi: Add safer buffer setter function Felipe F. Tonello
  2017-02-07 23:40 ` [PATCH BlueZ 2/2] profiles/midi: Moved MIDI UUIDs to library header Felipe F. Tonello
  0 siblings, 2 replies; 5+ messages in thread
From: Felipe F. Tonello @ 2017-02-07 23:40 UTC (permalink / raw)
  To: linux-bluetooth

Minor improvements that doesn't have any affect in functionality.

Felipe F. Tonello (2):
  profiles/midi: Add safer buffer setter function
  profiles/midi: Moved MIDI UUIDs to library header

 profiles/midi/libmidi.c | 9 ++++++++-
 profiles/midi/libmidi.h | 3 +++
 profiles/midi/midi.c    | 3 ---
 3 files changed, 11 insertions(+), 4 deletions(-)

-- 
2.11.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH BlueZ 1/2] profiles/midi: Add safer buffer setter function
  2017-02-07 23:40 [PATCH BlueZ 0/2] Minor MIDI profile improvements Felipe F. Tonello
@ 2017-02-07 23:40 ` Felipe F. Tonello
  2017-02-08 12:45   ` Luiz Augusto von Dentz
  2017-02-07 23:40 ` [PATCH BlueZ 2/2] profiles/midi: Moved MIDI UUIDs to library header Felipe F. Tonello
  1 sibling, 1 reply; 5+ messages in thread
From: Felipe F. Tonello @ 2017-02-07 23:40 UTC (permalink / raw)
  To: linux-bluetooth

This function helper makes buffer operations more consistent and adds
boundary check when its available.

Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
---
 profiles/midi/libmidi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/profiles/midi/libmidi.c b/profiles/midi/libmidi.c
index ac090b59eb60..4b4df799fc2e 100644
--- a/profiles/midi/libmidi.c
+++ b/profiles/midi/libmidi.c
@@ -52,6 +52,13 @@ inline static uint8_t buffer_reverse_get(struct midi_buffer *buffer, size_t i)
 	return buffer->data[buffer->len - (i + 1)];
 }
 
+inline static void buffer_reverse_set(struct midi_buffer *buffer, size_t i,
+                                      const uint8_t byte)
+{
+	MIDI_ASSERT(buffer->len > i);
+	buffer->data[buffer->len - (i + 1)] = byte;
+}
+
 inline static size_t parser_get_available_size(struct midi_write_parser *parser)
 {
 	return parser->stream_size - parser->midi_stream.len;
@@ -314,7 +321,7 @@ static size_t handle_end_of_sysex(struct midi_read_parser *parser,
 	time_low = buffer_reverse_get(&parser->sysex_stream, 0) & 0x7F;
 
 	/* Remove timestamp byte */
-	parser->sysex_stream.data[parser->sysex_stream.len - 1] = 0xF7;
+	buffer_reverse_set(&parser->sysex_stream, 0, 0xF7);
 
 	/* Update event */
 	update_ev_timestamp(parser, ev, time_low);
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ 2/2] profiles/midi: Moved MIDI UUIDs to library header
  2017-02-07 23:40 [PATCH BlueZ 0/2] Minor MIDI profile improvements Felipe F. Tonello
  2017-02-07 23:40 ` [PATCH BlueZ 1/2] profiles/midi: Add safer buffer setter function Felipe F. Tonello
@ 2017-02-07 23:40 ` Felipe F. Tonello
  1 sibling, 0 replies; 5+ messages in thread
From: Felipe F. Tonello @ 2017-02-07 23:40 UTC (permalink / raw)
  To: linux-bluetooth

This allows other users of libmidi to consistently use MIDI UUIDs.

Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
---
 profiles/midi/libmidi.h | 3 +++
 profiles/midi/midi.c    | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/profiles/midi/libmidi.h b/profiles/midi/libmidi.h
index 7078fb4a690b..9d94065b60c0 100644
--- a/profiles/midi/libmidi.h
+++ b/profiles/midi/libmidi.h
@@ -29,6 +29,9 @@
 #include <stdbool.h>
 #include <alsa/asoundlib.h>
 
+#define MIDI_UUID "03B80E5A-EDE8-4B33-A751-6CE34EC4C700"
+#define MIDI_IO_UUID "7772E5DB-3868-4112-A1A9-F2669D106BF3"
+
 #define MIDI_MAX_TIMESTAMP 8191
 #define MIDI_MSG_MAX_SIZE 12
 #define MIDI_SYSEX_MAX_SIZE (4 * 1024)
diff --git a/profiles/midi/midi.c b/profiles/midi/midi.c
index d12b4cf29818..fdc1c007da1c 100644
--- a/profiles/midi/midi.c
+++ b/profiles/midi/midi.c
@@ -53,9 +53,6 @@
 
 #include "libmidi.h"
 
-#define MIDI_UUID "03B80E5A-EDE8-4B33-A751-6CE34EC4C700"
-#define MIDI_IO_UUID "7772E5DB-3868-4112-A1A9-F2669D106BF3"
-
 struct midi {
 	struct btd_device *dev;
 	struct gatt_db *db;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH BlueZ 1/2] profiles/midi: Add safer buffer setter function
  2017-02-07 23:40 ` [PATCH BlueZ 1/2] profiles/midi: Add safer buffer setter function Felipe F. Tonello
@ 2017-02-08 12:45   ` Luiz Augusto von Dentz
  2017-02-09 14:46     ` Felipe Ferreri Tonello
  0 siblings, 1 reply; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2017-02-08 12:45 UTC (permalink / raw)
  To: Felipe F. Tonello; +Cc: linux-bluetooth

Hi Felipe,

On Wed, Feb 8, 2017 at 1:40 AM, Felipe F. Tonello <eu@felipetonello.com> wrote:
> This function helper makes buffer operations more consistent and adds
> boundary check when its available.
>
> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>

We don't use Signed-off-by on userspace, please remove it.

> ---
>  profiles/midi/libmidi.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/profiles/midi/libmidi.c b/profiles/midi/libmidi.c
> index ac090b59eb60..4b4df799fc2e 100644
> --- a/profiles/midi/libmidi.c
> +++ b/profiles/midi/libmidi.c
> @@ -52,6 +52,13 @@ inline static uint8_t buffer_reverse_get(struct midi_buffer *buffer, size_t i)
>         return buffer->data[buffer->len - (i + 1)];
>  }
>
> +inline static void buffer_reverse_set(struct midi_buffer *buffer, size_t i,
> +                                      const uint8_t byte)
> +{
> +       MIDI_ASSERT(buffer->len > i);
> +       buffer->data[buffer->len - (i + 1)] = byte;
> +}
> +
>  inline static size_t parser_get_available_size(struct midi_write_parser *parser)
>  {
>         return parser->stream_size - parser->midi_stream.len;
> @@ -314,7 +321,7 @@ static size_t handle_end_of_sysex(struct midi_read_parser *parser,
>         time_low = buffer_reverse_get(&parser->sysex_stream, 0) & 0x7F;
>
>         /* Remove timestamp byte */
> -       parser->sysex_stream.data[parser->sysex_stream.len - 1] = 0xF7;
> +       buffer_reverse_set(&parser->sysex_stream, 0, 0xF7);
>
>         /* Update event */
>         update_ev_timestamp(parser, ev, time_low);
> --
> 2.11.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH BlueZ 1/2] profiles/midi: Add safer buffer setter function
  2017-02-08 12:45   ` Luiz Augusto von Dentz
@ 2017-02-09 14:46     ` Felipe Ferreri Tonello
  0 siblings, 0 replies; 5+ messages in thread
From: Felipe Ferreri Tonello @ 2017-02-09 14:46 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

[-- Attachment #1: Type: text/plain, Size: 1959 bytes --]

Hi Luiz,

On 08/02/17 12:45, Luiz Augusto von Dentz wrote:
> Hi Felipe,
> 
> On Wed, Feb 8, 2017 at 1:40 AM, Felipe F. Tonello <eu@felipetonello.com> wrote:
>> This function helper makes buffer operations more consistent and adds
>> boundary check when its available.
>>
>> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
> 
> We don't use Signed-off-by on userspace, please remove it.

Sure, I forgot this...

> 
>> ---
>>  profiles/midi/libmidi.c | 9 ++++++++-
>>  1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/profiles/midi/libmidi.c b/profiles/midi/libmidi.c
>> index ac090b59eb60..4b4df799fc2e 100644
>> --- a/profiles/midi/libmidi.c
>> +++ b/profiles/midi/libmidi.c
>> @@ -52,6 +52,13 @@ inline static uint8_t buffer_reverse_get(struct midi_buffer *buffer, size_t i)
>>         return buffer->data[buffer->len - (i + 1)];
>>  }
>>
>> +inline static void buffer_reverse_set(struct midi_buffer *buffer, size_t i,
>> +                                      const uint8_t byte)
>> +{
>> +       MIDI_ASSERT(buffer->len > i);
>> +       buffer->data[buffer->len - (i + 1)] = byte;
>> +}
>> +
>>  inline static size_t parser_get_available_size(struct midi_write_parser *parser)
>>  {
>>         return parser->stream_size - parser->midi_stream.len;
>> @@ -314,7 +321,7 @@ static size_t handle_end_of_sysex(struct midi_read_parser *parser,
>>         time_low = buffer_reverse_get(&parser->sysex_stream, 0) & 0x7F;
>>
>>         /* Remove timestamp byte */
>> -       parser->sysex_stream.data[parser->sysex_stream.len - 1] = 0xF7;
>> +       buffer_reverse_set(&parser->sysex_stream, 0, 0xF7);
>>
>>         /* Update event */
>>         update_ev_timestamp(parser, ev, time_low);
>> --
>> 2.11.0
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> 

-- 
Felipe

[-- Attachment #2: 0x92698E6A.asc --]
[-- Type: application/pgp-keys, Size: 7177 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-02-09 14:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-07 23:40 [PATCH BlueZ 0/2] Minor MIDI profile improvements Felipe F. Tonello
2017-02-07 23:40 ` [PATCH BlueZ 1/2] profiles/midi: Add safer buffer setter function Felipe F. Tonello
2017-02-08 12:45   ` Luiz Augusto von Dentz
2017-02-09 14:46     ` Felipe Ferreri Tonello
2017-02-07 23:40 ` [PATCH BlueZ 2/2] profiles/midi: Moved MIDI UUIDs to library header Felipe F. Tonello

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.