Wed Mar 4 13:34:49 2015 UTC ()
PR/49716: Henning Petersen: Use false and true on bool, fix sign in printf
formats.


(christos)
diff -r1.7 -r1.8 src/usr.bin/midirecord/midirecord.c

cvs diff -r1.7 -r1.8 src/usr.bin/midirecord/midirecord.c (expand / switch to unified diff)

--- src/usr.bin/midirecord/midirecord.c 2015/03/01 09:56:54 1.7
+++ src/usr.bin/midirecord/midirecord.c 2015/03/04 13:34:49 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: midirecord.c,v 1.7 2015/03/01 09:56:54 mrg Exp $ */ 1/* $NetBSD: midirecord.c,v 1.8 2015/03/04 13:34:49 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2014 Matthew R. Green 4 * Copyright (c) 2014 Matthew R. Green
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -23,27 +23,27 @@ @@ -23,27 +23,27 @@
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29/* 29/*
30 * midirecord(1), similar to audiorecord(1). 30 * midirecord(1), similar to audiorecord(1).
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34 34
35#ifndef lint 35#ifndef lint
36__RCSID("$NetBSD: midirecord.c,v 1.7 2015/03/01 09:56:54 mrg Exp $"); 36__RCSID("$NetBSD: midirecord.c,v 1.8 2015/03/04 13:34:49 christos Exp $");
37#endif 37#endif
38 38
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/midiio.h> 40#include <sys/midiio.h>
41#include <sys/ioctl.h> 41#include <sys/ioctl.h>
42#include <sys/time.h> 42#include <sys/time.h>
43#include <sys/uio.h> 43#include <sys/uio.h>
44 44
45#include <err.h> 45#include <err.h>
46#include <errno.h> 46#include <errno.h>
47#include <ctype.h> 47#include <ctype.h>
48#include <fcntl.h> 48#include <fcntl.h>
49#include <paths.h> 49#include <paths.h>
@@ -112,27 +112,27 @@ main(int argc, char *argv[]) @@ -112,27 +112,27 @@ main(int argc, char *argv[])
112 switch (ch) { 112 switch (ch) {
113 case 'a': 113 case 'a':
114 aflag++; 114 aflag++;
115 break; 115 break;
116 case 'B': 116 case 'B':
117 bufsize = strsuftoll("read buffer size", optarg, 117 bufsize = strsuftoll("read buffer size", optarg,
118 1, UINT_MAX); 118 1, UINT_MAX);
119 break; 119 break;
120 case 'c': 120 case 'c':
121 parse_ints(optarg, &filt_chans, &num_filt_chans, 121 parse_ints(optarg, &filt_chans, &num_filt_chans,
122 "channels"); 122 "channels");
123 break; 123 break;
124 case 'D': 124 case 'D':
125 debug++; 125 debug = true;
126 break; 126 break;
127 case 'd': 127 case 'd':
128 parse_ints(optarg, &filt_devnos, &num_filt_devnos, 128 parse_ints(optarg, &filt_devnos, &num_filt_devnos,
129 "devices"); 129 "devices");
130 break; 130 break;
131 case 'f': 131 case 'f':
132 midi_device = optarg; 132 midi_device = optarg;
133 ignore_timer_fail = true; 133 ignore_timer_fail = true;
134 break; 134 break;
135 case 'n': 135 case 'n':
136 decode_uint(optarg, &notes_per_beat); 136 decode_uint(optarg, &notes_per_beat);
137 break; 137 break;
138 case 'o': 138 case 'o':
@@ -227,27 +227,27 @@ main(int argc, char *argv[]) @@ -227,27 +227,27 @@ main(int argc, char *argv[])
227 /* set the tempo */ 227 /* set the tempo */
228 if (ioctl(midifd, SEQUENCER_TMR_TEMPO, &tempo) < 0) { 228 if (ioctl(midifd, SEQUENCER_TMR_TEMPO, &tempo) < 0) {
229 if (ignore_timer_fail) 229 if (ignore_timer_fail)
230 warn("SEQUENCER_TMR_TIMEBASE: tempo %d", tempo); 230 warn("SEQUENCER_TMR_TIMEBASE: tempo %d", tempo);
231 else 231 else
232 err(1, "SEQUENCER_TMR_TIMEBASE: tempo %d", tempo); 232 err(1, "SEQUENCER_TMR_TIMEBASE: tempo %d", tempo);
233 } 233 }
234 234
235 signal(SIGINT, cleanup); 235 signal(SIGINT, cleanup);
236 236
237 data_size = 0; 237 data_size = 0;
238 238
239 if (verbose) 239 if (verbose)
240 fprintf(stderr, "tempo=%d notes_per_beat=%d\n", 240 fprintf(stderr, "tempo=%d notes_per_beat=%u\n",
241 tempo, notes_per_beat); 241 tempo, notes_per_beat);
242 242
243 if (!no_time_limit && verbose) 243 if (!no_time_limit && verbose)
244 fprintf(stderr, "recording for %lu seconds, %lu microseconds\n", 244 fprintf(stderr, "recording for %lu seconds, %lu microseconds\n",
245 (u_long)record_time.tv_sec, (u_long)record_time.tv_usec); 245 (u_long)record_time.tv_sec, (u_long)record_time.tv_usec);
246 246
247 /* Create a midi header. */ 247 /* Create a midi header. */
248 write_midi_header(); 248 write_midi_header();
249 249
250 (void)gettimeofday(&start_time, NULL); 250 (void)gettimeofday(&start_time, NULL);
251 while (no_time_limit || timeleft(&start_time, &record_time)) { 251 while (no_time_limit || timeleft(&start_time, &record_time)) {
252 seq_event_t e; 252 seq_event_t e;
253 size_t wrsize; 253 size_t wrsize;
@@ -272,27 +272,27 @@ main(int argc, char *argv[]) @@ -272,27 +272,27 @@ main(int argc, char *argv[])
272 data_size += wrsize; 272 data_size += wrsize;
273 } 273 }
274 } 274 }
275 cleanup(0); 275 cleanup(0);
276} 276}
277 277
278static void 278static void
279debug_log(const char *file, size_t line, const char *fmt, ...) 279debug_log(const char *file, size_t line, const char *fmt, ...)
280{ 280{
281 va_list ap; 281 va_list ap;
282 282
283 if (!debug) 283 if (!debug)
284 return; 284 return;
285 fprintf(stderr, "%s:%zd: ", file, line); 285 fprintf(stderr, "%s:%zu: ", file, line);
286 va_start(ap, fmt); 286 va_start(ap, fmt);
287 vfprintf(stderr, fmt, ap); 287 vfprintf(stderr, fmt, ap);
288 va_end(ap); 288 va_end(ap);
289 fprintf(stderr, "\n"); 289 fprintf(stderr, "\n");
290} 290}
291 291
292#define LOG(fmt...) \ 292#define LOG(fmt...) \
293 debug_log(__func__, __LINE__, fmt) 293 debug_log(__func__, __LINE__, fmt)
294 294
295 295
296/* 296/*
297 * handle a SEQ_LOCAL event. NetBSD /dev/music doesn't generate these. 297 * handle a SEQ_LOCAL event. NetBSD /dev/music doesn't generate these.
298 */ 298 */