Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/cdplay fix the rest of the lint warnings [pass 1]



details:   https://anonhg.NetBSD.org/src/rev/ece93773b229
branches:  trunk
changeset: 790421:ece93773b229
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Oct 07 15:17:24 2013 +0000

description:
fix the rest of the lint warnings [pass 1]

diffstat:

 usr.bin/cdplay/cdplay.c |  116 ++++++++++++++++++++++++-----------------------
 1 files changed, 60 insertions(+), 56 deletions(-)

diffs (truncated from 346 to 300 lines):

diff -r c0c285ef8ffe -r ece93773b229 usr.bin/cdplay/cdplay.c
--- a/usr.bin/cdplay/cdplay.c   Mon Oct 07 10:50:37 2013 +0000
+++ b/usr.bin/cdplay/cdplay.c   Mon Oct 07 15:17:24 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cdplay.c,v 1.47 2013/10/07 00:16:19 dholland Exp $     */
+/*     $NetBSD: cdplay.c,v 1.48 2013/10/07 15:17:24 christos Exp $     */
 
 /*
  * Copyright (c) 1999, 2000, 2001 Andrew Doran.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: cdplay.c,v 1.47 2013/10/07 00:16:19 dholland Exp $");
+__RCSID("$NetBSD: cdplay.c,v 1.48 2013/10/07 15:17:24 christos Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -94,7 +94,7 @@
 static struct cmdtab {
        enum cmd        command;
        const char      *name;
-       unsigned int    min;
+       u_int   min;
        const char      *args;
 } const cmdtab[] = {
        { CMD_ANALOG,   "analog",  1, NULL },
@@ -172,14 +172,14 @@
 static const char   *parse(char *, int *);
 static int     play(const char *, int);
 static int     play_blocks(int, int);
-static int     play_digital(int, int);
-static int     play_msf(int, int, int, int, int, int);
+static int     play_digital(u_int, u_int);
+static int     play_msf(u_int, u_int, u_int, u_int, u_int, u_int);
 static int     play_track(int, int, int, int);
 static int     print_status(void);
 static void    print_track(struct cd_toc_entry *);
 static const char      *prompt(void);
 static int     readaudio(int, int, int, u_char *);
-static int     read_toc_entries(int);
+static int     read_toc_entries(size_t);
 static int     run(int, const char *);
 static int     start_analog(void);
 static int     start_digital(const char *);
@@ -318,18 +318,17 @@
                        fd = -1;
                }
        }
-
+       /*NOTREACHED*/
        el_end(elptr);
        history_end(hist);
        exit(EXIT_SUCCESS);
-       /* NOTREACHED */
 }
 
 static void
 usage(void)
 {
 
-       fprintf(stderr, "usage: cdplay [-a audio_device] [-f cd_device] [command ...]\n");
+       fprintf(stderr, "Usage: %s [-a audio_device] [-f cd_device] [command ...]\n", getprogname());
        exit(EXIT_FAILURE);
        /* NOTREACHED */
 }
@@ -377,7 +376,7 @@
         * in the signal handler
         */
        intv_usecs -= 50000;
-       hz_usecs = 1000000 / sysconf(_SC_CLK_TCK);
+       hz_usecs = (int)(1000000 / sysconf(_SC_CLK_TCK));
        if (intv_usecs < hz_usecs) {
                /* can't have a shorter interval, increase
                   buffer size to compensate */
@@ -641,7 +640,8 @@
 static int
 play(const char *arg, int fromuser)
 {
-       int rv, start, end, istart, iend, blk, len, relend;
+       int start, end, istart, iend, blk, len, relend;
+       ssize_t rv;
        u_int n, tr1, tr2, m1, m2, s1, s2, f1, f2, tm, ts, tf;
        struct ioc_toc_header h;
 
@@ -652,7 +652,7 @@
 
        if ((rv = ioctl(fd, CDIOREADTOCHEADER, &h)) <  0) {
                warn("ioctl(CDIOREADTOCHEADER)");
-               return (rv);
+               return (int)(rv);
        }
 
        end = 0;
@@ -660,7 +660,7 @@
        n = h.ending_track - h.starting_track + 1;
        rv = read_toc_entries((n + 1) * sizeof(struct cd_toc_entry));
        if (rv < 0)
-               return (rv);
+               return (int)(rv);
 
        if (arg == NULL || *arg == '\0') {
                /* Play the whole disc */
@@ -692,71 +692,71 @@
                 */
                relend = 1;
                tr2 = m2 = s2 = f2 = f1 = 0;
-               if (8 == sscanf(arg, "%d %d:%d.%d %d %d:%d.%d", &tr1, &m1,
+               if (8 == sscanf(arg, "%u %u:%u.%u %u %u:%u.%u", &tr1, &m1,
                    &s1, &f1, &tr2, &m2, &s2, &f2))
                        goto Play_Relative_Addresses;
 
                tr2 = m2 = s2 = f2 = f1 = 0;
-               if (7 == sscanf(arg, "%d %d:%d %d %d:%d.%d", &tr1, &m1, &s1,
+               if (7 == sscanf(arg, "%u %u:%u %u %u:%u.%u", &tr1, &m1, &s1,
                    &tr2, &m2, &s2, &f2))
                        goto Play_Relative_Addresses;
 
                tr2 = m2 = s2 = f2 = f1 = 0;
-               if (7 == sscanf(arg, "%d %d:%d.%d %d %d:%d", &tr1, &m1, &s1,
+               if (7 == sscanf(arg, "%u %u:%u.%u %u %u:%u", &tr1, &m1, &s1,
                    &f1, &tr2, &m2, &s2))
                        goto Play_Relative_Addresses;
 
                tr2 = m2 = s2 = f2 = f1 = 0;
-               if (7 == sscanf(arg, "%d %d:%d.%d %d:%d.%d", &tr1, &m1, &s1,
+               if (7 == sscanf(arg, "%u %u:%u.%u %u:%u.%u", &tr1, &m1, &s1,
                    &f1, &m2, &s2, &f2))
                        goto Play_Relative_Addresses;
 
                tr2 = m2 = s2 = f2 = f1 = 0;
-               if (6 == sscanf(arg, "%d %d:%d.%d %d:%d", &tr1, &m1, &s1, &f1,
+               if (6 == sscanf(arg, "%u %u:%u.%u %u:%u", &tr1, &m1, &s1, &f1,
                    &m2, &s2))
                        goto Play_Relative_Addresses;
 
                tr2 = m2 = s2 = f2 = f1 = 0;
-               if (6 == sscanf(arg, "%d %d:%d %d:%d.%d", &tr1, &m1, &s1, &m2,
+               if (6 == sscanf(arg, "%u %u:%u %u:%u.%u", &tr1, &m1, &s1, &m2,
                    &s2, &f2))
                        goto Play_Relative_Addresses;
 
                tr2 = m2 = s2 = f2 = f1 = 0;
-               if (6 == sscanf(arg, "%d %d:%d.%d %d %d", &tr1, &m1, &s1, &f1,
+               if (6 == sscanf(arg, "%u %u:%u.%u %u %u", &tr1, &m1, &s1, &f1,
                    &tr2, &m2))
                        goto Play_Relative_Addresses;
 
                tr2 = m2 = s2 = f2 = f1 = 0;
-               if (6 == sscanf(arg, "%d %d:%d %d %d:%d", &tr1, &m1, &s1, &tr2,
+               if (6 == sscanf(arg, "%u %u:%u %u %u:%u", &tr1, &m1, &s1, &tr2,
                    &m2, &s2))
                        goto Play_Relative_Addresses;
 
                tr2 = m2 = s2 = f2 = f1 = 0;
-               if (5 == sscanf(arg, "%d %d:%d %d:%d", &tr1, &m1, &s1, &m2,
+               if (5 == sscanf(arg, "%u %u:%u %u:%u", &tr1, &m1, &s1, &m2,
                    &s2))
                        goto Play_Relative_Addresses;
 
                tr2 = m2 = s2 = f2 = f1 = 0;
-               if (5 == sscanf(arg, "%d %d:%d %d %d", &tr1, &m1, &s1, &tr2,
+               if (5 == sscanf(arg, "%u %u:%u %u %u", &tr1, &m1, &s1, &tr2,
                    &m2))
                        goto Play_Relative_Addresses;
 
                relend=0;
                tr2 = m2 = s2 = f2 = f1 = 0;
-               if (5 == sscanf(arg, "%d %d:%d.%d %d", &tr1, &m1, &s1, &f1,
+               if (5 == sscanf(arg, "%u %u:%u.%u %u", &tr1, &m1, &s1, &f1,
                    &tr2))
                        goto Play_Relative_Addresses;
 
                tr2 = m2 = s2 = f2 = f1 = 0;
-               if (4 == sscanf(arg, "%d %d:%d %d", &tr1, &m1, &s1, &tr2))
+               if (4 == sscanf(arg, "%u %u:%u %u", &tr1, &m1, &s1, &tr2))
                        goto Play_Relative_Addresses;
 
                tr2 = m2 = s2 = f2 = f1 = 0;
-               if (4 == sscanf(arg, "%d %d:%d.%d", &tr1, &m1, &s1, &f1))
+               if (4 == sscanf(arg, "%u %u:%u.%u", &tr1, &m1, &s1, &f1))
                        goto Play_Relative_Addresses;
 
                tr2 = m2 = s2 = f2 = f1 = 0;
-               if (3 == sscanf(arg, "%d %d:%d", &tr1, &m1, &s1))
+               if (3 == sscanf(arg, "%u %u:%u", &tr1, &m1, &s1))
                        goto Play_Relative_Addresses;
 
                tr2 = m2 = s2 = f2 = f1 = 0;
@@ -862,9 +862,10 @@
 }
 
 static void
+/*ARGSUSED*/
 sig_timer(int sig)
 {
-       int aulen, auwr, fpw;
+       int aulen, fpw;
        sigset_t anymore;
 
        sigpending(&anymore);
@@ -884,7 +885,7 @@
                if (fpw > 0) {
                        aulen = readaudio(fd, da.lba_current, fpw, da.aubuf);
                        if (aulen > 0) {
-                               auwr = write(da.afd, da.aubuf, aulen);
+                               (void)write(da.afd, da.aubuf, aulen);
                                da.lba_current += fpw;
                        }
                }
@@ -1064,10 +1065,10 @@
 
        lba += 150;             /* block start offset */
        lba &= 0xffffff;        /* negative lbas use only 24 bits */
-       *m = lba / (60 * 75);
+       *m = (u_int)(lba / (60 * 75));
        lba %= (60 * 75);
-       *s = lba / 75;
-       *f = lba % 75;
+       *s = (u_int)(lba / 75);
+       *f = (u_int)(lba % 75);
 }
 
 static u_int
@@ -1088,8 +1089,8 @@
                printf("%2d:%02d.%02d  ", e->addr.msf.minute,
                    e->addr.msf.second, e->addr.msf.frame);
 
-               block = msf2lba(e->addr.msf.minute, e->addr.msf.second,
-                   e->addr.msf.frame);
+               block = msf2lba((u_int)e->addr.msf.minute,
+                   (u_int)e->addr.msf.second, (u_int)e->addr.msf.frame);
        } else {
                block = e->addr.lba;
                lba2msf(block, &m, &s, &f);
@@ -1102,8 +1103,8 @@
                return;
        }
        if (msf)
-               next = msf2lba(e[1].addr.msf.minute, e[1].addr.msf.second,
-                   e[1].addr.msf.frame);
+               next = msf2lba((u_int)e[1].addr.msf.minute,
+                   (u_int)e[1].addr.msf.second, (u_int)e[1].addr.msf.frame);
        else
                next = e[1].addr.lba;
        len = next - block;
@@ -1126,13 +1127,16 @@
        if (digital) {
                tstart--;
                if (msf) {
-                       return (play_msf(toc_buffer[tstart].addr.msf.minute,
-                               toc_buffer[tstart].addr.msf.second, toc_buffer[tstart].addr.msf.frame,
-                               toc_buffer[tend].addr.msf.minute, toc_buffer[tend].addr.msf.second,
-                               toc_buffer[tend].addr.msf.frame));
+                       return play_msf(
+                           (u_int)toc_buffer[tstart].addr.msf.minute,
+                           (u_int)toc_buffer[tstart].addr.msf.second,
+                           (u_int)toc_buffer[tstart].addr.msf.frame,
+                           (u_int)toc_buffer[tend].addr.msf.minute,
+                           (u_int)toc_buffer[tend].addr.msf.second,
+                           (u_int)toc_buffer[tend].addr.msf.frame);
                } else
-                       return (play_digital(toc_buffer[tstart].addr.lba,
-                               toc_buffer[tend].addr.lba));
+                       return play_digital(toc_buffer[tstart].addr.lba,
+                           toc_buffer[tend].addr.lba);
        }
        t.start_track = tstart;
        t.start_index = istart;
@@ -1164,7 +1168,7 @@
 }
 
 static int
-play_digital(int start, int end)
+play_digital(u_int start, u_int end)
 {
        da.lba_start = start;
        da.lba_end = --end;
@@ -1192,14 +1196,14 @@
 }
 
 static int
-read_toc_entries(int len)
+read_toc_entries(size_t len)
 {
        struct ioc_read_toc_entry t;
        int rv;
 
        t.address_format = msf ? CD_MSF_FORMAT : CD_LBA_FORMAT;
        t.starting_track = 0;
-       t.data_len = len;
+       t.data_len = (int)len;
        t.data = toc_buffer;
 
        if ((rv = ioctl(fd, CDIOREADTOCENTRYS, &t)) < 0)
@@ -1209,8 +1213,8 @@
 }
 
 static int
-play_msf(int start_m, int start_s, int start_f, int end_m, int end_s,



Home | Main Index | Thread Index | Old Index