diff options
author | Martijn van Beurden <mvanb1@gmail.com> | 2022-04-30 11:55:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-30 11:55:17 +0200 |
commit | e0a874e84b88c9d2caa8c853796b21e75e4b87bc (patch) | |
tree | a13d1e4e0c6502192dec21319b6437b65c2be513 /src | |
parent | 6cd28e855c71248ec40790922795590106be7076 (diff) | |
download | flac-e0a874e84b88c9d2caa8c853796b21e75e4b87bc.tar.gz |
Silence a bunch of MSVC warnings
See https://github.com/xiph/flac/issues/313
Diffstat (limited to 'src')
-rw-r--r-- | src/libFLAC/format.c | 9 | ||||
-rw-r--r-- | src/libFLAC/metadata_iterators.c | 20 | ||||
-rw-r--r-- | src/libFLAC/metadata_object.c | 2 | ||||
-rw-r--r-- | src/libFLAC/stream_encoder.c | 4 | ||||
-rw-r--r-- | src/libFLAC/window.c | 8 | ||||
-rw-r--r-- | src/share/grabbag/picture.c | 4 | ||||
-rw-r--r-- | src/test_seeking/main.c | 4 | ||||
-rw-r--r-- | src/test_streams/main.c | 7 |
8 files changed, 50 insertions, 8 deletions
diff --git a/src/libFLAC/format.c b/src/libFLAC/format.c index b1939fb5..7f2a9685 100644 --- a/src/libFLAC/format.c +++ b/src/libFLAC/format.c @@ -577,6 +577,11 @@ void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__En FLAC__format_entropy_coding_method_partitioned_rice_contents_init(object); } +#if defined(_MSC_VER) +// silence three MSVC warnings 'result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)' +#pragma warning ( disable : 4334 ) +#endif + FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, uint32_t max_partition_order) { FLAC__ASSERT(0 != object); @@ -594,3 +599,7 @@ FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_s return true; } + +#if defined(_MSC_VER) +#pragma warning ( default : 4334 ) +#endif diff --git a/src/libFLAC/metadata_iterators.c b/src/libFLAC/metadata_iterators.c index 6f805aed..13dec3c8 100644 --- a/src/libFLAC/metadata_iterators.c +++ b/src/libFLAC/metadata_iterators.c @@ -576,7 +576,7 @@ FLAC_API off_t FLAC__metadata_simple_iterator_get_block_offset(const FLAC__Metad FLAC__ASSERT(0 != iterator); FLAC__ASSERT(0 != iterator->file); - return iterator->offset[iterator->depth]; + return (off_t)iterator->offset[iterator->depth]; } FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const FLAC__Metadata_SimpleIterator *iterator) @@ -1099,6 +1099,11 @@ static FLAC__bool chain_merge_adjacent_padding_(FLAC__Metadata_Chain *chain, FLA return false; } +#if defined(_MSC_VER) +// silence three MSVC warnings 'conversion from 'conversion from 'const __int64' to 'uint32_t', possible loss of data' +#pragma warning ( disable : 4244 ) +#endif + /* Returns the new length of the chain, or 0 if there was an error. */ /* WATCHOUT: This can get called multiple times before a write, so * it should still work when this happens. @@ -1176,6 +1181,10 @@ static FLAC__off_t chain_prepare_for_write_(FLAC__Metadata_Chain *chain, FLAC__b return current_length; } +#if defined(_MSC_VER) +#pragma warning ( default : 4244 ) +#endif + static FLAC__bool chain_read_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__IOCallback_Tell tell_cb) { FLAC__Metadata_Node *node; @@ -1625,6 +1634,11 @@ typedef enum { LBS_BLOCK_REMOVED } LastBlockState; +#if defined(_MSC_VER) +// silence three MSVC warnings 'conversion from 'conversion from 'const __int64' to 'uint32_t', possible loss of data' +#pragma warning ( disable : 4244 ) +#endif + FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata_Chain *chain, FLAC__bool use_padding) { /* This does all the same checks that are in chain_prepare_for_write_() @@ -1702,6 +1716,10 @@ FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata return (current_length != chain->initial_length); } +#if defined(_MSC_VER) +#pragma warning ( default : 4244 ) +#endif + FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__bool preserve_file_stats) { struct flac_stat_s stats; diff --git a/src/libFLAC/metadata_object.c b/src/libFLAC/metadata_object.c index de8e5139..db4fc48c 100644 --- a/src/libFLAC/metadata_object.c +++ b/src/libFLAC/metadata_object.c @@ -1124,7 +1124,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_point if (num > 32768) { /* Set the bound and recalculate samples accordingly. */ num = 32768; - samples = total_samples / num; + samples = (uint32_t)(total_samples / num); } i = seek_table->num_points; diff --git a/src/libFLAC/stream_encoder.c b/src/libFLAC/stream_encoder.c index 0aa98a21..9eaf5d3a 100644 --- a/src/libFLAC/stream_encoder.c +++ b/src/libFLAC/stream_encoder.c @@ -3928,9 +3928,9 @@ uint32_t find_best_partition_order_( /* save best parameters and raw_bits */ FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(prc, flac_max(6u, best_partition_order)); - memcpy(prc->parameters, private_->partitioned_rice_contents_extra[best_parameters_index].parameters, sizeof(uint32_t)*(1<<(best_partition_order))); + memcpy(prc->parameters, private_->partitioned_rice_contents_extra[best_parameters_index].parameters, (uint32_t)sizeof(uint32_t)*(1<<(best_partition_order))); if(do_escape_coding) - memcpy(prc->raw_bits, private_->partitioned_rice_contents_extra[best_parameters_index].raw_bits, sizeof(uint32_t)*(1<<(best_partition_order))); + memcpy(prc->raw_bits, private_->partitioned_rice_contents_extra[best_parameters_index].raw_bits, (uint32_t)sizeof(uint32_t)*(1<<(best_partition_order))); /* * Now need to check if the type should be changed to * FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 based on the diff --git a/src/libFLAC/window.c b/src/libFLAC/window.c index 94495f35..cd312ab1 100644 --- a/src/libFLAC/window.c +++ b/src/libFLAC/window.c @@ -42,6 +42,10 @@ #ifndef FLAC__INTEGER_ONLY_LIBRARY +#if defined(_MSC_VER) +// silence 25 MSVC warnings 'conversion from 'double' to 'float', possible loss of data' +#pragma warning ( disable : 4244 ) +#endif void FLAC__window_bartlett(FLAC__real *window, const FLAC__int32 L) { @@ -279,4 +283,8 @@ void FLAC__window_welch(FLAC__real *window, const FLAC__int32 L) } } +#if defined(_MSC_VER) +#pragma warning ( default : 4244 ) +#endif + #endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/src/share/grabbag/picture.c b/src/share/grabbag/picture.c index 89d5cc92..81036989 100644 --- a/src/share/grabbag/picture.c +++ b/src/share/grabbag/picture.c @@ -287,7 +287,7 @@ static const char * read_file (const char * filepath, FLAC__StreamMetadata * obj if (size < 0) return error_messages[5]; - if (size >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) /* actual limit is less because of other fields in the PICTURE metadata block */ + if (size >= (FLAC__off_t)(1u << FLAC__STREAM_METADATA_LENGTH_LEN)) /* actual limit is less because of other fields in the PICTURE metadata block */ return error_messages[11]; if ((buffer = safe_malloc_(size)) == NULL) @@ -305,7 +305,7 @@ static const char * read_file (const char * filepath, FLAC__StreamMetadata * obj } fclose(file); - if (!FLAC__metadata_object_picture_set_data(obj, buffer, size, /*copy=*/false)) + if (!FLAC__metadata_object_picture_set_data(obj, buffer, (FLAC__uint32)size, /*copy=*/false)) error_message = error_messages[6]; /* try to extract MIME type if user left it blank */ else if (*obj->data.picture.mime_type == '\0' && !local__extract_mime_type_(obj)) diff --git a/src/test_seeking/main.c b/src/test_seeking/main.c index 5a7e3999..a44555eb 100644 --- a/src/test_seeking/main.c +++ b/src/test_seeking/main.c @@ -148,7 +148,7 @@ static FLAC__bool read_pcm_(FLAC__int32 *pcm[], const char *rawfilename, const c printf("ERROR: PCM verification requires 8 or 16 bps, got %u\n", bps); return false; } - samples = rawfilesize / channels / (bps>>3); + samples = (uint32_t)(rawfilesize / channels / (bps>>3)); if (samples > 10000000) { fprintf(stderr, "ERROR: %s is too big\n", rawfilename); return false; @@ -320,7 +320,7 @@ static FLAC__bool seek_barrage(FLAC__bool is_ogg, const char *filename, FLAC__of /* @@@ for is_ogg we should get it from last page's granulepos */ if(n == 0) { /* 8 would imply no compression, 9 guarantees that we will get some samples off the end of the stream to test that case */ - n = 9 * filesize / (decoder_client_data.channels * decoder_client_data.bits_per_sample); + n = (long int)(9 * filesize / (decoder_client_data.channels * decoder_client_data.bits_per_sample)); } printf("Begin seek barrage, count=%u\n", count); diff --git a/src/test_streams/main.c b/src/test_streams/main.c index 7f21fe0d..12366f0a 100644 --- a/src/test_streams/main.c +++ b/src/test_streams/main.c @@ -104,6 +104,10 @@ static FLAC__bool write_little_endian_int32(FILE *f, FLAC__int32 x) } #endif +#if defined(_MSC_VER) +// silence 4 MSVC warnings 'conversion from 'FLAC__uint64' to 'int', possible loss of data' +#pragma warning ( disable : 4244 ) +#endif static FLAC__bool write_little_endian_uint64(FILE *f, FLAC__uint64 x) { return @@ -117,6 +121,9 @@ static FLAC__bool write_little_endian_uint64(FILE *f, FLAC__uint64 x) fputc(x >> 56, f) != EOF ; } +#if defined(_MSC_VER) +#pragma warning ( default : 4244 ) +#endif static FLAC__bool write_big_endian(FILE *f, FLAC__int32 x, size_t bytes) { |