OSDN Git Service

sbc: Fix a couple of other places that should use size_t and ssize_t
authorJohan Hedberg <johan.hedberg@nokia.com>
Thu, 12 Mar 2009 19:33:14 +0000 (16:33 -0300)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 30 Jul 2012 02:48:28 +0000 (19:48 -0700)
sbc/sbcdec.c
sbc/sbcenc.c
sbc/sbcinfo.c

index dfe092f..b6635ed 100644 (file)
@@ -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;
                }
index d284789..8dad062 100644 (file)
@@ -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;
                        }
index 339518a..645de9b 100644 (file)
@@ -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;
                }