History

Fix read and write return types: now st_size_t, like the size inputs.

To support this change, turn on lots more compiler warnings, and fix all the warnings generated.

rrt committed 19 years ago

Commit 4d743c41 parent ce1f8f393 files · +875 −1236Browse files

Showing the changes to src/raw.c (1 of 93 files). Show all

Unified · Split

src/raw.c+36−42
@@ -134,7 +134,7 @@ int st_rawstartwrite(ft_t ft) · 133 unmodified lines
134134 return ST_SUCCESS;
135135 }
136136
137−void st_ub_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
137+void st_ub_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount UNUSED)
138138 {
139139 while (len)
140140 {
@@ -148,7 +148,7 @@ void st_ub_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char sw · 7 unmodified lines
148148 }
149149 }
150150
151−void st_sb_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
151+void st_sb_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount UNUSED)
152152 {
153153 while (len)
154154 {
@@ -162,7 +162,7 @@ void st_sb_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char sw · 7 unmodified lines
162162 }
163163 }
164164
165−void st_ulaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
165+static void st_ulaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount UNUSED)
166166 {
167167 while (len)
168168 {
@@ -176,7 +176,7 @@ void st_ulaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char · 7 unmodified lines
176176 }
177177 }
178178
179−void st_alaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
179+static void st_alaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount UNUSED)
180180 {
181181 while (len)
182182 {
@@ -190,7 +190,7 @@ void st_alaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char · 7 unmodified lines
190190 }
191191 }
192192
193−void st_inv_ulaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
193+static void st_inv_ulaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount UNUSED)
194194 {
195195 while (len)
196196 {
@@ -204,7 +204,7 @@ void st_inv_ulaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, c · 7 unmodified lines
204204 }
205205 }
206206
207−void st_inv_alaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
207+static void st_inv_alaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount UNUSED)
208208 {
209209 while (len)
210210 {
@@ -219,7 +219,7 @@ void st_inv_alaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, c · 8 unmodified lines
219219 }
220220
221221
222−void st_uw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
222+void st_uw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount UNUSED)
223223 {
224224 while (len)
225225 {
@@ -235,7 +235,7 @@ void st_uw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char sw · 9 unmodified lines
235235 }
236236 }
237237
238−void st_sw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
238+void st_sw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount UNUSED)
239239 {
240240 while (len)
241241 {
@@ -266,12 +266,12 @@ static int24_t st_24_read_one(char const * * buffer, char swap) · 24 unmodified lines
266266 datum >>= 8;
267267 }
268268
269− return swap? st_swap24(datum) : datum;
269+ return swap ? (int24_t)(st_swap24(datum)) : datum;
270270 }
271271
272272
273273
274−void st_u24_read_buf(st_sample_t * buf1, char const * buf2, st_size_t len, char const swap, st_size_t * clippedCount)
274+static void st_u24_read_buf(st_sample_t * buf1, char const * buf2, st_size_t len, char const swap, st_size_t * clippedCount UNUSED)
275275 {
276276 while (len--)
277277 {
@@ -282,7 +282,7 @@ void st_u24_read_buf(st_sample_t * buf1, char const * buf2, st_size_t len, char · 4 unmodified lines
282282
283283
284284
285−void st_s24_read_buf(st_sample_t * buf1, char const * buf2, st_size_t len, char const swap, st_size_t * clippedCount)
285+static void st_s24_read_buf(st_sample_t * buf1, char const * buf2, st_size_t len, char const swap, st_size_t * clippedCount UNUSED)
286286 {
287287 while (len--)
288288 {
@@ -293,7 +293,7 @@ void st_s24_read_buf(st_sample_t * buf1, char const * buf2, st_size_t len, char · 4 unmodified lines
293293
294294
295295
296−void st_udw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
296+static void st_udw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount UNUSED)
297297 {
298298 while (len)
299299 {
@@ -309,7 +309,7 @@ void st_udw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char s · 9 unmodified lines
309309 }
310310 }
311311
312−void st_dw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
312+static void st_dw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount UNUSED)
313313 {
314314 while (len)
315315 {
@@ -325,7 +325,7 @@ void st_dw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char sw · 9 unmodified lines
325325 }
326326 }
327327
328−void st_f32_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
328+static void st_f32_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
329329 {
330330 while (len)
331331 {
@@ -341,7 +341,7 @@ void st_f32_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char s · 9 unmodified lines
341341 }
342342 }
343343
344−void st_f64_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
344+static void st_f64_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
345345 {
346346 while (len)
347347 {
@@ -366,18 +366,12 @@ void st_f64_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char s · 18 unmodified lines
366366 * functions will cause a loss of data! Need to have sox implement
367367 * a consistent buffering protocol.
368368 */
369−st_ssize_t st_rawread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
369+st_size_t st_rawread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
370370 {
371371 st_size_t len, done = 0;
372372 void (*read_buf)(st_sample_t *, char const *, st_size_t, char, st_size_t *) = 0;
373373 size_t i;
374374
375− if (nsamp < 0)
376− {
377− st_fail_errno(ft,ST_EINVAL,"st_rawread requires positive sizes");
378− return ST_EOF;
379− }
380−
381375 switch(ft->info.size) {
382376 case ST_SIZE_BYTE:
383377 switch(ft->info.encoding)
@@ -527,7 +521,7 @@ int st_rawstopread(ft_t ft) · 143 unmodified lines
527521 return ST_SUCCESS;
528522 }
529523
530−void st_ub_write_buf(char* buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
524+void st_ub_write_buf(char* buf1, st_sample_t const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount)
531525 {
532526 while (len)
533527 {
@@ -536,7 +530,7 @@ void st_ub_write_buf(char* buf1, st_sample_t const * buf2, st_size_t len, char s · 2 unmodified lines
536530 }
537531 }
538532
539−void st_sb_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
533+void st_sb_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount)
540534 {
541535 while (len)
542536 {
@@ -545,8 +539,8 @@ void st_sb_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char s · 2 unmodified lines
545539 }
546540 }
547541
548−void st_ulaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
549− char swap, st_size_t * clippedCount)
542+static void st_ulaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
543+ char swap UNUSED, st_size_t * clippedCount)
550544 {
551545 while (len)
552546 {
@@ -555,8 +549,8 @@ void st_ulaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, · 2 unmodified lines
555549 }
556550 }
557551
558−void st_alaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
559− char swap, st_size_t * clippedCount)
552+static void st_alaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
553+ char swap UNUSED, st_size_t * clippedCount)
560554 {
561555 while (len)
562556 {
@@ -565,8 +559,8 @@ void st_alaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, · 2 unmodified lines
565559 }
566560 }
567561
568−void st_inv_ulaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
569− char swap, st_size_t * clippedCount)
562+static void st_inv_ulaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
563+ char swap UNUSED, st_size_t * clippedCount)
570564 {
571565 while (len)
572566 {
@@ -575,8 +569,8 @@ void st_inv_ulaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, · 2 unmodified lines
575569 }
576570 }
577571
578−void st_inv_alaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
579− char swap, st_size_t * clippedCount)
572+static void st_inv_alaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
573+ char swap UNUSED, st_size_t * clippedCount)
580574 {
581575 while (len)
582576 {
@@ -639,7 +633,7 @@ static void st_24_write_one(char * * const buf1, int24_t datum, char const swap) · 56 unmodified lines
639633
640634
641635
642−void st_u24_write_buf(char * buf1, st_sample_t const * buf2, st_size_t len, char const swap, st_size_t * clippedCount)
636+static void st_u24_write_buf(char * buf1, st_sample_t const * buf2, st_size_t len, char const swap, st_size_t * clippedCount)
643637 {
644638 while (len--)
645639 {
@@ -650,7 +644,7 @@ void st_u24_write_buf(char * buf1, st_sample_t const * buf2, st_size_t len, char · 4 unmodified lines
650644
651645
652646
653−void st_s24_write_buf(char * buf1, st_sample_t const * buf2, st_size_t len, char const swap, st_size_t * clippedCount)
647+static void st_s24_write_buf(char * buf1, st_sample_t const * buf2, st_size_t len, char const swap, st_size_t * clippedCount)
654648 {
655649 while (len--)
656650 {
@@ -661,7 +655,7 @@ void st_s24_write_buf(char * buf1, st_sample_t const * buf2, st_size_t len, char · 4 unmodified lines
661655
662656
663657
664−void st_udw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
658+static void st_udw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount UNUSED)
665659 {
666660 while (len)
667661 {
@@ -677,7 +671,7 @@ void st_udw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char · 9 unmodified lines
677671 }
678672 }
679673
680−void st_dw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
674+static void st_dw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount UNUSED)
681675 {
682676 while (len)
683677 {
@@ -693,7 +687,7 @@ void st_dw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char s · 9 unmodified lines
693687 }
694688 }
695689
696−void st_f32_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
690+static void st_f32_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
697691 {
698692 while (len)
699693 {
@@ -709,7 +703,7 @@ void st_f32_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char · 9 unmodified lines
709703 }
710704 }
711705
712−void st_f64_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
706+static void st_f64_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
713707 {
714708 while (len)
715709 {
@@ -744,7 +738,7 @@ static void writeflush(ft_t ft) · 28 unmodified lines
744738 * functions will cause a loss of data! Need to have sox implement
745739 * a consistent buffering protocol.
746740 */
747−st_ssize_t st_rawwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
741+st_size_t st_rawwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
748742 {
749743 st_size_t len, done = 0;
750744 void (*write_buf)(char *, st_sample_t const *, st_size_t, char, st_size_t *) = 0;
@@ -873,7 +867,7 @@ int st_rawstopwrite(ft_t ft) · 122 unmodified lines
873867 */
874868
875869 #define STARTREAD(NAME,SIZE,STYLE) \
876−int NAME(ft_t ft) \
870+static int NAME(ft_t ft) \
877871 { \
878872 ft->info.size = SIZE; \
879873 ft->info.encoding = STYLE; \
@@ -882,7 +876,7 @@ int NAME(ft_t ft) \ · 2 unmodified lines
882876 }
883877
884878 #define STARTWRITE(NAME,SIZE,STYLE)\
885−int NAME(ft_t ft) \
879+static int NAME(ft_t ft) \
886880 { \
887881 ft->info.size = SIZE; \
888882 ft->info.encoding = STYLE; \
@@ -930,7 +924,7 @@ void rawdefaults(ft_t ft) · 41 unmodified lines
930924 {
931925 if (ft->info.rate == 0)
932926 ft->info.rate = 8000;
933− if (ft->info.channels == -1)
927+ if (ft->info.channels == 0)
934928 ft->info.channels = 1;
935929 }
936930

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t