From: Marcel Holtmann <marcel@holtmann.org>
To: Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCHv3 3/4] add 64 bit get_val support
Date: Wed, 19 Oct 2011 08:59:27 -0700 [thread overview]
Message-ID: <1319039969.15441.145.camel@aeonflux> (raw)
In-Reply-To: <20111019075907.GD28113@aemeltch-MOBL1>
Hi Andrei,
> > > > > + case 8:
> > > > > + return btohll(bt_get_unaligned((uint64_t *) ptr));
> > > > > }
> > > > > return 0;
> > > > > }
> > > >
> > > > turning everything into a uint64 is a bit heavy. Just change this into
> > > > broken down version. get_uint64, get_uint32, get_uint16 etc. Otherwise
> > > > you keep casting yourself crazy.
> > >
> > > Yes, casting does not look nice. What about if I keep everything AS IS and
> > > just use btohll(bt_get_unaligned((ptr)) to access 64 bit value.
> >
> > this does not make it more readable. Create helpers like get_uint64 for
> > it.
>
> Is this OK:
>
> --- a/parser/parser.h
> +++ b/parser/parser.h
> ...
> +static inline uint64_t get_uint64(void *ptr)
> +{
> + return btohll(bt_get_unaligned((uint64_t *) ptr));
> +}
> ...
that would be fine with me.
And if you wanna go all out, then you could fix the weird SDP big-endian
conversion/handling that is lingering around the source code and all
parsers for a while now.
Maybe just something like get_le64, get_le32, get_be32 etc. Think about
it a little bit and if you are up for some major cleanup task.
Regards
Marcel
next prev parent reply other threads:[~2011-10-19 15:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-17 8:20 [PATCHv3 0/4] decode fixed channels Emeltchenko Andrei
2011-10-17 8:20 ` [PATCHv3 1/4] add btohll macro Emeltchenko Andrei
2011-10-17 15:32 ` Marcel Holtmann
2011-10-17 8:21 ` [PATCHv3 2/4] add fixed channel definitions Emeltchenko Andrei
2011-10-17 15:29 ` Marcel Holtmann
2011-10-17 8:21 ` [PATCHv3 3/4] add 64 bit get_val support Emeltchenko Andrei
2011-10-17 15:31 ` Marcel Holtmann
2011-10-18 6:33 ` Emeltchenko Andrei
2011-10-18 15:53 ` Marcel Holtmann
2011-10-19 7:59 ` Emeltchenko Andrei
2011-10-19 15:59 ` Marcel Holtmann [this message]
2011-10-17 8:21 ` [PATCHv3 4/4] decode fixed channel list info rsp Emeltchenko Andrei
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=1319039969.15441.145.camel@aeonflux \
--to=marcel@holtmann.org \
--cc=Andrei.Emeltchenko.news@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;
as well as URLs for NNTP newsgroup(s).