From: Peter Dons Tychsen <donpedro@tdcadsl.dk>
To: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Anderson Lizardo <anderson.lizardo@openbossa.org>,
linux-bluetooth@vger.kernel.org
Subject: Re: [PATCHv2 2/5] Initial Client Characteristic Configuration implementation
Date: Mon, 07 Mar 2011 21:52:24 +0100 [thread overview]
Message-ID: <1299531144.2688.9.camel@donpedro> (raw)
In-Reply-To: <20110223032608.GE16014@jh-x301>
Hi,
On Wed, 2011-02-23 at 00:26 -0300, Johan Hedberg wrote:
> On Tue, Feb 22, 2011, Anderson Lizardo wrote:
> > +static uint8_t client_set_notifications(struct attribute *attr,
> > + gpointer
> user_data)
> > +{
> > + struct gatt_channel *channel = user_data;
> > + struct attribute *a, *last_chr_val = NULL;
> > + uint16_t handle, cfg_val;
> > + uuid_t uuid;
> > + GSList *l;
> > +
> > + cfg_val = att_get_u16(attr->data);
> > +
> > + sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
> > + for (l = database, handle = 0; l != NULL; l = l->next) {
> > + a = l->data;
>
> The variable "a" is only used inside the for-loop so it should be
> declared inside it as well. I think you can move handle inside the
> loop
> as well as long as you declare it static (so it only gets initialized
> to
> 0 on the first iteration).
Would that not be a waste? Declaring it static would place it in
global-space. IMHO local variables must never be static, unless there
really is a need for it. For embedded devices with less memory, to many
of such constructs would be considered a problem.
Putting it inside or outside the loops makes no difference with most
compilers as the optimizer will figure it out anyway (to the code, not
the style), but putting static in front will change the output and will
lower the global memory available. And since the number of used
instructions most likely will be the same, putting static in front will
at best be a waste.
Thanks,
/pedro
next prev parent reply other threads:[~2011-03-07 20:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-21 21:30 [PATCH 1/5] Add read/write callbacks to attribute server Anderson Lizardo
2011-02-21 21:30 ` [PATCH 2/5] Initial Client Characteristic Configuration implementation Anderson Lizardo
2011-02-21 21:30 ` [PATCH 3/5] Check permissions before setting client configs Anderson Lizardo
2011-02-21 21:30 ` [PATCH 4/5] Implement server-side ATT handle notification Anderson Lizardo
2011-02-21 21:30 ` [PATCH 5/5] Implement ATT handle indication Anderson Lizardo
2011-02-22 21:01 ` [PATCHv2 1/5] Add read/write callbacks to attribute server Anderson Lizardo
2011-02-23 3:21 ` Johan Hedberg
2011-02-23 14:28 ` Anderson Lizardo
2011-02-23 15:14 ` [PATCH v3 " Anderson Lizardo
2011-02-23 15:14 ` [PATCH v3 2/5] Initial Client Characteristic Configuration implementation Anderson Lizardo
2011-02-23 15:14 ` [PATCH v3 3/5] Check properties before setting client configs Anderson Lizardo
2011-02-23 15:14 ` [PATCH v3 4/5] Implement server-side ATT handle notification Anderson Lizardo
2011-02-23 15:14 ` [PATCH v3 5/5] Implement ATT handle indication Anderson Lizardo
2011-02-24 19:10 ` Johan Hedberg
2011-02-22 21:01 ` [PATCHv2 2/5] Initial Client Characteristic Configuration implementation Anderson Lizardo
2011-02-23 3:26 ` Johan Hedberg
2011-02-23 14:29 ` Anderson Lizardo
2011-03-07 20:52 ` Peter Dons Tychsen [this message]
2011-02-22 21:01 ` [PATCHv2 3/5] Check permissions before setting client configs Anderson Lizardo
2011-02-22 21:01 ` [PATCHv2 4/5] Implement server-side ATT handle notification Anderson Lizardo
2011-02-22 21:01 ` [PATCHv2 5/5] Implement ATT handle indication Anderson Lizardo
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=1299531144.2688.9.camel@donpedro \
--to=donpedro@tdcadsl.dk \
--cc=anderson.lizardo@openbossa.org \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox