Commit 27e13541 authored by Josh Coalson's avatar Josh Coalson
Browse files

C89 standard fixes, based on feedback from IRIX port

parent 1e70455a
......@@ -1404,9 +1404,9 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
fmt= RAW;
}
else {
if(!strncmp(lookahead, "RIFF", 4) && !strncmp(lookahead+8, "WAVE", 4))
if(!strncmp((const char *)lookahead, "RIFF", 4) && !strncmp((const char *)lookahead+8, "WAVE", 4))
fmt= WAV;
else if(!strncmp(lookahead, "FORM", 4) && !strncmp(lookahead+8, "AIFF", 4))
else if(!strncmp((const char *)lookahead, "FORM", 4) && !strncmp((const char *)lookahead+8, "AIFF", 4))
fmt= AIF;
else {
if(fmt != RAW)
......
......@@ -109,10 +109,10 @@ static FLAC__bool set_vc_field(FLAC__StreamMetadata *block, const Argument_VcFie
FLAC__ASSERT(0 != needs_write);
if(raw) {
entry.entry = field->field;
entry.entry = (FLAC__byte *)field->field;
}
else if(utf8_encode(field->field, &converted) >= 0) {
entry.entry = converted;
entry.entry = (FLAC__byte *)converted;
needs_free = true;
}
else {
......@@ -120,7 +120,7 @@ static FLAC__bool set_vc_field(FLAC__StreamMetadata *block, const Argument_VcFie
return false;
}
entry.length = strlen(entry.entry);
entry.length = strlen((const char *)entry.entry);
if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, block->data.vorbis_comment.num_comments, entry, /*copy=*/true)) {
if(needs_free)
......
......@@ -1159,7 +1159,7 @@ FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMet
memset(obj, 0, sizeof(FLAC__StreamMetadata_CueSheet));
FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN % 8 == 0);
if(!FLAC__bitbuffer_read_byte_block_aligned_no_crc(decoder->private_->input, obj->media_catalog_number, FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN/8, read_callback_, decoder))
if(!FLAC__bitbuffer_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->media_catalog_number, FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN/8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
if(!FLAC__bitbuffer_read_raw_uint64(decoder->private_->input, &obj->lead_in, FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN, read_callback_, decoder))
......@@ -1191,7 +1191,7 @@ FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMet
track->number = (FLAC__byte)x;
FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN % 8 == 0);
if(!FLAC__bitbuffer_read_byte_block_aligned_no_crc(decoder->private_->input, track->isrc, FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN/8, read_callback_, decoder))
if(!FLAC__bitbuffer_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)track->isrc, FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN/8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
if(!FLAC__bitbuffer_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN, read_callback_, decoder))
......
......@@ -478,7 +478,7 @@ FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *unused,
ogg_bytes_to_read = min(*bytes, OGG_BYTES_CHUNK);
oggbuf = ogg_sync_buffer(&decoder->private_->ogg.sync_state, ogg_bytes_to_read);
if(decoder->private_->read_callback(decoder, oggbuf, &ogg_bytes_to_read, decoder->private_->client_data) != FLAC__STREAM_DECODER_READ_STATUS_CONTINUE) {
if(decoder->private_->read_callback(decoder, (FLAC__byte*)oggbuf, &ogg_bytes_to_read, decoder->private_->client_data) != FLAC__STREAM_DECODER_READ_STATUS_CONTINUE) {
decoder->protected_->state = OggFLAC__STREAM_DECODER_READ_ERROR;
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
}
......
......@@ -179,10 +179,10 @@ FLAC__bool set_vc_field(const char *filename, FLAC__StreamMetadata *block, const
FLAC__ASSERT(0 != needs_write);
if(raw) {
entry.entry = field->field;
entry.entry = (FLAC__byte *)field->field;
}
else if(utf8_encode(field->field, &converted) >= 0) {
entry.entry = converted;
entry.entry = (FLAC__byte *)converted;
needs_free = true;
}
else {
......@@ -190,7 +190,7 @@ FLAC__bool set_vc_field(const char *filename, FLAC__StreamMetadata *block, const
return false;
}
entry.length = strlen(entry.entry);
entry.length = strlen((const char *)entry.entry);
if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, block->data.vorbis_comment.num_comments, entry, /*copy=*/true)) {
if(needs_free)
......
......@@ -88,7 +88,7 @@ char* FLAC_plugin__charset_convert_string (const char *string, char *from, char
outptr = out;
retry:
if (iconv(cd, &input, &length, &outptr, &outleft) == -1)
if (iconv(cd, (char**)&input, &length, &outptr, &outleft) == -1)
{
int used;
switch (errno)
......
......@@ -32,7 +32,7 @@ static int local__vcentry_matches(const char *field_name, const FLAC__StreamMeta
#endif
const FLAC__byte *eq = memchr(entry->entry, '=', entry->length);
const unsigned field_name_length = strlen(field_name);
return (0 != eq && (unsigned)(eq-entry->entry) == field_name_length && 0 == FLAC__STRNCASECMP(field_name, entry->entry, field_name_length));
return (0 != eq && (unsigned)(eq-entry->entry) == field_name_length && 0 == FLAC__STRNCASECMP(field_name, (const char *)entry->entry, field_name_length));
}
static void local__vcentry_parse_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry, char **dest)
......@@ -74,7 +74,7 @@ static void local__vc_change_field(FLAC__StreamMetadata *block, const char *name
sprintf(s, "%s=%s", name, value);
entry.length = strlen(s);
entry.entry = s;
entry.entry = (FLAC__byte *)s;
if(l == -1)
FLAC__metadata_object_vorbiscomment_insert_comment(block, block->data.vorbis_comment.num_comments, entry, /*copy=*/true);
......
......@@ -99,7 +99,7 @@ static FLAC__bool append_tag_(FLAC__StreamMetadata *block, const char *format, c
#endif
setlocale(LC_ALL, saved_locale);
entry.entry = buffer;
entry.entry = (FLAC__byte *)buffer;
entry.length = strlen(buffer);
return FLAC__metadata_object_vorbiscomment_insert_comment(block, block->data.vorbis_comment.num_comments, entry, /*copy=*/true);
......@@ -384,8 +384,8 @@ const char *grabbag__replaygain_store_to_vorbiscomment_album(FLAC__StreamMetadat
FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
if(
FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, tag_album_gain_) < 0 ||
FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, tag_album_peak_) < 0
FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, (const char *)tag_album_gain_) < 0 ||
FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, (const char *)tag_album_peak_) < 0
)
return "memory allocation error";
......@@ -404,8 +404,8 @@ const char *grabbag__replaygain_store_to_vorbiscomment_title(FLAC__StreamMetadat
FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
if(
FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, tag_title_gain_) < 0 ||
FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, tag_title_peak_) < 0
FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, (const char *)tag_title_gain_) < 0 ||
FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, (const char *)tag_title_peak_) < 0
)
return "memory allocation error";
......@@ -587,9 +587,9 @@ FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadat
FLAC__ASSERT(0 != block);
FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
if(0 > (gain_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, album_mode? tag_album_gain_ : tag_title_gain_)))
if(0 > (gain_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, (const char *)(album_mode? tag_album_gain_ : tag_title_gain_))))
return false;
if(0 > (peak_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, album_mode? tag_album_peak_ : tag_title_peak_)))
if(0 > (peak_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, (const char *)(album_mode? tag_album_peak_ : tag_title_peak_))))
return false;
if(!parse_double_(block->data.vorbis_comment.comments + gain_offset, gain))
......
......@@ -42,7 +42,7 @@ class OurFileDecoder: public FLAC::Decoder::File {
public:
inline OurFileDecoder(bool ignore_metadata): ignore_metadata_(ignore_metadata), error_occurred_(false) { }
bool ignore_metadata_;;
bool ignore_metadata_;
bool error_occurred_;
protected:
::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
......
......@@ -126,9 +126,11 @@ static FLAC__bool test_stream_encoder()
FLAC__StreamEncoderState state;
FLAC__StreamDecoderState dstate;
FLAC__int32 samples[1024];
FLAC__int32 *samples_array[1] = { samples };
FLAC__int32 *samples_array[1];
unsigned i;
samples_array[0] = samples;
printf("\n+++ libFLAC unit test: FLAC__StreamEncoder\n\n");
printf("testing FLAC__stream_encoder_new()... ");
......@@ -433,9 +435,11 @@ static FLAC__bool test_seekable_stream_encoder()
FLAC__StreamEncoderState state_;
FLAC__StreamDecoderState dstate;
FLAC__int32 samples[1024];
FLAC__int32 *samples_array[1] = { samples };
FLAC__int32 *samples_array[1];
unsigned i;
samples_array[0] = samples;
printf("\n+++ libFLAC unit test: FLAC__SeekableStreamEncoder\n\n");
printf("testing FLAC__seekable_stream_encoder_new()... ");
......@@ -738,9 +742,11 @@ static FLAC__bool test_file_encoder()
FLAC__StreamEncoderState state__;
FLAC__StreamDecoderState dstate;
FLAC__int32 samples[1024];
FLAC__int32 *samples_array[1] = { samples };
FLAC__int32 *samples_array[1];
unsigned i;
samples_array[0] = samples;
printf("\n+++ libFLAC unit test: FLAC__FileEncoder\n\n");
printf("testing FLAC__file_encoder_new()... ");
......
......@@ -76,9 +76,11 @@ static FLAC__bool test_stream_encoder()
FLAC__StreamEncoderState state_;
FLAC__StreamDecoderState dstate;
FLAC__int32 samples[1024];
FLAC__int32 *samples_array[1] = { samples };
FLAC__int32 *samples_array[1];
unsigned i;
samples_array[0] = samples;
printf("\n+++ libOggFLAC unit test: OggFLAC__StreamEncoder\n\n");
printf("testing OggFLAC__stream_encoder_new()... ");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment