linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: hci_conn: clean up some casts
@ 2023-07-17 10:20 Dan Carpenter
  2023-07-17 11:04 ` bluez.test.bot
  2023-07-18 19:30 ` [PATCH] " Luiz Augusto von Dentz
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2023-07-17 10:20 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: Johan Hedberg, linux-bluetooth, linux-kernel, kernel-janitors

The ERR_PTR/PTR_ERR() functions are only for error pointers.  They're
not a generic way to cast pointers to int.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
We should really create INT_PTR/PTR_INT() functions.  But this is a
cleanup until someone creates those.

 net/bluetooth/hci_conn.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index cccc2b8b60a8..aea6fa12d954 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -873,7 +873,7 @@ static void bis_cleanup(struct hci_conn *conn)
 
 static int remove_cig_sync(struct hci_dev *hdev, void *data)
 {
-	u8 handle = PTR_ERR(data);
+	u8 handle = (unsigned long)data;
 
 	return hci_le_remove_cig_sync(hdev, handle);
 }
@@ -882,7 +882,7 @@ static int hci_le_remove_cig(struct hci_dev *hdev, u8 handle)
 {
 	bt_dev_dbg(hdev, "handle 0x%2.2x", handle);
 
-	return hci_cmd_sync_queue(hdev, remove_cig_sync, ERR_PTR(handle), NULL);
+	return hci_cmd_sync_queue(hdev, remove_cig_sync, (void *)(unsigned long)handle, NULL);
 }
 
 static void find_cis(struct hci_conn *conn, void *data)
@@ -1234,7 +1234,7 @@ void hci_conn_failed(struct hci_conn *conn, u8 status)
 static void create_le_conn_complete(struct hci_dev *hdev, void *data, int err)
 {
 	struct hci_conn *conn;
-	u16 handle = PTR_ERR(data);
+	u16 handle = (unsigned long)data;
 
 	conn = hci_conn_hash_lookup_handle(hdev, handle);
 	if (!conn)
@@ -1264,7 +1264,7 @@ static void create_le_conn_complete(struct hci_dev *hdev, void *data, int err)
 static int hci_connect_le_sync(struct hci_dev *hdev, void *data)
 {
 	struct hci_conn *conn;
-	u16 handle = PTR_ERR(data);
+	u16 handle = (unsigned long)data;
 
 	conn = hci_conn_hash_lookup_handle(hdev, handle);
 	if (!conn)
@@ -2854,7 +2854,7 @@ u32 hci_conn_get_phy(struct hci_conn *conn)
 static int abort_conn_sync(struct hci_dev *hdev, void *data)
 {
 	struct hci_conn *conn;
-	u16 handle = PTR_ERR(data);
+	u16 handle = (unsigned long)data;
 
 	conn = hci_conn_hash_lookup_handle(hdev, handle);
 	if (!conn)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: Bluetooth: hci_conn: clean up some casts
  2023-07-17 10:20 [PATCH] Bluetooth: hci_conn: clean up some casts Dan Carpenter
@ 2023-07-17 11:04 ` bluez.test.bot
  2023-07-18 19:30 ` [PATCH] " Luiz Augusto von Dentz
  1 sibling, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2023-07-17 11:04 UTC (permalink / raw)
  To: linux-bluetooth, dan.carpenter

[-- Attachment #1: Type: text/plain, Size: 1427 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=766419

---Test result---

Test Summary:
CheckPatch                    PASS      0.67 seconds
GitLint                       PASS      0.32 seconds
SubjectPrefix                 PASS      0.12 seconds
BuildKernel                   PASS      32.04 seconds
CheckAllWarning               PASS      34.95 seconds
CheckSparse                   PASS      40.28 seconds
CheckSmatch                   PASS      111.59 seconds
BuildKernel32                 PASS      30.71 seconds
TestRunnerSetup               PASS      470.82 seconds
TestRunner_l2cap-tester       PASS      21.71 seconds
TestRunner_iso-tester         PASS      40.80 seconds
TestRunner_bnep-tester        PASS      10.13 seconds
TestRunner_mgmt-tester        PASS      211.54 seconds
TestRunner_rfcomm-tester      PASS      15.39 seconds
TestRunner_sco-tester         PASS      16.06 seconds
TestRunner_ioctl-tester       PASS      16.84 seconds
TestRunner_mesh-tester        PASS      12.38 seconds
TestRunner_smp-tester         PASS      13.60 seconds
TestRunner_userchan-tester    PASS      10.48 seconds
IncrementalBuild              PASS      29.37 seconds



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Bluetooth: hci_conn: clean up some casts
  2023-07-17 10:20 [PATCH] Bluetooth: hci_conn: clean up some casts Dan Carpenter
  2023-07-17 11:04 ` bluez.test.bot
@ 2023-07-18 19:30 ` Luiz Augusto von Dentz
  2023-07-19  8:01   ` Dan Carpenter
  1 sibling, 1 reply; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2023-07-18 19:30 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-kernel,
	kernel-janitors

Hi Dan,

On Mon, Jul 17, 2023 at 3:20 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> The ERR_PTR/PTR_ERR() functions are only for error pointers.  They're
> not a generic way to cast pointers to int.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> We should really create INT_PTR/PTR_INT() functions.  But this is a
> cleanup until someone creates those.

Is there any reason you didn't create such macros? I mean we could
have it local first, or perhaps we just do HANDLE_PTR/PTR_HANDLE to
avoid any confusion.

>  net/bluetooth/hci_conn.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index cccc2b8b60a8..aea6fa12d954 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -873,7 +873,7 @@ static void bis_cleanup(struct hci_conn *conn)
>
>  static int remove_cig_sync(struct hci_dev *hdev, void *data)
>  {
> -       u8 handle = PTR_ERR(data);
> +       u8 handle = (unsigned long)data;
>
>         return hci_le_remove_cig_sync(hdev, handle);
>  }
> @@ -882,7 +882,7 @@ static int hci_le_remove_cig(struct hci_dev *hdev, u8 handle)
>  {
>         bt_dev_dbg(hdev, "handle 0x%2.2x", handle);
>
> -       return hci_cmd_sync_queue(hdev, remove_cig_sync, ERR_PTR(handle), NULL);
> +       return hci_cmd_sync_queue(hdev, remove_cig_sync, (void *)(unsigned long)handle, NULL);
>  }
>
>  static void find_cis(struct hci_conn *conn, void *data)
> @@ -1234,7 +1234,7 @@ void hci_conn_failed(struct hci_conn *conn, u8 status)
>  static void create_le_conn_complete(struct hci_dev *hdev, void *data, int err)
>  {
>         struct hci_conn *conn;
> -       u16 handle = PTR_ERR(data);
> +       u16 handle = (unsigned long)data;
>
>         conn = hci_conn_hash_lookup_handle(hdev, handle);
>         if (!conn)
> @@ -1264,7 +1264,7 @@ static void create_le_conn_complete(struct hci_dev *hdev, void *data, int err)
>  static int hci_connect_le_sync(struct hci_dev *hdev, void *data)
>  {
>         struct hci_conn *conn;
> -       u16 handle = PTR_ERR(data);
> +       u16 handle = (unsigned long)data;
>
>         conn = hci_conn_hash_lookup_handle(hdev, handle);
>         if (!conn)
> @@ -2854,7 +2854,7 @@ u32 hci_conn_get_phy(struct hci_conn *conn)
>  static int abort_conn_sync(struct hci_dev *hdev, void *data)
>  {
>         struct hci_conn *conn;
> -       u16 handle = PTR_ERR(data);
> +       u16 handle = (unsigned long)data;
>
>         conn = hci_conn_hash_lookup_handle(hdev, handle);
>         if (!conn)
> --
> 2.39.2
>


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Bluetooth: hci_conn: clean up some casts
  2023-07-18 19:30 ` [PATCH] " Luiz Augusto von Dentz
@ 2023-07-19  8:01   ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2023-07-19  8:01 UTC (permalink / raw)
  To: Luiz Augusto von Dentz
  Cc: Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-kernel,
	kernel-janitors

On Tue, Jul 18, 2023 at 12:30:57PM -0700, Luiz Augusto von Dentz wrote:
> Hi Dan,
> 
> On Mon, Jul 17, 2023 at 3:20 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
> >
> > The ERR_PTR/PTR_ERR() functions are only for error pointers.  They're
> > not a generic way to cast pointers to int.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> > We should really create INT_PTR/PTR_INT() functions.  But this is a
> > cleanup until someone creates those.
> 
> Is there any reason you didn't create such macros? I mean we could
> have it local first, or perhaps we just do HANDLE_PTR/PTR_HANDLE to
> avoid any confusion.
> 

Yeah.  I can do that.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-07-19  8:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-17 10:20 [PATCH] Bluetooth: hci_conn: clean up some casts Dan Carpenter
2023-07-17 11:04 ` bluez.test.bot
2023-07-18 19:30 ` [PATCH] " Luiz Augusto von Dentz
2023-07-19  8:01   ` Dan Carpenter

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).