All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 10/23] avrcp: handle GetCurrentPlayerAplicationSettingValue pdu
Date: Mon, 8 Aug 2011 17:02:13 +0300	[thread overview]
Message-ID: <20110808140213.GA23380@dell> (raw)
In-Reply-To: <CAMOw1v7xvyYO6VA33kZ_VYM=yYzZ+e703xOEDaE7nWmHmkLyig@mail.gmail.com>

Hi Lucas,

On Mon, Aug 08, 2011, Lucas De Marchi wrote:
> >> +static int avrcp_handle_get_current_player_value(struct control *control,
> >> +                                               struct avrcp_spec_avc_pdu *pdu)
> >> +{
> >> +       uint16_t len = ntohs(pdu->params_len);
> >> +       struct media_player *mp = control->mp;
> >> +
> >> +       if (!mp)
> >> +               goto done;
> >> +
> >> +       if (len > 1 && pdu->params[0] == len - 1) {
> >
> > This if statement is quite long, perhaps you could do check the
> > opposite e.g. if (len <=1 || pdu->params[0] != len - 1) goto done;
> 
> In all other parts of the code I do like you said because it's much
> cleaner. Here however I can't because of the following declaration:
> 
> >> +               uint8_t settings[pdu->params[0]];
> 
> It depends on the value of pdu->params[0]

Actually Luiz should have objected to that even more than to the coding
style. I don't think we use anywhere else array size initializers which
are not determinable upon compile time (I suppose this is also a very
recent C feature?). Furthermore, since these values are coming from the
remote side you're effectively allowing them to to "explode" our stack
here. So, dynamically allocating memory from the heap would be a (much)
better idea in this case (and then you can easily use the coding style
fix suggested by Luiz).

Johan

  reply	other threads:[~2011-08-08 14:02 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-05 18:15 [PATCH 01/23] audio: move interface declarations to their headers Lucas De Marchi
2011-08-05 18:15 ` [PATCH 02/23] avrcp: use C99 instead of gcc extension Lucas De Marchi
2011-08-08  8:41   ` Luiz Augusto von Dentz
2011-08-08 13:50     ` Lucas De Marchi
2011-08-05 18:15 ` [PATCH 03/23] avrcp: add skeleton of MediaPlayer interface Lucas De Marchi
2011-08-05 18:15 ` [PATCH 04/23] avrcp: implement ChangeSetting() method of MediaPlayer Lucas De Marchi
2011-08-05 18:15 ` [PATCH 05/23] avrcp: implement ChangePlayback() method Lucas De Marchi
2011-08-05 18:15 ` [PATCH 06/23] avrcp: implement ChangeTrack() method Lucas De Marchi
2011-08-05 18:15 ` [PATCH 07/23] avrcp: handle query for company ids Lucas De Marchi
2011-08-05 18:15 ` [PATCH 08/23] avrcp: handle ListPlayerApplicationSettingAttributes pdu Lucas De Marchi
2011-08-05 18:15 ` [PATCH 09/23] avrcp: handle ListPlayerApplicationSettingValues pdu Lucas De Marchi
2011-08-05 18:15 ` [PATCH 10/23] avrcp: handle GetCurrentPlayerAplicationSettingValue pdu Lucas De Marchi
2011-08-08  8:08   ` Luiz Augusto von Dentz
2011-08-08 13:49     ` Lucas De Marchi
2011-08-08 14:02       ` Johan Hedberg [this message]
2011-08-08 14:07         ` Lucas De Marchi
2011-08-05 18:15 ` [PATCH 11/23] avrcp: handle SetPlayerApplicationSettingValue pdu Lucas De Marchi
2011-08-08  8:31   ` Luiz Augusto von Dentz
2011-08-08 14:03     ` Lucas De Marchi
2011-08-08 18:58     ` Lucas De Marchi
2011-08-05 18:15 ` [PATCH 12/23] avrcp: handle commands for future extension Lucas De Marchi
2011-08-05 18:15 ` [PATCH 13/23] avrcp: handle InformDisplayableCharacterSet pdu Lucas De Marchi
2011-08-05 18:15 ` [PATCH 14/23] avrcp: handle InformBatteryStatusOfCT pdu Lucas De Marchi
2011-08-05 18:15 ` [PATCH 15/23] avrcp: handle GetPlayStatus pdu Lucas De Marchi
2011-08-05 18:15 ` [PATCH 16/23] avrcp: handle RegisterNotification pdu Lucas De Marchi
2011-08-08  7:54   ` Luiz Augusto von Dentz
2011-08-05 18:15 ` [PATCH 17/23] avrcp: handle query for supported events Lucas De Marchi
2011-08-05 18:15 ` [PATCH 18/23] avrcp: handle GetElementAttributes pdu Lucas De Marchi
2011-08-05 18:15 ` [PATCH 19/23] avrcp: send response for registered events Lucas De Marchi
2011-08-05 18:15 ` [PATCH 20/23] avrcp: change TG record to use version 1.3 Lucas De Marchi
2011-08-05 18:15 ` [PATCH 21/23] avrcp: update copyright Lucas De Marchi
2011-08-05 18:15 ` [PATCH 22/23] Add script to test control interface Lucas De Marchi
2011-08-05 18:15 ` [PATCH 23/23] Update Control documentation Lucas De Marchi

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=20110808140213.GA23380@dell \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=lucas.demarchi@profusion.mobi \
    --cc=luiz.dentz@gmail.com \
    /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.