From: Johan Hedberg <johan.hedberg@gmail.com>
To: Alfonso Acosta <fons@spotify.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v4] Bluetooth: Include ADV_IND report in Device Connected event
Date: Tue, 7 Oct 2014 11:01:54 +0300 [thread overview]
Message-ID: <20141007080154.GA30209@t440s.lan> (raw)
In-Reply-To: <1412637149-2966-1-git-send-email-fons@spotify.com>
Hi Alfonso,
On Mon, Oct 06, 2014, Alfonso Acosta wrote:
> @@ -4322,7 +4323,7 @@ static void check_pending_le_conn(struct hci_dev *hdev, bdaddr_t *addr,
> * count consistent once the connection is established.
> */
> params->conn = hci_conn_get(conn);
> - return;
> + return conn;
> }
>
> switch (PTR_ERR(conn)) {
> @@ -4335,7 +4336,10 @@ static void check_pending_le_conn(struct hci_dev *hdev, bdaddr_t *addr,
> break;
> default:
> BT_DBG("Failed to connect: err %ld", PTR_ERR(conn));
> + return NULL;
> }
> +
> + return conn;
> }
I just realized that in this last part of check_pending_le_conn()
IS_ERR(conn) will true (since the first part that I quoted handles the
!IS_ERR(conn) condition) so you should really be explicitly returning
NULL here instead of the conn pointer. This is particularly important
since you're only checking for non-NULL in the calling code instead of
doing IS_ERR() there.
> - if (conn->dev_class && memcmp(conn->dev_class, "\0\0\0", 3) != 0)
> - eir_len = eir_append_data(ev->eir, eir_len,
> - EIR_CLASS_OF_DEV, conn->dev_class, 3);
> + if (conn->dev_class &&
> + memcmp(conn->dev_class, "\0\0\0", 3) != 0)
> + eir_len = eir_append_data(ev->eir, eir_len,
> + EIR_CLASS_OF_DEV,
> + conn->dev_class, 3);
> + }
I know this is not your fault but a redundancy in the existing code, but
the check for if (conn->dev_class) is pointless since the variable is
defined as an array, i.e. it will always be non-NULL. To make this fix
clear it's probably better to have it as a separate patch either before
or after your current two patches.
To make it easier to get the right versions of these applied could you
please send the entire set again instead of just this one patch. Thanks.
Johan
next prev parent reply other threads:[~2014-10-07 8:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-06 23:12 [PATCH v4] Bluetooth: Include ADV_IND report in Device Connected event Alfonso Acosta
2014-10-06 23:14 ` [PATCH v3] " Alfonso Acosta
2014-10-07 8:01 ` Johan Hedberg [this message]
2014-10-07 9:30 ` [PATCH v4] " Alfonso Acosta
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=20141007080154.GA30209@t440s.lan \
--to=johan.hedberg@gmail.com \
--cc=fons@spotify.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