File: add-warning-diagnostic-function.patch

package info (click to toggle)
xtrs 4.9d-3
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 5,484 kB
  • sloc: ansic: 72,545; makefile: 1,633; sh: 554; csh: 132
file content (70 lines) | stat: -rw-r--r-- 1,955 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
A few places in the code were calling error() with "warning:" in the
argument string, which looked weird.

Make a warn() function for these use cases.

G. Branden Robinson <g.branden.robinson@gmail.com>

--- a/error.c
+++ b/error.c
@@ -67,3 +67,17 @@
   va_end(args);
   exit(1);
 }
+
+void warn(const char *fmt, ...)
+{
+  va_list args;
+  char xfmt[2048];
+
+  strcpy(xfmt, program_name);
+  strcat(xfmt, " warning: ");
+  strcat(xfmt, fmt);
+  strcat(xfmt, "\n");
+  va_start(args, fmt);
+  vfprintf(stderr, xfmt, args);
+  va_end(args);
+}
--- a/trs_cassette.c
+++ b/trs_cassette.c
@@ -675,8 +675,7 @@
 	/*int arg = 0x7fff0008;*/ /* unlimited fragments of size (1 << 8) */
 	int arg = 0x00200008; /* 32 fragments of size (1 << 8) */
 	if (ioctl(fileno(cassette_file), SNDCTL_DSP_SETFRAGMENT, &arg) < 0) {
-	  error("warning: couldn't set sound fragment size: %s",
-		strerror(errno));
+	  warn("couldn't set sound fragment size: %s", strerror(errno));
 	}
       }
 #endif
--- a/trs_disk.c
+++ b/trs_disk.c
@@ -1761,7 +1761,7 @@
 	} else {
 	  /* We do not have a flag for this; try using CRC error */
 	  d->u.jv3.id[state.format_sec].flags |= JV3_ERROR;
-	  error("warning: recording false sector ID as CRC error");
+	  warn("recording false sector ID as CRC error");
 
 	  /* Write the sector id */
 	  fseek(d->file, idoffset(d, state.format_sec), 0);
@@ -2030,7 +2030,7 @@
 	  trs_disk_unimpl(state.currcommand, "false sector ID (no data)");
 	} else {
 	  /* We do not have a flag for this; try using CRC error */
-	  error("warning: recording false sector ID as CRC error");
+	  warn("recording false sector ID as CRC error");
 	  d->u.jv3.id[state.format_sec].flags |= JV3_ERROR;
 
 	  /* Write the sector id */
--- a/trs_interrupt.c
+++ b/trs_interrupt.c
@@ -496,7 +496,7 @@
 {
     while (event_func) {
 #if EDEBUG	
-	error("warning: trying to schedule two events");
+	warn("trying to schedule two events");
 #endif
 	trs_do_event();
     }