summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2009-03-12 16:33:14 -0300
committerJohan Hedberg <johan.hedberg@nokia.com>2009-03-12 16:33:14 -0300
commitae6e4f68f37333e3dbd6b8b89445850b87bcbfe2 (patch)
tree89d1a0cd2f07b82597b9d78843b162019f944868
parent7c27b3e218470ba0bc2beaad39635f7b3548e53a (diff)
Fix a couple of other places that should use size_t and ssize_t
-rw-r--r--compat/bnep.c10
-rw-r--r--sbc/sbcdec.c5
-rw-r--r--sbc/sbcenc.c7
-rw-r--r--sbc/sbcinfo.c7
4 files changed, 16 insertions, 13 deletions
diff --git a/compat/bnep.c b/compat/bnep.c
index e9742c7a..0498c789 100644
--- a/compat/bnep.c
+++ b/compat/bnep.c
@@ -219,7 +219,7 @@ int bnep_accept_connection(int sk, uint16_t role, char *dev)
struct bnep_setup_conn_req *req;
struct bnep_control_rsp *rsp;
unsigned char pkt[BNEP_MTU];
- int r;
+ ssize_t r;
r = recv(sk, pkt, BNEP_MTU, 0);
if (r <= 0)
@@ -227,7 +227,7 @@ int bnep_accept_connection(int sk, uint16_t role, char *dev)
errno = EPROTO;
- if (r < (int) sizeof(*req))
+ if ((size_t) r < sizeof(*req))
return -1;
req = (void *) pkt;
@@ -259,7 +259,7 @@ int bnep_create_connection(int sk, uint16_t role, uint16_t svc, char *dev)
struct __service_16 *s;
struct timeval timeo;
unsigned char pkt[BNEP_MTU];
- int r;
+ ssize_t r;
/* Send request */
req = (void *) pkt;
@@ -292,9 +292,9 @@ receive:
errno = EPROTO;
- if (r < (int) sizeof(*rsp))
+ if ((size_t) r < sizeof(*rsp))
return -1;
-
+
rsp = (void *) pkt;
if (rsp->type != BNEP_CONTROL)
return -1;
diff --git a/sbc/sbcdec.c b/sbc/sbcdec.c
index dfe092f5..b6635ed2 100644
--- a/sbc/sbcdec.c
+++ b/sbc/sbcdec.c
@@ -49,8 +49,9 @@ static void decode(char *filename, char *output, int tofile)
struct stat st;
off_t filesize;
sbc_t sbc;
- int fd, ad, pos, streamlen, framelen, count, written, len;
+ int fd, ad, pos, streamlen, framelen, count, len;
int format = AFMT_S16_BE, frequency, channels;
+ ssize_t written;
if (stat(filename, &st) < 0) {
fprintf(stderr, "Can't get size of file %s: %s\n",
@@ -143,7 +144,7 @@ static void decode(char *filename, char *output, int tofile)
au_hdr.channels = BE_INT(channels);
written = write(ad, &au_hdr, sizeof(au_hdr));
- if (written < (int) sizeof(au_hdr)) {
+ if (written < (ssize_t) sizeof(au_hdr)) {
fprintf(stderr, "Failed to write header\n");
goto close;
}
diff --git a/sbc/sbcenc.c b/sbc/sbcenc.c
index d284789a..8dad062f 100644
--- a/sbc/sbcenc.c
+++ b/sbc/sbcenc.c
@@ -48,7 +48,8 @@ static void encode(char *filename, int subbands, int bitpool, int joint,
{
struct au_header au_hdr;
sbc_t sbc;
- int fd, len, size, encoded, srate, codesize, nframes;
+ int fd, size, encoded, srate, codesize, nframes;
+ ssize_t len;
if (sizeof(au_hdr) != 24) {
/* Sanity check just in case */
@@ -67,7 +68,7 @@ static void encode(char *filename, int subbands, int bitpool, int joint,
fd = fileno(stdin);
len = read(fd, &au_hdr, sizeof(au_hdr));
- if (len < (int) sizeof(au_hdr)) {
+ if (len < (ssize_t) sizeof(au_hdr)) {
if (fd > fileno(stderr))
fprintf(stderr, "Can't read header from file %s: %s\n",
filename, strerror(errno));
@@ -170,7 +171,7 @@ static void encode(char *filename, int subbands, int bitpool, int joint,
&encoded);
if (len != codesize || encoded <= 0) {
fprintf(stderr,
- "sbc_encode fail, len=%d, encoded=%d\n",
+ "sbc_encode fail, len=%zd, encoded=%d\n",
len, encoded);
break;
}
diff --git a/sbc/sbcinfo.c b/sbc/sbcinfo.c
index 339518a2..645de9be 100644
--- a/sbc/sbcinfo.c
+++ b/sbc/sbcinfo.c
@@ -174,7 +174,8 @@ static int analyze_file(char *filename)
double rate;
int bitpool[SIZE], frame_len[SIZE];
int subbands, blocks, freq, mode, method;
- int n, p1, p2, fd, len, size, num;
+ int n, p1, p2, fd, size, num;
+ ssize_t len;
unsigned int count;
if (strcmp(filename, "-")) {
@@ -236,9 +237,9 @@ static int analyze_file(char *filename)
if (len == 0)
break;
- if (len < (int) sizeof(hdr) || hdr.syncword != 0x9c) {
+ if ((size_t) len < sizeof(hdr) || hdr.syncword != 0x9c) {
fprintf(stderr, "Corrupted SBC stream "
- "(len %d syncword 0x%02x)\n",
+ "(len %zd syncword 0x%02x)\n",
len, hdr.syncword);
break;
}