Bluetooth: Do not use assignments in IF conditions
authorAndrei Emeltchenko <andrei.emeltchenko@nokia.com>
Tue, 11 Jan 2011 15:20:20 +0000 (17:20 +0200)
committerGustavo F. Padovan <padovan@profusion.mobi>
Tue, 8 Feb 2011 03:40:08 +0000 (01:40 -0200)
Fix checkpatch warnings concerning assignments in if conditions.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
net/bluetooth/af_bluetooth.c
net/bluetooth/cmtp/capi.c
net/bluetooth/cmtp/core.c
net/bluetooth/hci_core.c
net/bluetooth/hci_event.c
net/bluetooth/hidp/core.c
net/bluetooth/l2cap.c

index c4cf3f595004d3c549e3bfb66e2f138732130c6c..a6732b576a522e0eb11696e8474fdd98638ee836 100644 (file)
@@ -240,7 +240,8 @@ int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
        if (flags & (MSG_OOB))
                return -EOPNOTSUPP;
 
-       if (!(skb = skb_recv_datagram(sk, flags, noblock, &err))) {
+       skb = skb_recv_datagram(sk, flags, noblock, &err);
+       if (!skb) {
                if (sk->sk_shutdown & RCV_SHUTDOWN)
                        return 0;
                return err;
@@ -323,7 +324,8 @@ int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
                        if (copied >= target)
                                break;
 
-                       if ((err = sock_error(sk)) != 0)
+                       err = sock_error(sk);
+                       if (err)
                                break;
                        if (sk->sk_shutdown & RCV_SHUTDOWN)
                                break;
index 3487cfe74aecad8d69f007db8e23537226ff3d3a..67cff810c77d19c4755634d7cf4f3093a68f0d9a 100644 (file)
@@ -155,7 +155,8 @@ static void cmtp_send_interopmsg(struct cmtp_session *session,
 
        BT_DBG("session %p subcmd 0x%02x appl %d msgnum %d", session, subcmd, appl, msgnum);
 
-       if (!(skb = alloc_skb(CAPI_MSG_BASELEN + 6 + len, GFP_ATOMIC))) {
+       skb = alloc_skb(CAPI_MSG_BASELEN + 6 + len, GFP_ATOMIC);
+       if (!skb) {
                BT_ERR("Can't allocate memory for interoperability packet");
                return;
        }
index 8e5f292529accd5784482c72a2090816a1ab7df6..2cee71a714c42f7fda5fd217b4a82c6fb8a1dc97 100644 (file)
@@ -115,7 +115,8 @@ static inline void cmtp_add_msgpart(struct cmtp_session *session, int id, const
 
        size = (skb) ? skb->len + count : count;
 
-       if (!(nskb = alloc_skb(size, GFP_ATOMIC))) {
+       nskb = alloc_skb(size, GFP_ATOMIC);
+       if (!nskb) {
                BT_ERR("Can't allocate memory for CAPI message");
                return;
        }
@@ -216,7 +217,8 @@ static void cmtp_process_transmit(struct cmtp_session *session)
 
        BT_DBG("session %p", session);
 
-       if (!(nskb = alloc_skb(session->mtu, GFP_ATOMIC))) {
+       nskb = alloc_skb(session->mtu, GFP_ATOMIC);
+       if (!nskb) {
                BT_ERR("Can't allocate memory for new frame");
                return;
        }
@@ -224,7 +226,8 @@ static void cmtp_process_transmit(struct cmtp_session *session)
        while ((skb = skb_dequeue(&session->transmit))) {
                struct cmtp_scb *scb = (void *) skb->cb;
 
-               if ((tail = (session->mtu - nskb->len)) < 5) {
+               tail = session->mtu - nskb->len;
+               if (tail < 5) {
                        cmtp_send_frame(session, nskb->data, nskb->len);
                        skb_trim(nskb, 0);
                        tail = session->mtu;
index bf6729a53378347b68208b269aa63846b07141f4..2f003224d2ea9e4d9727c643f03ad3ec35c17b7f 100644 (file)
@@ -429,7 +429,8 @@ int hci_inquiry(void __user *arg)
        if (copy_from_user(&ir, ptr, sizeof(ir)))
                return -EFAULT;
 
-       if (!(hdev = hci_dev_get(ir.dev_id)))
+       hdev = hci_dev_get(ir.dev_id);
+       if (!hdev)
                return -ENODEV;
 
        hci_dev_lock_bh(hdev);
@@ -489,7 +490,8 @@ int hci_dev_open(__u16 dev)
        struct hci_dev *hdev;
        int ret = 0;
 
-       if (!(hdev = hci_dev_get(dev)))
+       hdev = hci_dev_get(dev);
+       if (!hdev)
                return -ENODEV;
 
        BT_DBG("%s %p", hdev->name, hdev);
@@ -1940,7 +1942,11 @@ static void hci_cmd_task(unsigned long arg)
        }
 
        /* Send queued commands */
-       if (atomic_read(&hdev->cmd_cnt) && (skb = skb_dequeue(&hdev->cmd_q))) {
+       if (atomic_read(&hdev->cmd_cnt)) {
+               skb = skb_dequeue(&hdev->cmd_q);
+               if (!skb)
+                       return;
+
                kfree_skb(hdev->sent_cmd);
 
                hdev->sent_cmd = skb_clone(skb, GFP_ATOMIC);
index 617f58363dbc06a281d168c9ed2501def58f61c5..cee46cbe7aebbd21591b7846213e8dc7b58d5541 100644 (file)
@@ -851,11 +851,14 @@ static void hci_cs_add_sco(struct hci_dev *hdev, __u8 status)
        hci_dev_lock(hdev);
 
        acl = hci_conn_hash_lookup_handle(hdev, handle);
-       if (acl && (sco = acl->link)) {
-               sco->state = BT_CLOSED;
+       if (acl) {
+               sco = acl->link;
+               if (sco) {
+                       sco->state = BT_CLOSED;
 
-               hci_proto_connect_cfm(sco, status);
-               hci_conn_del(sco);
+                       hci_proto_connect_cfm(sco, status);
+                       hci_conn_del(sco);
+               }
        }
 
        hci_dev_unlock(hdev);
@@ -1037,11 +1040,14 @@ static void hci_cs_setup_sync_conn(struct hci_dev *hdev, __u8 status)
        hci_dev_lock(hdev);
 
        acl = hci_conn_hash_lookup_handle(hdev, handle);
-       if (acl && (sco = acl->link)) {
-               sco->state = BT_CLOSED;
+       if (acl) {
+               sco = acl->link;
+               if (sco) {
+                       sco->state = BT_CLOSED;
 
-               hci_proto_connect_cfm(sco, status);
-               hci_conn_del(sco);
+                       hci_proto_connect_cfm(sco, status);
+                       hci_conn_del(sco);
+               }
        }
 
        hci_dev_unlock(hdev);
index 29544c21f4b52b33a34b87a8621d6150cd9b2455..e0de92952f32589ef21c08dffc5e5a6d7a1f27e4 100644 (file)
@@ -157,7 +157,8 @@ static int hidp_queue_event(struct hidp_session *session, struct input_dev *dev,
 
        session->leds = newleds;
 
-       if (!(skb = alloc_skb(3, GFP_ATOMIC))) {
+       skb = alloc_skb(3, GFP_ATOMIC);
+       if (!skb) {
                BT_ERR("Can't allocate memory for new frame");
                return -ENOMEM;
        }
@@ -250,7 +251,8 @@ static int __hidp_send_ctrl_message(struct hidp_session *session,
 
        BT_DBG("session %p data %p size %d", session, data, size);
 
-       if (!(skb = alloc_skb(size + 1, GFP_ATOMIC))) {
+       skb = alloc_skb(size + 1, GFP_ATOMIC);
+       if (!skb) {
                BT_ERR("Can't allocate memory for new frame");
                return -ENOMEM;
        }
@@ -283,7 +285,8 @@ static int hidp_queue_report(struct hidp_session *session,
 
        BT_DBG("session %p hid %p data %p size %d", session, session->hid, data, size);
 
-       if (!(skb = alloc_skb(size + 1, GFP_ATOMIC))) {
+       skb = alloc_skb(size + 1, GFP_ATOMIC);
+       if (!skb) {
                BT_ERR("Can't allocate memory for new frame");
                return -ENOMEM;
        }
index cbaa7409d8772d80981e54f89847edc0577b01f6..28d2954f94a48243b641ac4d40b3e5fc4dba17b1 100644 (file)
@@ -4724,7 +4724,10 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
 {
        struct l2cap_conn *conn = hcon->l2cap_data;
 
-       if (!conn && !(conn = l2cap_conn_add(hcon, 0)))
+       if (!conn)
+               conn = l2cap_conn_add(hcon, 0);
+
+       if (!conn)
                goto drop;
 
        BT_DBG("conn %p len %d flags 0x%x", conn, skb->len, flags);