Subject: bin/21894: cdplay(1) de-lintification
To: None <gnats-bugs@gnats.netbsd.org>
From: Sergey Svishchev <svs+pr@grep.ru>
List: netbsd-bugs
Date: 06/15/2003 21:46:33
>Number:         21894
>Category:       bin
>Synopsis:       cdplay(1) de-lintification
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 15 17:48:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     "Sergey Svishchev" <svs+pr@grep.ru>
>Release:        NetBSD 1.6T
>Organization:
>Environment:
	
	
>Description:
	
>How-To-Repeat:
Run `make lint' in usr.bin/cdplay.
	
>Fix:
Fixes 48 warnings.

--- usr.bin/cdplay/cdplay.c.nolint	Fri Jun  6 01:39:21 2003
+++ usr.bin/cdplay/cdplay.c.lint	Sun Jun 15 16:32:43 2003
@@ -81,7 +81,7 @@
 	CMD_SKIP,
 	CMD_STATUS,
 	CMD_STOP,
-	CMD_VOLUME,
+	CMD_VOLUME
 };
 
 struct cmdtab {
@@ -131,20 +131,20 @@
 int	get_vol(int *, int *);
 int	get_status(int *, int *, int *, int *, int *);
 void	help(void);
-int	info(const char *);
-void	lba2msf(u_long, u_int *, u_int *, u_int *);
+int	info(void);
+void	lba2msf(u_int32_t, u_int *, u_int *, u_int *);
 int 	main(int, char **);
-u_int	msf2lba(u_int, u_int, u_int);
+u_int	msf2lba(u_char, u_char, u_char);
 int	opencd(void);
 const char   *parse(char *, int *);
 int	play(const char *, int);
 int	play_blocks(int, int);
-int	play_msf(int, int, int, int, int, int);
+int	play_msf(u_int, u_int, u_int, u_int, u_int, u_int);
 int	play_track(int, int, int, int);
-int	print_status(const char *);
+int	print_status(void);
 void	print_track(struct cd_toc_entry *);
 const char	*prompt(void);
-int	read_toc_entrys(int);
+int	read_toc_entries(u_int);
 int	run(int, const char *);
 int	setvol(int, int);
 void	sig_timer(int, int, struct sigcontext *);
@@ -165,7 +165,7 @@
 	int cmd, len, c;
 	char *line;
 	const char *elline;
-	int scratch, rv;
+	int scratch;
 	struct sigaction sa_timer;
 
 	cdname = getenv("MUSIC_CD");
@@ -197,8 +197,8 @@
 		cdname = defdev;
 	}
 
-	opencd();
-	srandom(time(NULL));
+	(void) opencd();
+	srandom((u_long)time(NULL));
 	
 	if (argc > 0) {
 		interactive = 0;
@@ -231,7 +231,7 @@
 	sigemptyset(&sa_timer.sa_mask);
 	sa_timer.sa_handler = (void (*)(int))sig_timer;
 	sa_timer.sa_flags = SA_RESTART;
-	if ((rv = sigaction(SIGALRM, &sa_timer, NULL)) < 0)
+	if (sigaction(SIGALRM, &sa_timer, NULL) < 0)
 		err(EXIT_FAILURE, "sigaction()");
 
 	for (;;) {
@@ -260,10 +260,10 @@
 			free(line);
 	}
 
+	/* NOTREACHED */
 	el_end(elptr);
 	history_end(hist);
 	exit(EXIT_SUCCESS);
-	/* NOTREACHED */
 }
 
 void
@@ -313,11 +313,11 @@
 
 	switch (cmd) {
 	case CMD_INFO:
-		rv = info(arg);
+		rv = info();
 		break;
 
 	case CMD_STATUS:
-		rv = print_status(arg);
+		rv = print_status();
 		break;
 
 	case CMD_PAUSE:
@@ -347,7 +347,7 @@
 
 	case CMD_EJECT:
 		if (shuffle)
-			run(CMD_SHUFFLE, NULL);
+			rv = run(CMD_SHUFFLE, NULL);
 		if (ioctl(fd, CDIOCALLOW) < 0)
 			warn("ioctl(CDIOCALLOW)");
 		if ((rv = ioctl(fd, CDIOCEJECT)) < 0)
@@ -355,7 +355,7 @@
 		break;
 
 	case CMD_CLOSE:
-		ioctl(fd, CDIOCALLOW);
+		(void) ioctl(fd, CDIOCALLOW);
 		if ((rv = ioctl(fd, CDIOCCLOSE)) >= 0) {
 			close(fd);
 			fd = -1;
@@ -388,7 +388,7 @@
 			itv_timer.it_value.tv_usec = 0;
 			if (setitimer(ITIMER_REAL, &itv_timer, NULL) == 0) {
 				shuffle = 1;
-				skip(0, 1);
+				rv = skip(0, 1);
 			}
 		} else {
 			itv_timer.it_interval.tv_sec = 0;
@@ -409,7 +409,7 @@
 		if (!shuffle)
 			warnx("`skip' valid only in shuffle mode");
 		else
-			skip(0, 1);
+			rv = skip(0, 1);
 		break;
 
 	case CMD_SET:
@@ -459,8 +459,8 @@
 int
 play(const char *arg, int fromuser)
 {
-	int rv, n, start, end, istart, iend, blk, len, relend;
-	u_int tr1, tr2, m1, m2, s1, s2, f1, f2, tm, ts, tf;
+	int rv, start, end, istart, iend, blk, len, relend;
+	u_int n, tr1, tr2, m1, m2, s1, s2, f1, f2, tm, ts, tf;
 	struct ioc_toc_header h;
 
 	if (shuffle && fromuser) {
@@ -476,7 +476,7 @@
 	end = 0;
 	istart = iend = 1;
 	n = h.ending_track - h.starting_track + 1;
-	rv = read_toc_entrys((n + 1) * sizeof(struct cd_toc_entry));
+	rv = read_toc_entries((n + 1) * sizeof(struct cd_toc_entry));
 	if (rv < 0)
 		return (rv);
 
@@ -685,12 +685,17 @@
 {
 	sigset_t anymore;
 
+#ifdef lint
+	sig = sig;
+	code = code;
+	scp = scp;
+#endif
 	sigpending(&anymore);
 	if (sigismember(&anymore, SIGALRM))
 		return;
-	setitimer(ITIMER_REAL, &itv_timer, NULL);
+	(void) setitimer(ITIMER_REAL, &itv_timer, NULL);
 	if (fd != -1)
-		skip(0, 0);
+		(void) skip(0, 0);
 }
 
 int
@@ -763,7 +768,7 @@
 }
 
 int
-print_status(const char *arg)
+print_status(void)
 {
 	struct cd_sub_channel_info data;
 	struct ioc_read_subchannel ss;
@@ -809,10 +814,11 @@
 }
 
 int
-info(const char *arg)
+info(void)
 {
 	struct ioc_toc_header h;
-	int rc, i, n;
+	int rc, i;
+	u_int n;
 
 	if ((rc = ioctl(fd, CDIOREADTOCHEADER, &h)) < 0) {
 		warn("ioctl(CDIOREADTOCHEADER)");
@@ -820,7 +826,7 @@
 	}
 
 	n = h.ending_track - h.starting_track + 1;
-	rc = read_toc_entrys((n + 1) * sizeof(struct cd_toc_entry));
+	rc = read_toc_entries((n + 1) * sizeof(struct cd_toc_entry));
 	if (rc < 0)
 		return (rc);
 
@@ -837,7 +843,7 @@
 }
 
 void
-lba2msf(u_long lba, u_int *m, u_int *s, u_int *f)
+lba2msf(u_int32_t lba, u_int *m, u_int *s, u_int *f)
 {
 
 	lba += 150;		/* block start offset */
@@ -849,7 +855,7 @@
 }
 
 u_int
-msf2lba(u_int m, u_int s, u_int f)
+msf2lba(u_char m, u_char s, u_char f)
 {
 
 	return (((m * 60) + s) * 75 + f) - 150;
@@ -858,7 +864,7 @@
 void
 print_track(struct cd_toc_entry *e)
 {
-	int block, next, len;
+	u_int32_t block, next, len;
 	u_int m, s, f;
 
 	if (msf) {
@@ -939,7 +945,7 @@
 }
 
 int
-read_toc_entrys(int len)
+read_toc_entries(u_int len)
 {
 	struct ioc_read_toc_entry t;
 	int rv;
@@ -955,8 +961,8 @@
 }
 
 int
-play_msf(int start_m, int start_s, int start_f, int end_m, int end_s,
-	 int end_f)
+play_msf(u_int start_m, u_int start_s, u_int start_f, u_int end_m, u_int end_s,
+	 u_int end_f)
 {
 	struct ioc_play_msf a;
 	int rv;
@@ -1021,7 +1027,7 @@
 {
 	const struct cmdtab *c, *mc;
 	char *p, *q;
-	int len;
+	u_int len;
 
 	for (p = buf; isspace(*p); p++)
 		continue;
@@ -1103,7 +1109,6 @@
 {
 	struct cd_toc_entry *ctep;
 
-	assert(i >= 0);
 	assert(i <= CD_MAX_TRACK);
 
 	ctep = &toc_buffer[i];
>Release-Note:
>Audit-Trail:
>Unformatted: