Bluetooth: Improve buffer debug usefulness
The overflow/underflow checks are something that we want to have whenever debug is enabled in general (and not just for buffers specifically). Change-Id: Ib4edd366ae8ce1a80d33155ab1dc8d5a20477909 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
8d0d247f23
commit
1781490c87
|
@ -150,7 +150,10 @@ struct bt_buf *bt_buf_hold(struct bt_buf *buf)
|
|||
void *bt_buf_add(struct bt_buf *buf, size_t len)
|
||||
{
|
||||
uint8_t *tail = buf->data + buf->len;
|
||||
#if defined(CONFIG_BLUETOOTH_DEBUG_BUF)
|
||||
|
||||
BT_DBG("buf %p len %u\n", buf, len);
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_DEBUG)
|
||||
if (bt_buf_tailroom(buf) < len) {
|
||||
BT_ERR("buf %p overflow! len %u tailroom %u\n", buf, len,
|
||||
bt_buf_tailroom(buf));
|
||||
|
@ -162,7 +165,9 @@ void *bt_buf_add(struct bt_buf *buf, size_t len)
|
|||
|
||||
void *bt_buf_push(struct bt_buf *buf, size_t len)
|
||||
{
|
||||
#if defined(CONFIG_BLUETOOTH_DEBUG_BUF)
|
||||
BT_DBG("buf %p len %u\n", buf, len);
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_DEBUG)
|
||||
if (bt_buf_headroom(buf) < len) {
|
||||
BT_ERR("buf %p underflow! len %u headroom %u\n", buf, len,
|
||||
bt_buf_headroom(buf));
|
||||
|
@ -175,7 +180,9 @@ void *bt_buf_push(struct bt_buf *buf, size_t len)
|
|||
|
||||
void *bt_buf_pull(struct bt_buf *buf, size_t len)
|
||||
{
|
||||
#if defined(CONFIG_BLUETOOTH_DEBUG_BUF)
|
||||
BT_DBG("buf %p len %u\n", buf, len);
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_DEBUG)
|
||||
if (buf->len < len) {
|
||||
BT_ERR("buf %p overflow! len %u buf->len %u\n", buf, len,
|
||||
buf->len);
|
||||
|
|
Loading…
Reference in New Issue