All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, clemens@ladisch.de,
	ffado-devel@lists.sf.net
Subject: Re: [PATCH 2/3] ALSA: tascam: improve loop condition to filling MIDI bytes in transaction
Date: Sun, 18 Oct 2015 21:13:08 +0900	[thread overview]
Message-ID: <56238CD4.30900@sakamocchi.jp> (raw)
In-Reply-To: <s5h7fmkbd4r.wl-tiwai@suse.de>

On Oct 18 2015 21:00, Takashi Iwai wrote:
> On Sun, 18 Oct 2015 12:51:33 +0200,
> Takashi Sakamoto wrote:
>>
>> On Oct 18 2015 19:10, Takashi Iwai wrote:
>>> On Sun, 18 Oct 2015 12:02:17 +0200,
>>> Takashi Sakamoto wrote:
>>>>
>>>> It includes meaningless condition. This commit improve it.
>>>>
>>>> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
>>>> ---
>>>>  sound/firewire/tascam/tascam-transaction.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/sound/firewire/tascam/tascam-transaction.c b/sound/firewire/tascam/tascam-transaction.c
>>>> index 7fcee81..4ffaa8a 100644
>>>> --- a/sound/firewire/tascam/tascam-transaction.c
>>>> +++ b/sound/firewire/tascam/tascam-transaction.c
>>>> @@ -74,7 +74,7 @@ static int fill_message(struct snd_rawmidi_substream *substream, u8 *buf)
>>>>  	/* On exclusive message. */
>>>>  	if (tscm->on_sysex[port]) {
>>>>  		/* Seek the end of exclusives. */
>>>> -		for (i = 1; i < 4 || i < len; ++i) {
>>>> +		for (i = 1; i < len + 1; ++i) {
>>>
>>> This doesn't look like an improvement...
>>> The fix should be rather like:
>>> 		for (i = 1; i < 4 && i < len; ++i) {
>>
>> The 'len' variable is assigned to the return value of
>> snd_rawmidi_transmit_peek(). The third argument to call this function is
>> 3, thus the value of this variable equals to or is less than 3.
>>
>> The aim of this loop is to find EOX (end of exclusive) byte in retrieved
>> bytes, then break the loop.The index goes from 1 to the end of retrieved
>> bytes. Thus, 'i < 4 || i < len' is not so proper, here.
> 
> Then the patch description is incorrect.  You actually fix something
> that was a buggy behavior.

It's not so buggy behaviour because the loop continue to seek the buffer
till its end (4th byte), always. But this is against my intention to
stop the seek in the end of retrieved byte.

Anyway, the code is not good.

> Overall, the code is confusing because the real data buffer begins at
> offset 1 and len doesn't mean the size of the values written to buf[].
> Maybe it's better to be like:
> 	char *msg = buf + 1;
> 
> and use msg[x] instead of buf[1+x].  Then len really corresponds to
> the size of msg[].

That's a good idea. OK, I'll post the revised version, later.


Thanks

Takashi Sakamoto

  reply	other threads:[~2015-10-18 12:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-18 10:02 [PATCH 0/3] fix sending the same MIDI bytes in two transactions Takashi Sakamoto
2015-10-18 10:02 ` [PATCH 1/3] ALSA: tascam: remove buffer initialization in driver side Takashi Sakamoto
2015-10-18 10:02 ` [PATCH 2/3] ALSA: tascam: improve loop condition to filling MIDI bytes in transaction Takashi Sakamoto
2015-10-18 10:10   ` Takashi Iwai
2015-10-18 10:51     ` Takashi Sakamoto
2015-10-18 12:00       ` Takashi Iwai
2015-10-18 12:13         ` Takashi Sakamoto [this message]
2015-10-18 10:02 ` [PATCH 3/3] ALSA: tascam: clear extra MIDI byte of asynchronous transaction Takashi Sakamoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56238CD4.30900@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=ffado-devel@lists.sf.net \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.