summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2009-03-12 16:15:06 -0300
committerJohan Hedberg <johan.hedberg@nokia.com>2009-03-12 16:15:06 -0300
commit7c27b3e218470ba0bc2beaad39635f7b3548e53a (patch)
tree392d8bced2ac86de3da8a6648aa4fc543d8ec7c8 /audio
parent88b59d5500d626ce382b2edd8892d4b62ad40177 (diff)
Make use of size_t and ssize_t when possible
Diffstat (limited to 'audio')
-rw-r--r--audio/pcm_bluetooth.c5
-rw-r--r--audio/unix.c14
2 files changed, 11 insertions, 8 deletions
diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c
index c0a39be3..9c4f9c46 100644
--- a/audio/pcm_bluetooth.c
+++ b/audio/pcm_bluetooth.c
@@ -1511,7 +1511,8 @@ static int audioservice_send(int sk, const bt_audio_msg_header_t *msg)
static int audioservice_recv(int sk, bt_audio_msg_header_t *inmsg)
{
- int err, ret;
+ int err;
+ ssize_t ret;
const char *type, *name;
uint16_t length;
@@ -1524,7 +1525,7 @@ static int audioservice_recv(int sk, bt_audio_msg_header_t *inmsg)
err = -errno;
SNDERR("Error receiving IPC data from bluetoothd: %s (%d)",
strerror(errno), errno);
- } else if (ret < (int) sizeof(bt_audio_msg_header_t)) {
+ } else if ((size_t) ret < sizeof(bt_audio_msg_header_t)) {
SNDERR("Too short (%d bytes) IPC packet from bluetoothd", ret);
err = -EINVAL;
} else {
diff --git a/audio/unix.c b/audio/unix.c
index e455c4e3..1487395a 100644
--- a/audio/unix.c
+++ b/audio/unix.c
@@ -387,17 +387,19 @@ static int a2dp_append_codec(struct bt_get_capabilities_rsp *rsp,
{
struct avdtp_media_codec_capability *codec_cap = (void *) cap->data;
codec_capabilities_t *codec = (void *) rsp + rsp->h.length;
- int space_left = BT_SUGGESTED_BUFFER_SIZE - rsp->h.length;
+ size_t space_left;
- if (space_left <= 0)
+ if (rsp->h.length > BT_SUGGESTED_BUFFER_SIZE)
return -ENOMEM;
+ space_left = BT_SUGGESTED_BUFFER_SIZE - rsp->h.length;
+
/* endianess prevent direct cast */
if (codec_cap->media_codec_type == A2DP_CODEC_SBC) {
struct sbc_codec_cap *sbc_cap = (void *) codec_cap;
sbc_capabilities_t *sbc = (void *) codec;
- if ((space_left - (int) sizeof(sbc_capabilities_t)) < 0)
+ if (space_left < sizeof(sbc_capabilities_t))
return -ENOMEM;
codec->length = sizeof(sbc_capabilities_t);
@@ -413,7 +415,7 @@ static int a2dp_append_codec(struct bt_get_capabilities_rsp *rsp,
struct mpeg_codec_cap *mpeg_cap = (void *) codec_cap;
mpeg_capabilities_t *mpeg = (void *) codec;
- if ((space_left - (int) sizeof(mpeg_capabilities_t)) < 0)
+ if (space_left < sizeof(mpeg_capabilities_t))
return -ENOMEM;
codec->length = sizeof(mpeg_capabilities_t);
@@ -425,12 +427,12 @@ static int a2dp_append_codec(struct bt_get_capabilities_rsp *rsp,
mpeg->mpf = mpeg_cap->mpf;
mpeg->bitrate = mpeg_cap->bitrate;
} else {
- int codec_length;
+ size_t codec_length;
codec_length = cap->length - (sizeof(struct avdtp_service_capability)
+ sizeof(struct avdtp_media_codec_capability));
- if ((space_left - codec_length - (int) sizeof(codec_capabilities_t)) < 0)
+ if (space_left < codec_length + sizeof(codec_capabilities_t))
return -ENOMEM;
codec->length = codec_length + sizeof(codec_capabilities_t);