File: fix-compiler-warnings.patch

package info (click to toggle)
xtrs 4.9d-2
  • links: PTS
  • area: contrib
  • in suites: bookworm, bullseye, buster, sid
  • size: 5,480 kB
  • sloc: ansic: 72,545; makefile: 1,633; sh: 554; csh: 132
file content (197 lines) | stat: -rw-r--r-- 5,408 bytes parent folder | download
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
* Hoist volatile dummy variable into file scope to silence GCC warning
  about variable being set but not used.  See, e.g.,
    https://stackoverflow.com/questions/21688067/gcc-unused-but-set-variable-warning-on-volatile

* Explicitly declare int type on function arguments with implicit types.

* Get rid of unused variable in help window display function.

* Squash unused variable warnings in trs_cassette.c; add preprocessor
  guards to symbols used only when system support is available.  Work
  around dual usage of sb_address as a boolean (prefer SoundBlaster to
  OSS when both are available?) and a hardware address on x86.  Throw a
  warning the first time (each of) the cassette port or sound port is
  written to on systems where there is no supporting sound system for
  either.  Relocate some #if guards, and one static function so that
  there isn't a forward reference to it.  Rewrite a call to
  trs_orch90_out(0, FLUSH) to orch90_flush(FLUSH) (the former being
  exactly what orch90_flush() is defined as), which is how this forward
  reference was avoided before.  Add comment documenting why
  orch90_flush() takes an argument that it ignores.

-- Branden Robinson, 2018-08-08T02:59:45-0400
--- a/z80.c
+++ b/z80.c
@@ -2980,6 +2980,7 @@
 #define X_POLL_INTERVAL 10000
 
 int trs_continuous;
+volatile int dummy;
 
 int z80_run(int continuous)
      /*
@@ -3006,7 +3007,6 @@
 	}
         /* Speed control */
         if ((i = z80_state.delay)) {
-	  volatile int dummy;
 	  while (--i) dummy = i;
 	}
 
--- a/trs_memory.c
+++ b/trs_memory.c
@@ -154,7 +154,7 @@
     memory_map = which + (trs_model << 4) + (romin << 2);
 }
 
-void mem_romin(state)
+void mem_romin(int state)
 {
     romin = (state & 1);
     memory_map = (memory_map & ~4) + (romin << 2);
--- a/trs_xinterface.c
+++ b/trs_xinterface.c
@@ -706,10 +706,8 @@
 
   for (i = 0; NULL != helpitems[i]; i++) {
     size_t len;
-    int text_width;
 
     len = strlen(helpitems[i]);
-    text_width = XTextWidth(help_font_info, helpitems[i], len);
 
     XDrawString(display, help_window, help_gc, 10, text_line, helpitems[i],
 		len);
--- a/trs_disk.c
+++ b/trs_disk.c
@@ -3124,7 +3124,7 @@
 }
 
 void
-real_restore(curdrive)
+real_restore(int curdrive)
 {
 #if __linux
   DiskState *d = &disk[curdrive];
--- a/trs_printer.c
+++ b/trs_printer.c
@@ -18,7 +18,7 @@
 #include "z80.h"
 #include "trs.h"
 
-void trs_printer_write(value)
+void trs_printer_write(int value)
 {
     if(value == 0x0D)
     {
--- a/trs_cassette.c
+++ b/trs_cassette.c
@@ -234,17 +234,38 @@
 static long wave_datasize_offset = WAVE_DATASIZE_OFFSET;
 static long wave_data_offset = WAVE_DATA_OFFSET;
 
-/* Orchestra 80/85/90 stuff */
-static int orch90_left = 128, orch90_right = 128;
-
 #if SB_SOUND
 /* ioport of the SoundBlaster command register. 0 means none */
 static unsigned char sb_cassette_volume[4];
 static unsigned char sb_sound_volume[2];
 #endif /*SB_SOUND*/
-static unsigned int sb_address=0;
 static int sb_volume = 0;
 
+#if !SB_SOUND && !HAVE_OSS
+static int warn_on_cassette_output_failure = 1;
+static int warn_on_sound_output_failure = 1;
+#else
+/* sb_address is used if _either_ SB_SOUND or HAVE_OSS is defined. */
+static unsigned int sb_address = 0;
+#endif
+
+/* Orchestra 85/90 */
+/* Not supported in obsolescent SB_SOUND mode */
+/* Implementation shares some global state with cassette and game
+   sound implementations. */
+#if HAVE_OSS
+static int orch90_left = 128, orch90_right = 128;
+
+/* The dummy argument is due to the trs event scheduler; see
+   trs_schedule_event() in trs_interrupt.c.  */
+static void
+orch90_flush(int dummy)
+{
+  trs_orch90_out(0, FLUSH);
+}
+#endif
+
+
 /* Put a 2-byte quantity to a file in little-endian order */
 /* Return -1 on error, 0 otherwise */
 static int
@@ -561,7 +582,9 @@
 #endif
 
   if (cassette_state == ORCH90) {
-    trs_orch90_out(0, FLUSH);
+#if HAVE_OSS
+    orch90_flush(FLUSH);
+#endif
   }
 
   if (cassette_state != CLOSE && cassette_state != FAILED) {
@@ -1185,8 +1208,7 @@
     while (inb(sb_address + 0xC) & 0x80) /*poll*/ ;
     outb(sb_cassette_volume[value], sb_address + 0xC);
   }
-#endif
-#if OSS_SOUND && HAVE_OSS
+#elif OSS_SOUND && HAVE_OSS
   /* Do sound emulation by sending samples to /dev/dsp */
   if (cassette_motor == 0 && !sb_address) {
     if (cassette_state != SOUND && value == 0) return;
@@ -1194,6 +1216,11 @@
     trs_suspend_delay();
     transition_out(value);
   }
+#else
+  if (warn_on_cassette_output_failure) {
+    warn("no host system sound support for emulated cassete port");
+    warn_on_cassette_output_failure = 0;
+  }
 #endif
 }
 
@@ -1210,26 +1237,20 @@
     while (inb(sb_address + 0xC) & 0x80) /*poll*/ ;
     outb(sb_sound_volume[value], sb_address + 0xC);
   }
-#endif
-#if HAVE_OSS
+#elif HAVE_OSS
   if (cassette_motor == 0 && !sb_address) {
     if (assert_state(SOUND) < 0) return;
     trs_suspend_delay();
     transition_out(value ? 1 : 2);
   }
+#else
+  if (warn_on_sound_output_failure) {
+    warn("no host system sound support for emulated sound port");
+    warn_on_sound_output_failure = 0;
+  }
 #endif
 }
 
-static void
-orch90_flush(int dummy)
-{
-  trs_orch90_out(0, FLUSH);
-}
-
-/* Orchestra 85/90 */
-/* Not supported in obsolescent SB_SOUND mode */
-/* Implementation shares some global state with cassette and game
-   sound implementations. */
 void
 trs_orch90_out(int channels, int value)
 {