All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Szymon Janc <szymon.janc@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 06/18] adapter: Handle missing randomizer in btd_adapter_add_remote_oob_data
Date: Fri, 21 Sep 2012 13:17:23 +0300	[thread overview]
Message-ID: <20120921101723.GA4441@x220> (raw)
In-Reply-To: <1348221750-15345-7-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Fri, Sep 21, 2012, Szymon Janc wrote:
> Randomizer is optional. Handling missing randomizer in
> btd_adapter_add_remote_oob_data is easy and will simplify caller code.
> 
> ---
>  plugins/dbusoob.c |    7 -------
>  src/adapter.c     |    7 +++++++
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
> index a66c21d..ce9e5d4 100644
> --- a/plugins/dbusoob.c
> +++ b/plugins/dbusoob.c
> @@ -233,13 +233,6 @@ static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
>  	adapter_get_address(adapter, &local);
>  
>  	if (data->hash) {
> -		uint8_t empty_randomizer[16];
> -
> -		if (!data->randomizer) {
> -			memset(empty_randomizer, 0, sizeof(empty_randomizer));
> -			data->randomizer = empty_randomizer;
> -		}
> -
>  		if (btd_adapter_add_remote_oob_data(adapter, &bdaddr,
>  					data->hash, data->randomizer) < 0)
>  			return FALSE;
> diff --git a/src/adapter.c b/src/adapter.c
> index d34e966..a00522a 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -3574,6 +3574,13 @@ int btd_adapter_read_local_oob_data(struct btd_adapter *adapter)
>  int btd_adapter_add_remote_oob_data(struct btd_adapter *adapter,
>  			bdaddr_t *bdaddr, uint8_t *hash, uint8_t *randomizer)
>  {
> +	uint8_t empty_randomizer[16];
> +
> +	if (!randomizer) {
> +		memset(empty_randomizer, 0, sizeof(empty_randomizer));
> +		randomizer = empty_randomizer;
> +	}
> +
>  	return mgmt_add_remote_oob_data(adapter->dev_id, bdaddr, hash,
>  								randomizer);

I'd rather have mgmt_add_remote_oob_data accept a NULL pointer and have
the randomizer memcpy behind a NULL test (the code is anyway already
initializing the send buffer to zeros).

Johan

  reply	other threads:[~2012-09-21 10:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-21 10:02 [PATCH 00/18] neard plugin Szymon Janc
2012-09-21 10:02 ` [PATCH 01/18] Add initial neard plugin implementation Szymon Janc
2012-09-21 10:02 ` [PATCH 02/18] eir: Add support for parsing SSP hash and randomizer Szymon Janc
2012-09-21 10:02 ` [PATCH 03/18] eir: Store class in struct eir_data as uint32_t Szymon Janc
2012-09-21 10:02 ` [PATCH 04/18] eir: Add eir_parse_oob function Szymon Janc
2012-09-21 10:02 ` [PATCH 05/18] oob: Allow to register pairing complete callback Szymon Janc
2012-09-21 10:02 ` [PATCH 06/18] adapter: Handle missing randomizer in btd_adapter_add_remote_oob_data Szymon Janc
2012-09-21 10:17   ` Johan Hedberg [this message]
2012-09-21 10:42     ` Szymon Janc
2012-09-21 10:46   ` [PATCH v2 06/18] Handle missing randomizer in mgmt_add_remote_oob_data Szymon Janc
2012-09-21 10:02 ` [PATCH 07/18] neard: Implement PushOOB function Szymon Janc
2012-09-21 10:02 ` [PATCH 08/18] eir: Add support creating EIR with hash and randomizer fields Szymon Janc
2012-09-21 10:02 ` [PATCH 09/18] eir: Add support for creating EIR with CoD field Szymon Janc
2012-09-21 10:02 ` [PATCH 10/18] eir: Rename eir_create to eir_create_oob Szymon Janc
2012-09-21 10:02 ` [PATCH 11/18] eir: Remove support for creating EIR with tx_power fields Szymon Janc
2012-09-21 10:02 ` [PATCH 12/18] eir: Return number of bytes written by eir_create_oob Szymon Janc
2012-09-21 10:02 ` [PATCH 13/18] eir: Remove struct uuid_info Szymon Janc
2012-09-21 10:02 ` [PATCH 14/18] eir: Add support for creating proper OOB EIR Szymon Janc
2012-09-21 10:02 ` [PATCH 15/18] adapter: Add btd_adapter_get_services function Szymon Janc
2012-09-21 10:02 ` [PATCH 16/18] adapter: Rename btd_adapter_get_class to btd_adapter_read_class Szymon Janc
2012-09-21 10:02 ` [PATCH 17/18] adapter: Add btd_adapter_get_class function Szymon Janc
2012-09-21 10:02 ` [PATCH 18/18] neard: Implement RequestOOB function Szymon Janc

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=20120921101723.GA4441@x220 \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=szymon.janc@tieto.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.