Fix clang compiler warnings.
authorErik de Castro Lopo <erikd@mega-nerd.com>
Wed, 9 Apr 2014 07:56:13 +0000 (17:56 +1000)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Wed, 9 Apr 2014 08:09:03 +0000 (18:09 +1000)
These were most arising from -Wenum-conversion where an enum of
one type was being assigned to a variable on another.

Originally reported by Lenny Maiorani <lenny@colorado.edu> on the
flac-dev mailing list.

include/FLAC/format.h
src/libFLAC/cpu.c
src/libFLAC/include/protected/stream_decoder.h
src/libFLAC/metadata_object.c
src/libFLAC/stream_decoder.c

index e4c1c1a..e02388c 100644 (file)
@@ -509,9 +509,11 @@ typedef enum {
        FLAC__METADATA_TYPE_PICTURE = 6,
        /**< <A HREF="../format.html#metadata_block_picture">PICTURE</A> block */
 
-       FLAC__METADATA_TYPE_UNDEFINED = 7
+       FLAC__METADATA_TYPE_UNDEFINED = 7,
        /**< marker to denote beginning of undefined type range; this number will increase as new metadata types are added */
 
+        FLAC__MAX_METADATA_TYPE = FLAC__MAX_METADATA_TYPE_CODE,
+        /**< No type will ever be greater than this. There is not enough room in the protocol block. */
 } FLAC__MetadataType;
 
 /** Maps a FLAC__MetadataType to a C string.
index 940045f..383f823 100644 (file)
@@ -87,22 +87,25 @@ static void sigill_handler (int sig)
 /* how to get sysctlbyname()? */
 #endif
 
+#ifdef FLAC__CPU_IA32
 /* these are flags in EDX of CPUID AX=00000001 */
 static const unsigned FLAC__CPUINFO_IA32_CPUID_CMOV = 0x00008000;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_MMX = 0x00800000;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_FXSR = 0x01000000;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE = 0x02000000;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE2 = 0x04000000;
+#endif
 /* these are flags in ECX of CPUID AX=00000001 */
 static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE3 = 0x00000001;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_SSSE3 = 0x00000200;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE41 = 0x00080000;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE42 = 0x00100000;
+#ifdef FLAC__CPU_IA32
 /* these are flags in EDX of CPUID AX=80000001 */
 static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_3DNOW = 0x80000000;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXT3DNOW = 0x40000000;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXTMMX = 0x00400000;
-
+#endif
 
 /*
  * Extra stuff needed for detection of OS support for SSE on IA-32
index 629776f..e23126d 100644 (file)
@@ -40,6 +40,7 @@
 
 typedef struct FLAC__StreamDecoderProtected {
        FLAC__StreamDecoderState state;
+       FLAC__StreamDecoderInitStatus initstate;
        unsigned channels;
        FLAC__ChannelAssignment channel_assignment;
        unsigned bits_per_sample;
index 1af0b0d..161baed 100644 (file)
@@ -440,7 +440,7 @@ FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_new(FLAC__MetadataType type
 {
        FLAC__StreamMetadata *object;
 
-       if(type > FLAC__MAX_METADATA_TYPE_CODE)
+       if(type > FLAC__MAX_METADATA_TYPE)
                return 0;
 
        object = calloc(1, sizeof(FLAC__StreamMetadata));
index 8dadd66..7ccc526 100644 (file)
@@ -381,7 +381,7 @@ static FLAC__StreamDecoderInitStatus init_stream_internal_(
 #if FLAC__HAS_OGG
        decoder->private_->is_ogg = is_ogg;
        if(is_ogg && !FLAC__ogg_decoder_aspect_init(&decoder->protected_->ogg_decoder_aspect))
-               return decoder->protected_->state = FLAC__STREAM_DECODER_OGG_ERROR;
+               return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE;
 #endif
 
        /*
@@ -541,10 +541,10 @@ static FLAC__StreamDecoderInitStatus init_FILE_internal_(
        FLAC__ASSERT(0 != file);
 
        if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
-               return decoder->protected_->state = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED;
+               return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED;
 
        if(0 == write_callback || 0 == error_callback)
-               return decoder->protected_->state = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS;
+               return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS;
 
        /*
         * To make sure that our file does not go unclosed after an error, we
@@ -615,10 +615,10 @@ static FLAC__StreamDecoderInitStatus init_file_internal_(
         * in FLAC__stream_decoder_init_FILE() before the FILE* is assigned.
         */
        if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
-               return decoder->protected_->state = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED;
+               return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED;
 
        if(0 == write_callback || 0 == error_callback)
-               return decoder->protected_->state = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS;
+               return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS;
 
        file = filename? flac_fopen(filename, "rb") : stdin;