All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Jakub Pawlowski <jpawlowski@google.com>
Cc: Arman Uguray <armansito@chromium.org>,
	BlueZ development <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH v1 2/8] core/adapter: Refactor of scan type
Date: Mon, 23 Mar 2015 20:40:35 -0700	[thread overview]
Message-ID: <F6DDE3F3-448B-4740-8A64-6315810F7BCE@holtmann.org> (raw)
In-Reply-To: <CAD0=r8z6Wqdb5iXLmHaQqLRQHcF0uFxgO_Vut0G_VdcWPR5caA@mail.gmail.com>

Hi Jakub,

>>> On Sat, Mar 21, 2015 at 3:15 PM, Jakub Pawlowski <jpawlowski@google.com> wrote:
>>> This patch replaces scan type with defined constants, and creates
>>> new method that might be used to get currently avaliable scan type.
>>> ---
>>> src/adapter.c | 29 +++++++++++++++++++++--------
>>> 1 file changed, 21 insertions(+), 8 deletions(-)
>>> 
>>> diff --git a/src/adapter.c b/src/adapter.c
>>> index 6eeb2f9..99f9786 100644
>>> --- a/src/adapter.c
>>> +++ b/src/adapter.c
>>> @@ -88,6 +88,10 @@
>>> #define TEMP_DEV_TIMEOUT (3 * 60)
>>> #define BONDING_TIMEOUT (2 * 60)
>>> 
>>> +#define SCAN_TYPE_BREDR (1 << BDADDR_BREDR)
>>> +#define SCAN_TYPE_LE ((1 << BDADDR_LE_PUBLIC) | (1 << BDADDR_LE_RANDOM))
>>> +#define SCAN_TYPE_DUAL (SCAN_TYPE_BREDR | SCAN_TYPE_LE)
>> 
>> SCAN_TYPE_DUAL isn't being used anywhere in this patch, is it needed
>> here? Maybe only include this in the patch that actually uses it?
>> 
> I'll fix that.
>>> +
>>> static DBusConnection *dbus_conn = NULL;
>>> 
>>> static bool kernel_conn_control = false;
>>> @@ -1185,7 +1189,7 @@ static gboolean passive_scanning_timeout(gpointer user_data)
>>> 
>>>        adapter->passive_scan_timeout = 0;
>>> 
>>> -       cp.type = (1 << BDADDR_LE_PUBLIC) | (1 << BDADDR_LE_RANDOM);
>>> +       cp.type = SCAN_TYPE_LE;
>>> 
>>>        mgmt_send(adapter->mgmt, MGMT_OP_START_DISCOVERY,
>>>                                adapter->dev_id, sizeof(cp), &cp,
>>> @@ -1327,6 +1331,21 @@ static void cancel_passive_scanning(struct btd_adapter *adapter)
>>>        }
>>> }
>>> 
>>> +static uint8_t get_current_type(struct btd_adapter *adapter)
>>> +{
>>> +       uint8_t type;
>>> +
>>> +       if (adapter->current_settings & MGMT_SETTING_BREDR)
>>> +               type = SCAN_TYPE_BREDR;
>>> +       else
>>> +               type = 0;
>> 
>> I'd just initialize type = 0 and then bitwise or SCAN_TYPE_BREDR if
>> the BREDR setting is set, which I think makes for more readable code.
>> 
> 
> So when I was writing some kernel code, Marcel told me that they
> prefer to delay initialization of variables as long as possible, and
> that's in that manner. I also didn't write this code, I just moved it
> from other place, so this should be good, or was some convention
> changed ?

this rule is still in affect and we want it. Mainly so that the compiler will warn us when we accidentally have a new code path. I want people to think about their code and if the compiler just complains, that is normally a good indication that something needs some extra look at it.

Regards

Marcel


  reply	other threads:[~2015-03-24  3:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-21 22:15 [PATCH v1 1/8] core: device: add device_set_rssi_no_delta Jakub Pawlowski
2015-03-21 22:15 ` [PATCH v1 2/8] core/adapter: Refactor of scan type Jakub Pawlowski
2015-03-23 23:58   ` Arman Uguray
2015-03-24  3:18     ` Jakub Pawlowski
2015-03-24  3:40       ` Marcel Holtmann [this message]
2015-03-21 22:15 ` [PATCH v1 3/8] core: adapter: Add SetDiscoveryFilter method Jakub Pawlowski
2015-03-21 22:15 ` [PATCH v1 4/8] core: adapter: Add parameter parsing to SetDiscoveryFilter Jakub Pawlowski
2015-03-21 22:15 ` [PATCH v1 5/8] core: adapter: properly set the filter for discovery Jakub Pawlowski
2015-03-21 22:15 ` [PATCH v1 6/8] core: adapter: start proper discovery depending on filter type Jakub Pawlowski
2015-03-21 22:15 ` [PATCH v1 7/8] core: adapter: add device filtering when filered discovery is used Jakub Pawlowski
2015-03-21 22:15 ` [PATCH v1 8/8] client: main: add support for SetDiscoveryFilter Jakub Pawlowski

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=F6DDE3F3-448B-4740-8A64-6315810F7BCE@holtmann.org \
    --to=marcel@holtmann.org \
    --cc=armansito@chromium.org \
    --cc=jpawlowski@google.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 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.