diff --git a/monitor/avctp.c b/monitor/avctp.c
index be21cd7..5543a49 100644
--- a/monitor/avctp.c
+++ b/monitor/avctp.c
uint8_t cap, count;
int i;
- if (l2cap_frame_get_u8(frame, &cap))
+ if (!l2cap_frame_get_u8(frame, &cap))
return false;
print_field("%*cCapabilityID: 0x%02x (%s)", (indent - 8), ' ', cap,
if (len == 1)
return true;
- if (l2cap_frame_get_u8(frame, &count))
+ if (!l2cap_frame_get_u8(frame, &count))
return false;
print_field("%*cCapabilityCount: 0x%02x", (indent - 8), ' ', count);
for (i = 0; count > 0; count--, i++) {
uint8_t event;
- if (l2cap_frame_get_u8(frame, &event))
+ if (!l2cap_frame_get_u8(frame, &event))
return false;
print_field("%*c%s: 0x%02x (%s)", (indent - 8), ' ',
l2cap_frame_pull(&avrcp_frame, frame, 0);
- if (l2cap_frame_get_u8(&avrcp_frame, &num))
+ if (!l2cap_frame_get_u8(&avrcp_frame, &num))
return false;
print_field("%*cAttributeCount: 0x%02x", (indent - 8), ' ', num);
for (i = 0; num > 0; num--, i++) {
uint8_t attr;
- if (l2cap_frame_get_u8(&avrcp_frame, &attr))
+ if (!l2cap_frame_get_u8(&avrcp_frame, &attr))
return false;
print_field("%*cAttributeID: 0x%02x (%s)", (indent - 8), ' ',
if (ctype > AVC_CTYPE_GENERAL_INQUIRY)
goto response;
- if (l2cap_frame_get_u8(frame, &attr))
+ if (!l2cap_frame_get_u8(frame, &attr))
return false;
print_field("%*cAttributeID: 0x%02x (%s)", (indent - 8), ' ',
return true;
response:
- if (l2cap_frame_get_u8(frame, &num))
+ if (!l2cap_frame_get_u8(frame, &num))
return false;
print_field("%*cValueCount: 0x%02x", (indent - 8), ' ', num);
for (; num > 0; num--) {
uint8_t value;
- if (l2cap_frame_get_u8(frame, &value))
+ if (!l2cap_frame_get_u8(frame, &value))
return false;
print_field("%*cValueID: 0x%02x (%s)", (indent - 8),
{
uint8_t status;
- if (l2cap_frame_get_u8(frame, &status))
+ if (!l2cap_frame_get_u8(frame, &status))
return false;
print_field("%*cError: 0x%02x (%s)", (indent - 8), ' ', status,
diff --git a/monitor/l2cap.h b/monitor/l2cap.h
index 645e3ef..5faaea6 100644
--- a/monitor/l2cap.h
+++ b/monitor/l2cap.h
frame->size = source->size - len;
}
-static inline int l2cap_frame_get_u8(struct l2cap_frame *frame, uint8_t *value)
+static inline bool l2cap_frame_get_u8(struct l2cap_frame *frame, uint8_t *value)
{
if (frame->size < sizeof(*value))
- return -1;
+ return false;
if (value)
*value = *((uint8_t *) frame->data);
l2cap_frame_pull(frame, frame, sizeof(*value));
- return 0;
+ return true;
}
-static inline int l2cap_frame_get_be16(struct l2cap_frame *frame,
+static inline bool l2cap_frame_get_be16(struct l2cap_frame *frame,
uint16_t *value)
{
if (frame->size < sizeof(*value))
- return -1;
+ return false;
if (value)
*value = get_be16(frame->data);
l2cap_frame_pull(frame, frame, sizeof(*value));
- return 0;
+ return true;
}
-static inline int l2cap_frame_get_le16(struct l2cap_frame *frame,
+static inline bool l2cap_frame_get_le16(struct l2cap_frame *frame,
uint16_t *value)
{
if (frame->size < sizeof(*value))
- return -1;
+ return false;
if (value)
*value = get_le16(frame->data);
return 0;
}
-static inline int l2cap_frame_get_be32(struct l2cap_frame *frame,
+static inline bool l2cap_frame_get_be32(struct l2cap_frame *frame,
uint32_t *value)
{
if (frame->size < sizeof(*value))
- return -1;
+ return false;
if (value)
*value = get_be32(frame->data);
l2cap_frame_pull(frame, frame, sizeof(*value));
- return 0;
+ return true;
}
-static inline int l2cap_frame_get_le32(struct l2cap_frame *frame,
+static inline bool l2cap_frame_get_le32(struct l2cap_frame *frame,
uint32_t *value)
{
if (frame->size < sizeof(*value))
- return -1;
+ return false;
if (value)
*value = get_le32(frame->data);
l2cap_frame_pull(frame, frame, sizeof(*value));
- return 0;
+ return true;
}
-static inline int l2cap_frame_get_be64(struct l2cap_frame *frame,
+static inline bool l2cap_frame_get_be64(struct l2cap_frame *frame,
uint64_t *value)
{
if (frame->size < sizeof(*value))
- return -1;
+ return false;
if (value)
*value = get_be64(frame->data);
l2cap_frame_pull(frame, frame, sizeof(*value));
- return 0;
+ return true;
}
-static inline int l2cap_frame_get_le64(struct l2cap_frame *frame,
+static inline bool l2cap_frame_get_le64(struct l2cap_frame *frame,
uint64_t *value)
{
if (frame->size < sizeof(*value))
- return -1;
+ return false;
if (value)
*value = get_le64(frame->data);
l2cap_frame_pull(frame, frame, sizeof(*value));
- return 0;
+ return true;
}
void l2cap_packet(uint16_t index, bool in, uint16_t handle, uint8_t flags,