>From e771b2c8428c4e86bb409a4d8401b203fc0e05c1 Mon Sep 17 00:00:00 2001 From: Andreas Winkelmann Date: Tue, 24 Jun 2014 12:52:52 +0200 Subject: [PATCH 2/2] Fixed two Compiler Warnings about switch case values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ie: src/id3_tag.c: In function ‘Id3tag_Get_Field’: src/id3_tag.c:978:13: warning: case value ‘9999’ not in enumerated type ‘ID3_TextEnc’ [-Wswitch] case 9999: ^ One switch-statement converted to if-else-if statements, the other one just removed the "9999" because it was a fall-through to the default-statement --- src/id3_tag.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/id3_tag.c b/src/id3_tag.c index 44536ca..ed9fc61 100644 --- a/src/id3_tag.c +++ b/src/id3_tag.c @@ -949,43 +949,41 @@ gchar *Id3tag_Get_Field (const ID3Frame *id3_frame, ID3_FieldID id3_fieldid) } // Action according the encoding... - switch ( enc ) + if ( enc == ID3TE_ISO8859_1) { - case ID3TE_ISO8859_1: string = g_malloc0(sizeof(char)*ID3V2_MAX_STRING_LEN+1); num_chars = ID3Field_GetASCII_1(id3_field,string,ID3V2_MAX_STRING_LEN,0); string1 = convert_string(string,"ISO-8859-1","UTF-8",FALSE); - break; - case ID3TE_UTF8: // Shouldn't work with id3lib 3.8.3 (supports only ID3v2.3, not ID3v2.4) + } else if ( enc == ID3TE_UTF8) // Shouldn't work with id3lib 3.8.3 (supports only ID3v2.3, not ID3v2.4) + { // For UTF-8, this part do the same thing that enc=9999 string = g_malloc0(sizeof(char)*ID3V2_MAX_STRING_LEN+1); num_chars = ID3Field_GetASCII_1(id3_field,string,ID3V2_MAX_STRING_LEN,0); //string1 = convert_string(string,"UTF-8","UTF-8",FALSE); // Nothing to do if (g_utf8_validate(string,-1,NULL)) string1 = g_strdup(string); - break; - case ID3TE_UTF16: + } else if (( enc == ID3TE_UTF16 ) || + ( enc == ID3TE_UTF16BE )) + { // Id3lib (3.8.3 at least) always returns Unicode strings in UTF-16BE. - case ID3TE_UTF16BE: string = g_malloc0(sizeof(unicode_t)*ID3V2_MAX_STRING_LEN+1); num_chars = ID3Field_GetUNICODE_1(id3_field,(unicode_t *)string,ID3V2_MAX_STRING_LEN,0); // "convert_string_1" as we need to pass length for UTF-16 string1 = convert_string_1(string,num_chars,"UTF-16BE","UTF-8",FALSE); - break; - case 9999: + } else if ( enc == 9999 ) + { string = g_malloc0(sizeof(char)*ID3V2_MAX_STRING_LEN+1); num_chars = ID3Field_GetASCII_1(id3_field,string,ID3V2_MAX_STRING_LEN,0); string1 = convert_string(string,FILE_READING_ID3V1V2_CHARACTER_SET,"UTF-8",FALSE); - break; - default: + } else + { string = g_malloc0(sizeof(char)*4*ID3V2_MAX_STRING_LEN+1); num_chars = ID3Field_GetASCII_1(id3_field,string,ID3V2_MAX_STRING_LEN,0); string1 = convert_to_utf8(string); - break; } } //g_print(">>ID:%d >'%s' (string1:'%s') (num_chars:%d)\n",ID3Field_GetINT(id3_field_encoding),string,string1,num_chars); @@ -1148,7 +1146,6 @@ Id3tag_Set_Field (const ID3Frame *id3_frame, return ID3TE_UTF16; break; - case 9999: default: //string_converted = convert_string(string,"UTF-8",FILE_WRITING_ID3V2_NO_UNICODE_CHARACTER_SET,TRUE); string_converted = Id3tag_Rules_For_ISO_Fields(string,"UTF-8",FILE_WRITING_ID3V2_NO_UNICODE_CHARACTER_SET); -- 1.8.4.5