You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/07/25 14:06:55 UTC

[GitHub] [incubator-nuttx] onegray commented on a diff in pull request #6695: bluetooth: fixing BT buffer addref/release balance

onegray commented on code in PR #6695:
URL: https://github.com/apache/incubator-nuttx/pull/6695#discussion_r928927049


##########
wireless/bluetooth/bt_hcicore.c:
##########
@@ -1741,15 +1741,6 @@ int bt_hci_cmd_send(uint16_t opcode, FAR struct bt_buf_s *buf)
           return -ENOBUFS;
         }
     }
-  else
-    {
-      /* We manage the refcount the same for supplied and created
-       * buffers so increment the supplied count so we can manage
-       * it as-if we created it.
-       */
-
-      bt_buf_addref(buf);
-    }
 

Review Comment:
   The explanation in comment would be correct, if the function is a `neutral` function. When we pass a created buffer to `neutral` function, we also responsible to release the buffer in calling code.  But accordingly to its usage, this is a 'taking ownership' function.  The buffer comes with positive `ref` and here we are responsible to `release` it after usage.  No additional `addref` is needed.  



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org