linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Stotland, Inga" <inga.stotland@intel.com>
To: "michal.lowas-rzechonek@silvair.com" 
	<michal.lowas-rzechonek@silvair.com>
Cc: "Gix, Brian" <brian.gix@intel.com>,
	"linux-bluetooth@vger.kernel.org"
	<linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH BlueZ] mesh: Correctly generate NetKey list
Date: Thu, 9 Jan 2020 21:37:28 +0000	[thread overview]
Message-ID: <7347c54a1ffa3cf45195b0d8ca53d59613f946b8.camel@intel.com> (raw)
In-Reply-To: <20200109212935.6dn5ivmnupfd5f2d@kynes>

On Thu, 2020-01-09 at 22:29 +0100, michal.lowas-rzechonek@silvair.com
wrote:
> On 01/09, Stotland, Inga wrote:
> > > Please don't use bit shifts for division.
> > Why?
> 
> Because it's a different operation, and is less readable.  It's a
> formula, so use math operators for numbers and bit operators for bits.
> 
> For example, idx_pair <<= 12 is fine, because the *context* is
> bit-packing. Noone sane would write this as idx_pair *= 4096. This
> reasoning applies the other way as well: don't write foo >> 2 where you
> mean foo / 4.

Well, shift is a less expensive operation than a division (I believe,
some compilers may substitute integer division by 2 with a shift).

I don't see any reason not to use >> in this particular case, but I can
change if this is not readable...

> 
> > > Also, I think it's clearer to write this as:
> > >     req_size = num_keys * 3 - num_keys % 2
> > 
> > No, this is not how I read the spec. We need to pack 2 key indices in 3 octets.
> > For example, 4 keys are packed in 6 octets and 5 keys are packed in 8 octets.
> 
> Yes, you're right. Sorry.
> 

  reply	other threads:[~2020-01-09 21:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-09 17:57 [PATCH BlueZ] mesh: Correctly generate NetKey list Inga Stotland
2020-01-09 21:00 ` Michał Lowas-Rzechonek
2020-01-09 21:23   ` Stotland, Inga
     [not found]   ` <31a576190ecbd1ba3f7e779d746baf35815fbed9.camel@intel.com>
2020-01-09 21:29     ` michal.lowas-rzechonek
2020-01-09 21:37       ` Stotland, Inga [this message]
2020-01-09 21:55         ` michal.lowas-rzechonek
2020-01-09 21:08 ` Michał Lowas-Rzechonek
     [not found]   ` <d831f4046203d691b65bf145909cdc184bc788e9.camel@intel.com>
2020-01-09 21:23     ` michal.lowas-rzechonek

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=7347c54a1ffa3cf45195b0d8ca53d59613f946b8.camel@intel.com \
    --to=inga.stotland@intel.com \
    --cc=brian.gix@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=michal.lowas-rzechonek@silvair.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 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).