To support this change, turn on lots more compiler warnings, and fix all the warnings generated.
Showing the changes to src/aiff.c (1 of 93 files). Show all
Unified · Split
| @@ -74,7 +74,7 @@ static int textChunk(char **text, char *chunkDescription, ft_t ft); · 73 unmodified lines | |||
| 74 | static int commentChunk(char **text, char *chunkDescription, ft_t ft); | 74 | static int commentChunk(char **text, char *chunkDescription, ft_t ft); |
| 75 | static void reportInstrument(ft_t ft); | 75 | static void reportInstrument(ft_t ft); |
| 76 | 76 | ||
| 77 | int st_aiffseek(ft_t ft, st_size_t offset) | 77 | static int st_aiffseek(ft_t ft, st_size_t offset) |
| 78 | { | 78 | { |
| 79 | aiff_t aiff = (aiff_t ) ft->priv; | 79 | aiff_t aiff = (aiff_t ) ft->priv; |
| 80 | st_size_t new_offset, channel_block, alignment; | 80 | st_size_t new_offset, channel_block, alignment; |
| @@ -99,7 +99,7 @@ int st_aiffseek(ft_t ft, st_size_t offset) · 18 unmodified lines | |||
| 99 | return(ft->st_errno); | 99 | return(ft->st_errno); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | int st_aiffstartread(ft_t ft) | 102 | static int st_aiffstartread(ft_t ft) |
| 103 | { | 103 | { |
| 104 | aiff_t aiff = (aiff_t ) ft->priv; | 104 | aiff_t aiff = (aiff_t ) ft->priv; |
| 105 | char buf[5]; | 105 | char buf[5]; |
| @@ -408,7 +408,7 @@ int st_aiffstartread(ft_t ft) · 302 unmodified lines | |||
| 408 | if (foundcomm) { | 408 | if (foundcomm) { |
| 409 | ft->info.channels = channels; | 409 | ft->info.channels = channels; |
| 410 | ft->info.rate = rate; | 410 | ft->info.rate = rate; |
| 411 | if (ft->info.encoding != -1 && ft->info.encoding != ST_ENCODING_SIGN2) | 411 | if (ft->info.encoding != ST_ENCODING_UNKNOWN && ft->info.encoding != ST_ENCODING_SIGN2) |
| 412 | st_report("AIFF only supports signed data. Forcing to signed."); | 412 | st_report("AIFF only supports signed data. Forcing to signed."); |
| 413 | ft->info.encoding = ST_ENCODING_SIGN2; | 413 | ft->info.encoding = ST_ENCODING_SIGN2; |
| 414 | if (bits <= 8) | 414 | if (bits <= 8) |
| @@ -441,9 +441,9 @@ int st_aiffstartread(ft_t ft) · 26 unmodified lines | |||
| 441 | return(ST_EOF); | 441 | return(ST_EOF); |
| 442 | } | 442 | } |
| 443 | } else { | 443 | } else { |
| 444 | if ((ft->info.channels == -1) | 444 | if ((ft->info.channels == 0) |
| 445 | || (ft->info.rate == 0) | 445 | || (ft->info.rate == 0) |
| 446 | || (ft->info.encoding == -1) | 446 | || (ft->info.encoding == ST_ENCODING_UNKNOWN) |
| 447 | || (ft->info.size == -1)) { | 447 | || (ft->info.size == -1)) { |
| 448 | st_report("You must specify # channels, sample rate, signed/unsigned,"); | 448 | st_report("You must specify # channels, sample rate, signed/unsigned,"); |
| 449 | st_report("and 8/16 on the command line."); | 449 | st_report("and 8/16 on the command line."); |
| @@ -633,7 +633,7 @@ static int commentChunk(char **text, char *chunkDescription, ft_t ft) · 183 unmodified lines | |||
| 633 | st_debug("%-10s \"%s\"", chunkDescription, *text); | 633 | st_debug("%-10s \"%s\"", chunkDescription, *text); |
| 634 | /* make sure we read the whole chunk */ | 634 | /* make sure we read the whole chunk */ |
| 635 | if (totalReadLength < chunksize) { | 635 | if (totalReadLength < chunksize) { |
| 636 | int i; | 636 | size_t i; |
| 637 | char c; | 637 | char c; |
| 638 | for (i=0; i < chunksize - totalReadLength; i++ ) { | 638 | for (i=0; i < chunksize - totalReadLength; i++ ) { |
| 639 | st_readbuf(ft, &c, 1, 1); | 639 | st_readbuf(ft, &c, 1, 1); |
| @@ -642,14 +642,12 @@ static int commentChunk(char **text, char *chunkDescription, ft_t ft) · 2 unmodified lines | |||
| 642 | return(ST_SUCCESS); | 642 | return(ST_SUCCESS); |
| 643 | } | 643 | } |
| 644 | 644 | ||
| 645 | st_ssize_t st_aiffread(ft_t ft, st_sample_t *buf, st_size_t len) | 645 | static st_size_t st_aiffread(ft_t ft, st_sample_t *buf, st_size_t len) |
| 646 | { | 646 | { |
| 647 | aiff_t aiff = (aiff_t ) ft->priv; | 647 | aiff_t aiff = (aiff_t ) ft->priv; |
| 648 | st_ssize_t done; | 648 | st_ssize_t done; |
| 649 | 649 | ||
| 650 | if (len < 0) | 650 | if ((st_size_t)len > aiff->nsamples) |
| 651 | return ST_EOF; | ||
| 652 | else if ((st_size_t)len > aiff->nsamples) | ||
| 653 | len = aiff->nsamples; | 651 | len = aiff->nsamples; |
| 654 | done = st_rawread(ft, buf, len); | 652 | done = st_rawread(ft, buf, len); |
| 655 | if (done == 0 && aiff->nsamples != 0) | 653 | if (done == 0 && aiff->nsamples != 0) |
| @@ -658,7 +656,7 @@ st_ssize_t st_aiffread(ft_t ft, st_sample_t *buf, st_size_t len) · 2 unmodified lines | |||
| 658 | return done; | 656 | return done; |
| 659 | } | 657 | } |
| 660 | 658 | ||
| 661 | int st_aiffstopread(ft_t ft) | 659 | static int st_aiffstopread(ft_t ft) |
| 662 | { | 660 | { |
| 663 | char buf[5]; | 661 | char buf[5]; |
| 664 | uint32_t chunksize; | 662 | uint32_t chunksize; |
| @@ -701,7 +699,7 @@ int st_aiffstopread(ft_t ft) · 36 unmodified lines | |||
| 701 | Strictly spoken this is not legal, but the playaiff utility | 699 | Strictly spoken this is not legal, but the playaiff utility |
| 702 | will still be able to play the resulting file. */ | 700 | will still be able to play the resulting file. */ |
| 703 | 701 | ||
| 704 | int st_aiffstartwrite(ft_t ft) | 702 | static int st_aiffstartwrite(ft_t ft) |
| 705 | { | 703 | { |
| 706 | aiff_t aiff = (aiff_t ) ft->priv; | 704 | aiff_t aiff = (aiff_t ) ft->priv; |
| 707 | int rc; | 705 | int rc; |
| @@ -726,7 +724,7 @@ int st_aiffstartwrite(ft_t ft) · 18 unmodified lines | |||
| 726 | ft->info.encoding = ST_ENCODING_SIGN2; | 724 | ft->info.encoding = ST_ENCODING_SIGN2; |
| 727 | ft->info.size = ST_SIZE_WORD; | 725 | ft->info.size = ST_SIZE_WORD; |
| 728 | } | 726 | } |
| 729 | if (ft->info.encoding != -1 && ft->info.encoding != ST_ENCODING_SIGN2) | 727 | if (ft->info.encoding != ST_ENCODING_UNKNOWN && ft->info.encoding != ST_ENCODING_SIGN2) |
| 730 | st_report("AIFF only supports signed data. Forcing to signed."); | 728 | st_report("AIFF only supports signed data. Forcing to signed."); |
| 731 | ft->info.encoding = ST_ENCODING_SIGN2; /* We have a fixed encoding */ | 729 | ft->info.encoding = ST_ENCODING_SIGN2; /* We have a fixed encoding */ |
| 732 | 730 | ||
| @@ -739,7 +737,7 @@ int st_aiffstartwrite(ft_t ft) · 6 unmodified lines | |||
| 739 | return(aiffwriteheader(ft, 0x7f000000L / (ft->info.size*ft->info.channels))); | 737 | return(aiffwriteheader(ft, 0x7f000000L / (ft->info.size*ft->info.channels))); |
| 740 | } | 738 | } |
| 741 | 739 | ||
| 742 | st_ssize_t st_aiffwrite(ft_t ft, const st_sample_t *buf, st_size_t len) | 740 | static st_size_t st_aiffwrite(ft_t ft, const st_sample_t *buf, st_size_t len) |
| 743 | { | 741 | { |
| 744 | aiff_t aiff = (aiff_t ) ft->priv; | 742 | aiff_t aiff = (aiff_t ) ft->priv; |
| 745 | aiff->nsamples += len; | 743 | aiff->nsamples += len; |
| @@ -747,7 +745,7 @@ st_ssize_t st_aiffwrite(ft_t ft, const st_sample_t *buf, st_size_t len) · 1 unmodified line | |||
| 747 | return(len); | 745 | return(len); |
| 748 | } | 746 | } |
| 749 | 747 | ||
| 750 | int st_aiffstopwrite(ft_t ft) | 748 | static int st_aiffstopwrite(ft_t ft) |
| 751 | { | 749 | { |
| 752 | aiff_t aiff = (aiff_t ) ft->priv; | 750 | aiff_t aiff = (aiff_t ) ft->priv; |
| 753 | int rc; | 751 | int rc; |
| @@ -914,7 +912,7 @@ static int aiffwriteheader(ft_t ft, st_size_t nframes) · 160 unmodified lines | |||
| 914 | return(ST_SUCCESS); | 912 | return(ST_SUCCESS); |
| 915 | } | 913 | } |
| 916 | 914 | ||
| 917 | int st_aifcstartwrite(ft_t ft) | 915 | static int st_aifcstartwrite(ft_t ft) |
| 918 | { | 916 | { |
| 919 | aiff_t aiff = (aiff_t ) ft->priv; | 917 | aiff_t aiff = (aiff_t ) ft->priv; |
| 920 | int rc; | 918 | int rc; |
| @@ -939,7 +937,7 @@ int st_aifcstartwrite(ft_t ft) · 18 unmodified lines | |||
| 939 | ft->info.encoding = ST_ENCODING_SIGN2; | 937 | ft->info.encoding = ST_ENCODING_SIGN2; |
| 940 | ft->info.size = ST_SIZE_WORD; | 938 | ft->info.size = ST_SIZE_WORD; |
| 941 | } | 939 | } |
| 942 | if (ft->info.encoding != -1 && ft->info.encoding != ST_ENCODING_SIGN2) | 940 | if (ft->info.encoding != ST_ENCODING_UNKNOWN && ft->info.encoding != ST_ENCODING_SIGN2) |
| 943 | st_report("AIFC only supports signed data. Forcing to signed."); | 941 | st_report("AIFC only supports signed data. Forcing to signed."); |
| 944 | ft->info.encoding = ST_ENCODING_SIGN2; /* We have a fixed encoding */ | 942 | ft->info.encoding = ST_ENCODING_SIGN2; /* We have a fixed encoding */ |
| 945 | 943 | ||
| @@ -952,7 +950,7 @@ int st_aifcstartwrite(ft_t ft) · 6 unmodified lines | |||
| 952 | return(aifcwriteheader(ft, 0x7f000000L / (ft->info.size*ft->info.channels))); | 950 | return(aifcwriteheader(ft, 0x7f000000L / (ft->info.size*ft->info.channels))); |
| 953 | } | 951 | } |
| 954 | 952 | ||
| 955 | int st_aifcstopwrite(ft_t ft) | 953 | static int st_aifcstopwrite(ft_t ft) |
| 956 | { | 954 | { |
| 957 | aiff_t aiff = (aiff_t ) ft->priv; | 955 | aiff_t aiff = (aiff_t ) ft->priv; |
| 958 | int rc; | 956 | int rc; |