[easytag/wip/core-refactoring: 10/24] Avoid unhandled switch cases warning



commit e90a7e842f459fd3354d5de9f9da8410de143386
Author: David King <amigadave amigadave com>
Date:   Fri Jan 30 13:49:40 2015 +0000

    Avoid unhandled switch cases warning

 src/application.c      |   82 ++++++++++---------
 src/picture.c          |   33 +++-----
 src/playlist_dialog.c  |    3 +
 src/scan_dialog.c      |   44 +++++------
 src/tag_area.c         |   91 +++++++++------------
 src/tags/flac_header.c |   21 ++---
 src/tags/flac_tag.c    |  134 ++++++++++++-------------------
 src/tags/id3_tag.c     |    7 ++
 src/tags/id3v24_tag.c  |  207 ++++++++++++++++++++++++++++--------------------
 src/tags/mp4_tag.cc    |    1 +
 src/tags/mpeg_header.c |   24 ++++--
 src/tags/ogg_header.c  |   19 +++--
 src/tags/vcedit.c      |    2 +
 13 files changed, 333 insertions(+), 335 deletions(-)
---
diff --git a/src/application.c b/src/application.c
index a970cc4..9eebd4e 100644
--- a/src/application.c
+++ b/src/application.c
@@ -447,57 +447,63 @@ et_application_open (GApplication *self,
 
     type = g_file_info_get_file_type (info);
 
-    switch (type)
+    if (type == G_FILE_TYPE_DIRECTORY)
     {
-        case G_FILE_TYPE_DIRECTORY:
+        if (activated)
+        {
+            et_application_window_select_dir (windows->data, path);
+            g_free (path);
+        }
+        else
+        {
+            priv->init_directory = path;
+        }
+
+        g_free (path_utf8);
+        g_object_unref (info);
+    }
+    else if (type == G_FILE_TYPE_REGULAR)
+    {
+        /* When given a file, load the parent directory. */
+        parent = g_file_get_parent (arg);
+
+        if (parent)
+        {
+            g_free (path_utf8);
+            g_free (path);
+
             if (activated)
             {
-                et_application_window_select_dir (windows->data, path);
-                g_free (path);
+                gchar *parent_path;
+
+                parent_path = g_file_get_path (arg);
+                et_application_window_select_dir (windows->data,
+                                                  parent_path);
+
+                g_free (parent_path);
             }
             else
             {
-                priv->init_directory = path;
+                priv->init_directory = g_file_get_path (parent);
             }
 
-            g_free (path_utf8);
+            g_object_unref (parent);
             g_object_unref (info);
-            break;
-        case G_FILE_TYPE_REGULAR:
-            /* When given a file, load the parent directory. */
-            parent = g_file_get_parent (arg);
-
-            if (parent)
-            {
-                g_free (path_utf8);
-                g_free (path);
-
-                if (activated)
-                {
-                    gchar *parent_path;
-
-                    parent_path = g_file_get_path (arg);
-                    et_application_window_select_dir (windows->data,
-                                                      parent_path);
-
-                    g_free (parent_path);
-                }
-                else
-                {
-                    priv->init_directory = g_file_get_path (parent);
-                }
-
-                g_object_unref (parent);
-                g_object_unref (info);
-                break;
-            }
-            /* Fall through on error. */
-        default:
+        }
+        else
+        {
             Log_Print (LOG_WARNING, _("Cannot open path ‘%s’"), path_utf8);
             g_free (path);
             g_free (path_utf8);
             return;
-            break;
+        }
+    }
+    else
+    {
+        Log_Print (LOG_WARNING, _("Cannot open path ‘%s’"), path_utf8);
+        g_free (path);
+        g_free (path_utf8);
+        return;
     }
 
     if (!activated)
diff --git a/src/picture.c b/src/picture.c
index a9f53cd..8845585 100644
--- a/src/picture.c
+++ b/src/picture.c
@@ -158,6 +158,7 @@ Picture_Mime_Type_String (Picture_Format format)
             return "image/png";
         case PICTURE_FORMAT_GIF:
             return "image/gif";
+        case PICTURE_FORMAT_UNKNOWN:
         default:
             g_debug ("%s", "Unrecognised image MIME type");
             return "application/octet-stream";
@@ -176,6 +177,7 @@ Picture_Format_String (Picture_Format format)
             return _("PNG image");
         case PICTURE_FORMAT_GIF:
             return _("GIF image");
+        case PICTURE_FORMAT_UNKNOWN:
         default:
             return _("Unknown image");
     }
@@ -252,26 +254,19 @@ et_picture_format_info (const EtPicture *pic,
     type = Picture_Type_String (pic->type);
     size_str = g_format_size (g_bytes_get_size (pic->bytes));
 
-    // Behaviour following the tag type...
-    switch (tag_type)
+    /* Behaviour following the tag type. */
+    if (tag_type == MP4_TAG)
     {
-        case MP4_TAG:
-        {
-            r = g_strdup_printf ("%s (%s - %d×%d %s)\n%s: %s", format,
-                                 size_str, pic->width, pic->height,
-                                 _("pixels"), _("Type"), type);
-            break;
-        }
-
-        // Other tag types
-        default:
-        {
-            r = g_strdup_printf ("%s (%s - %d×%d %s)\n%s: %s\n%s: %s", format,
-                                 size_str, pic->width, pic->height,
-                                 _("pixels"), _("Type"), type,
-                                 _("Description"), desc);
-            break;
-        }
+        r = g_strdup_printf ("%s (%s - %d×%d %s)\n%s: %s", format,
+                             size_str, pic->width, pic->height,
+                             _("pixels"), _("Type"), type);
+    }
+    else
+    {
+        r = g_strdup_printf ("%s (%s - %d×%d %s)\n%s: %s\n%s: %s", format,
+                             size_str, pic->width, pic->height,
+                             _("pixels"), _("Type"), type,
+                             _("Description"), desc);
     }
 
     g_free (size_str);
diff --git a/src/playlist_dialog.c b/src/playlist_dialog.c
index 40e95f5..946786a 100644
--- a/src/playlist_dialog.c
+++ b/src/playlist_dialog.c
@@ -471,8 +471,11 @@ write_button_clicked (EtPlaylistDialog *self)
             case ET_CONVERT_SPACES_REMOVE:
                 Scan_Remove_Spaces (playlist_basename_utf8);
                 break;
+            /* FIXME: Check that this is intended. */
+            case ET_CONVERT_SPACES_NO_CHANGE:
             default:
                 g_assert_not_reached ();
+                break;
         }
     }else // PLAYLIST_USE_DIR_NAME
     {
diff --git a/src/scan_dialog.c b/src/scan_dialog.c
index e57e179..266db0c 100644
--- a/src/scan_dialog.c
+++ b/src/scan_dialog.c
@@ -386,33 +386,27 @@ Scan_Tag_With_Mask (EtScanDialog *self, ET_File *ETFile)
         GError *error = NULL;
         guint32 crc32_value;
         gchar *buffer;
-        const ET_File_Description *ETFileDescription;
 
-        ETFileDescription = ETFile->ETFileDescription;
-        switch (ETFileDescription->TagType)
+        if (ETFile->ETFileDescription == ID3_TAG)
         {
-            case ID3_TAG:
-                file = g_file_new_for_path (((File_Name *)((GList *)ETFile->FileNameNew)->data)->value);
+            file = g_file_new_for_path (((File_Name *)((GList *)ETFile->FileNameNew)->data)->value);
 
-                if (crc32_file_with_ID3_tag (file, &crc32_value, &error))
-                {
-                    buffer = g_strdup_printf ("%.8" G_GUINT32_FORMAT,
-                                              crc32_value);
-                    et_file_tag_set_comment (FileTag, buffer);
-                    g_free(buffer);
-                }
-                else
-                {
-                    Log_Print (LOG_ERROR,
-                               _("Cannot calculate CRC value of file ‘%s’"),
-                               error->message);
-                    g_error_free (error);
-                }
+            if (crc32_file_with_ID3_tag (file, &crc32_value, &error))
+            {
+                buffer = g_strdup_printf ("%.8" G_GUINT32_FORMAT,
+                                          crc32_value);
+                et_file_tag_set_comment (FileTag, buffer);
+                g_free(buffer);
+            }
+            else
+            {
+                Log_Print (LOG_ERROR,
+                           _("Cannot calculate CRC value of file ‘%s’"),
+                           error->message);
+                g_error_free (error);
+            }
 
-                g_object_unref (file);
-                break;
-            default:
-                break;
+            g_object_unref (file);
         }
     }
 
@@ -490,6 +484,8 @@ Scan_Generate_New_Tag_From_Mask (ET_File *ETFile, gchar *mask)
             break;
         case ET_CONVERT_SPACES_NO_CHANGE:
             break;
+        /* FIXME: Check if this is intentional. */
+        case ET_CONVERT_SPACES_REMOVE:
         default:
             g_assert_not_reached ();
     }
@@ -950,6 +946,8 @@ et_scan_generate_new_filename_from_mask (const ET_File *ETFile,
                     case ET_CONVERT_SPACES_REMOVE:
                         Scan_Remove_Spaces (mask_item->string);
                         break;
+                    /* FIXME: Check that this is intended. */
+                    case ET_CONVERT_SPACES_NO_CHANGE:
                     default:
                         g_assert_not_reached ();
                 }
diff --git a/src/tag_area.c b/src/tag_area.c
index 7ddcce2..9ef3ce5 100644
--- a/src/tag_area.c
+++ b/src/tag_area.c
@@ -1440,6 +1440,7 @@ load_picture_from_file (GFile *file,
                 }
                 break;
 
+            case UNKNOWN_TAG:
             default:
                 g_assert_not_reached ();
         }
@@ -1508,21 +1509,17 @@ on_picture_add_button_clicked (GObject *object,
                                  filter);
 
     // Behaviour following the tag type...
-    switch (ETCore->ETFileDisplayed->ETFileDescription->TagType)
+    if (ETCore->ETFileDisplayed->ETFileDescription->TagType == MP4_TAG)
     {
-        case MP4_TAG:
-        {
-            // Only one file can be selected
-            gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(FileSelectionWindow), FALSE);
-            break;
-        }
-
-        // Other tag types
-        default:
-        {
-            gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(FileSelectionWindow), TRUE);
-            break;
-        }
+        /* Only one file can be selected. */
+        gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (FileSelectionWindow),
+                                              FALSE);
+    }
+    else
+    {
+        /* Other tag types .*/
+        gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (FileSelectionWindow),
+                                              TRUE);
     }
 
     gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (FileSelectionWindow),
@@ -1660,45 +1657,40 @@ on_picture_properties_button_clicked (GObject *object,
         g_object_unref (store);
 
         /* Behaviour following the tag type. */
-        switch (ETCore->ETFileDisplayed->ETFileDescription->TagType)
+        if (ETCore->ETFileDisplayed->ETFileDescription->TagType == MP4_TAG)
         {
-            case MP4_TAG:
+            /* Load picture type (only Front Cover!). */
+            GtkTreeIter itertype;
+
+            gtk_list_store_insert_with_values (store, &itertype,
+                                               G_MAXINT,
+                                               PICTURE_TYPE_COLUMN_TEXT,
+                                               _(Picture_Type_String (ET_PICTURE_TYPE_FRONT_COVER)),
+                                               PICTURE_TYPE_COLUMN_TYPE_CODE,
+                                               ET_PICTURE_TYPE_FRONT_COVER,
+                                               -1);
+            /* Line to select by default. */
+            type_iter_to_select = itertype;
+        }
+        else
+        /* Other tag types. */
+        {
+            /* Load pictures types. */
+            for (pic_type = ET_PICTURE_TYPE_OTHER; pic_type < ET_PICTURE_TYPE_UNDEFINED; pic_type++)
             {
-                /* Load picture type (only Front Cover!). */
                 GtkTreeIter itertype;
 
-                gtk_list_store_insert_with_values (store, &itertype, G_MAXINT,
+                gtk_list_store_insert_with_values (store, &itertype,
+                                                   G_MAXINT,
                                                    PICTURE_TYPE_COLUMN_TEXT,
-                                                   _(Picture_Type_String (ET_PICTURE_TYPE_FRONT_COVER)),
+                                                   _(Picture_Type_String (pic_type)),
                                                    PICTURE_TYPE_COLUMN_TYPE_CODE,
-                                                   ET_PICTURE_TYPE_FRONT_COVER,
-                                                   -1);
+                                                   pic_type, -1);
                 /* Line to select by default. */
-                type_iter_to_select = itertype;
-                break;
-            }
-
-            /* Other tag types. */
-            default:
-            {
-                /* Load pictures types. */
-                for (pic_type = ET_PICTURE_TYPE_OTHER; pic_type < ET_PICTURE_TYPE_UNDEFINED; pic_type++)
+                if (pic->type == pic_type)
                 {
-                    GtkTreeIter itertype;
-
-                    gtk_list_store_insert_with_values (store, &itertype,
-                                                       G_MAXINT,
-                                                       PICTURE_TYPE_COLUMN_TEXT,
-                                                       _(Picture_Type_String (pic_type)),
-                                                       PICTURE_TYPE_COLUMN_TYPE_CODE,
-                                                       pic_type, -1);
-                    /* Line to select by default. */
-                    if (pic->type == pic_type)
-                    {
-                        type_iter_to_select = itertype;
-                    }
+                    type_iter_to_select = itertype;
                 }
-                break;
             }
         }
 
@@ -1726,15 +1718,10 @@ on_picture_properties_button_clicked (GObject *object,
             g_free (tmp);
         }
 
-        // Behaviour following the tag type...
-        switch (ETCore->ETFileDisplayed->ETFileDescription->TagType)
+        /* Behaviour following the tag type. */
+        if (ETCore->ETFileDisplayed->ETFileDescription->TagType == MP4_TAG)
         {
-            case MP4_TAG:
-                gtk_widget_set_sensitive (GTK_WIDGET (desc), FALSE);
-                break;
-            /* Other tag types. */
-            default:
-                break;
+            gtk_widget_set_sensitive (GTK_WIDGET (desc), FALSE);
         }
 
         gtk_widget_show_all (PictureTypesWindow);
diff --git a/src/tags/flac_header.c b/src/tags/flac_header.c
index ee60fb7..f2c1109 100644
--- a/src/tags/flac_header.c
+++ b/src/tags/flac_header.c
@@ -108,21 +108,14 @@ et_flac_header_read_file_info (GFile *file,
 
         metadata_len += block->length;
 
-        switch (block->type)
+        if (block->type == FLAC__METADATA_TYPE_STREAMINFO)
         {
-            case FLAC__METADATA_TYPE_STREAMINFO:
-                {
-                    const FLAC__StreamMetadata_StreamInfo *stream_info = &block->data.stream_info;
-                    ETFileInfo->duration = stream_info->total_samples
-                                           / stream_info->sample_rate;
-                    ETFileInfo->mode = stream_info->channels;
-                    ETFileInfo->samplerate = stream_info->sample_rate;
-                    ETFileInfo->version = 0; /* Not defined in FLAC file. */
-                }
-                break;
-            default:
-                /* Ignore all other metadata types. */
-                break;
+            const FLAC__StreamMetadata_StreamInfo *stream_info = &block->data.stream_info;
+            ETFileInfo->duration = stream_info->total_samples
+                                   / stream_info->sample_rate;
+            ETFileInfo->mode = stream_info->channels;
+            ETFileInfo->samplerate = stream_info->sample_rate;
+            ETFileInfo->version = 0; /* Not defined in FLAC file. */
         }
     }
     while (FLAC__metadata_iterator_next (iter));
diff --git a/src/tags/flac_tag.c b/src/tags/flac_tag.c
index 1e65b38..5e97c2f 100644
--- a/src/tags/flac_tag.c
+++ b/src/tags/flac_tag.c
@@ -111,19 +111,10 @@ flac_tag_read_file_tag (GFile *file,
 
     if (!FLAC__metadata_chain_read_with_callbacks (chain, &state, callbacks))
     {
-        FLAC__Metadata_ChainStatus status;
-
-        status = FLAC__metadata_chain_status (chain);
-
-        switch (status)
-        {
-            /* TODO: Provide a dedicated error enum corresponding to status. */
-            default:
-                g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, "%s",
-                             _("Error opening FLAC file"));
-                et_flac_read_close_func (&state);
-                break;
-        }
+        /* TODO: Provide a dedicated error enum corresponding to status. */
+        g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, "%s",
+                     _("Error opening FLAC file"));
+        et_flac_read_close_func (&state);
 
         return FALSE;
     }
@@ -146,10 +137,8 @@ flac_tag_read_file_tag (GFile *file,
 
         block = FLAC__metadata_iterator_get_block (iter);
 
-        switch (block->type)
+        if (block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT)
         {
-            case FLAC__METADATA_TYPE_VORBIS_COMMENT:
-            {
                 FLAC__StreamMetadata_VorbisComment       *vc;
                 FLAC__StreamMetadata_VorbisComment_Entry *field;
                 gint   field_num;
@@ -651,45 +640,33 @@ flac_tag_read_file_tag (GFile *file,
                         FileTag->other = g_list_append(FileTag->other,g_strndup((const gchar *)field->entry, 
field->length));
                     }
                 }
-                
-                break;
-            }
-
-            
-            //
-            // Read the PICTURE block (severals can exist)
-            //
-            case FLAC__METADATA_TYPE_PICTURE: 
-            {
-                /* Picture. */
-                FLAC__StreamMetadata_Picture *p;
-                GBytes *bytes;
-                EtPicture *pic;
-            
-                /* Get picture data from block. */
-                p = &block->data.picture;
-
-                bytes = g_bytes_new (p->data, p->data_length);
-            
-                pic = et_picture_new (p->type, (const gchar *)p->description,
-                                      0, 0, bytes);
-                g_bytes_unref (bytes);
+        }
+        else if (block->type == FLAC__METADATA_TYPE_PICTURE)
+        {
+            /* Picture. */
+            FLAC__StreamMetadata_Picture *p;
+            GBytes *bytes;
+            EtPicture *pic;
+        
+            /* Get picture data from block. */
+            p = &block->data.picture;
 
-                if (!prev_pic)
-                {
-                    FileTag->picture = pic;
-                }
-                else
-                {
-                    prev_pic->next = pic;
-                }
+            bytes = g_bytes_new (p->data, p->data_length);
+        
+            pic = et_picture_new (p->type, (const gchar *)p->description,
+                                  0, 0, bytes);
+            g_bytes_unref (bytes);
 
-                prev_pic = pic;
-                break;
+            if (!prev_pic)
+            {
+                FileTag->picture = pic;
             }
-                
-            default:
-                break;
+            else
+            {
+                prev_pic->next = pic;
+            }
+
+            prev_pic = pic;
         }
     }
 
@@ -897,43 +874,32 @@ flac_tag_write_file_tag (const ET_File *ETFile,
     
     while (FLAC__metadata_iterator_next (iter))
     {
-        switch (FLAC__metadata_iterator_get_block_type (iter))
+        const FLAC__MetadataType block_type = FLAC__metadata_iterator_get_block_type (iter);
+
+        /* TODO: Modify the blocks directly, rather than deleting and
+         * recreating. */
+        if (block_type == FLAC__METADATA_TYPE_VORBIS_COMMENT)
         {
-            /* TODO: Modify the blocks directly, rather than deleting and
-             * recreating. */
-            //
             // Delete the VORBIS_COMMENT block and convert to padding. But before, save the original vendor 
string.
-            //
-            case FLAC__METADATA_TYPE_VORBIS_COMMENT:
-            {
-                // Get block data
-                FLAC__StreamMetadata *block = FLAC__metadata_iterator_get_block(iter);
-                FLAC__StreamMetadata_VorbisComment *vc = &block->data.vorbis_comment;
-                
-                if (vc->vendor_string.entry != NULL)
-                {
-                    // Get initial vendor string, to don't alterate it by FLAC__VENDOR_STRING when saving 
file
-                    vce_field_vendor_string.entry = (FLAC__byte *)g_strdup((gchar *)vc->vendor_string.entry);
-                    vce_field_vendor_string.length = strlen((gchar *)vce_field_vendor_string.entry);
-                    vce_field_vendor_string_found = TRUE;
-                }
-                
-                // Free block data
-                FLAC__metadata_iterator_delete_block(iter,true);
-                break;
-            }
+            /* Get block data. */
+            FLAC__StreamMetadata *block = FLAC__metadata_iterator_get_block(iter);
+            FLAC__StreamMetadata_VorbisComment *vc = &block->data.vorbis_comment;
             
-            //
-            // Delete all the PICTURE blocks, and convert to padding
-            //
-            case FLAC__METADATA_TYPE_PICTURE: 
+            if (vc->vendor_string.entry != NULL)
             {
-                FLAC__metadata_iterator_delete_block(iter,true);
-                break;
+                // Get initial vendor string, to don't alterate it by FLAC__VENDOR_STRING when saving file
+                vce_field_vendor_string.entry = (FLAC__byte *)g_strdup ((gchar *)vc->vendor_string.entry);
+                vce_field_vendor_string.length = strlen ((gchar *)vce_field_vendor_string.entry);
+                vce_field_vendor_string_found = TRUE;
             }
-
-            default:
-                break;
+            
+            /* Free block data. */
+            FLAC__metadata_iterator_delete_block (iter, true);
+        }
+        else if (block_type == FLAC__METADATA_TYPE_PICTURE)
+        {
+            /* Delete all the PICTURE blocks, and convert to padding. */
+            FLAC__metadata_iterator_delete_block (iter, true);
         }
     }
     
diff --git a/src/tags/id3_tag.c b/src/tags/id3_tag.c
index a7e6cf2..e192c67 100644
--- a/src/tags/id3_tag.c
+++ b/src/tags/id3_tag.c
@@ -515,6 +515,7 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
                     ID3Field_SetASCII (id3_field, "GIF");
                 }
                 break;
+            case PICTURE_FORMAT_UNKNOWN:
             default:
                 break;
         }
@@ -1031,6 +1032,8 @@ gchar *Id3tag_Get_Field (const ID3Frame *id3_frame, ID3_FieldID id3_fieldid)
                 string1 = convert_string_1(string,num_chars,"UTF-16BE","UTF-8",FALSE);
                 break;
 
+            case ID3TE_NONE:
+            case ID3TE_NUMENCODINGS:
             default:
                 string = g_malloc0 (4 * ID3V2_MAX_STRING_LEN + 1);
                 num_chars = ID3Field_GetASCII_1(id3_field,string,ID3V2_MAX_STRING_LEN,0);
@@ -1211,6 +1214,10 @@ Id3tag_Set_Field (const ID3Frame *id3_frame,
                 break;
 
 override:
+            case ID3TE_UTF16BE:
+            case ID3TE_UTF8:
+            case ID3TE_NUMENCODINGS:
+            case ID3TE_NONE:
             default:
             {
                 //string_converted = convert_string(string,"UTF-8",charset,TRUE);
diff --git a/src/tags/id3v24_tag.c b/src/tags/id3v24_tag.c
index 9534b00..835a98b 100644
--- a/src/tags/id3v24_tag.c
+++ b/src/tags/id3v24_tag.c
@@ -454,31 +454,30 @@ id3tag_read_file_tag (GFile *gfile,
         /* Picture file data. */
         for (j = 0; (field = id3_frame_field(frame, j)); j++)
         {
-            switch (id3_field_type(field))
+            enum id3_field_type field_type;
+
+            field_type = id3_field_type (field);
+
+            if (field_type == ID3_FIELD_TYPE_BINARYDATA)
             {
-                case ID3_FIELD_TYPE_BINARYDATA:
-                    {
-                        id3_length_t size;
-                        id3_byte_t const *data;
-                        
-                        data = id3_field_getbinarydata (field, &size);
+                id3_length_t size;
+                id3_byte_t const *data;
 
-                        if (data)
-                        {
-                            if (bytes)
-                            {
-                                g_bytes_unref (bytes);
-                            }
+                data = id3_field_getbinarydata (field, &size);
 
-                            bytes = g_bytes_new (data, size);
-                        }
+                if (data)
+                {
+                    if (bytes)
+                    {
+                        g_bytes_unref (bytes);
                     }
-                    break;
-                case ID3_FIELD_TYPE_INT8:
-                    type = id3_field_getint (field);
-                    break;
-                default:
-                    break;
+
+                    bytes = g_bytes_new (data, size);
+                }
+            }
+            else if (field_type == ID3_FIELD_TYPE_INT8)
+            {
+                type = id3_field_getint (field);
             }
         }
 
@@ -1158,27 +1157,26 @@ id3tag_write_file_v24tag (const ET_File *ETFile,
             for (i = 0; (field = id3_frame_field(frame, i)); i++)
             {
                 Picture_Format format;
+                enum id3_field_type field_type;
+
+                field_type = id3_field_type (field);
                 
-                switch (id3_field_type(field))
+                if (field_type == ID3_FIELD_TYPE_LATIN1)
                 {
-                    case ID3_FIELD_TYPE_LATIN1:
-                        format = Picture_Format_From_Data(pic);
-                        id3_field_setlatin1(field, (id3_latin1_t const *)Picture_Mime_Type_String(format));
-                        break;
-                    case ID3_FIELD_TYPE_INT8:
-                        id3_field_setint(field, pic->type);
-                        break;
-                    case ID3_FIELD_TYPE_BINARYDATA:
-                        {
-                            gconstpointer data;
-                            gsize data_size;
+                    format = Picture_Format_From_Data(pic);
+                    id3_field_setlatin1(field, (id3_latin1_t const *)Picture_Mime_Type_String(format));
+                }
+                else if (field_type == ID3_FIELD_TYPE_INT8)
+                {
+                    id3_field_setint (field, pic->type);
+                }
+                else if (field_type == ID3_FIELD_TYPE_BINARYDATA)
+                {
+                    gconstpointer data;
+                    gsize data_size;
 
-                            data = g_bytes_get_data (pic->bytes, &data_size);
-                            id3_field_setbinarydata (field, data, data_size);
-                        }
-                        break;
-                    default:
-                        break;
+                    data = g_bytes_get_data (pic->bytes, &data_size);
+                    id3_field_setbinarydata (field, data, data_size);
                 }
             }
 
@@ -1392,79 +1390,114 @@ id3taglib_set_field(struct id3_frame *frame,
         if (is_set && !clear)
             break;
 
-        switch (curtype = id3_field_type(field))
+        curtype = id3_field_type (field);
+
+        if (curtype == ID3_FIELD_TYPE_TEXTENCODING)
         {
-            case ID3_FIELD_TYPE_TEXTENCODING:
-                id3_field_settextencoding(field, enc_field);
-                break;
-            case ID3_FIELD_TYPE_LATIN1:
-                if (clear)
-                    id3_field_setlatin1(field, NULL);
-                if ((type == curtype) && !is_set)
+            id3_field_settextencoding (field, enc_field);
+        }
+        else if (curtype == ID3_FIELD_TYPE_LATIN1)
+        {
+            if (clear)
+            {
+                id3_field_setlatin1 (field, NULL);
+            }
+
+            if ((type == curtype) && !is_set)
+            {
+                if (num == 0)
                 {
-                    if (num == 0)
-                    {
-                        id3_field_setlatin1(field, (id3_latin1_t const *)latinstr);
-                        is_set = 1;
-                    }else
-                        num--;
+                    id3_field_setlatin1 (field,
+                                         (id3_latin1_t const *)latinstr);
+                    is_set = 1;
                 }
-                break;
-            case ID3_FIELD_TYPE_LATIN1FULL:
+                else
+                {
+                    num--;
+                }
+            }
+        }
+        else if (curtype == ID3_FIELD_TYPE_LATIN1FULL)
+        {
                 if (clear)
-                    id3_field_setfulllatin1(field, NULL);
+                {
+                    id3_field_setfulllatin1 (field, NULL);
+                }
                 if ((type == curtype) && !is_set)
                 {
                     if (num == 0)
                     {
-                        id3_field_setfulllatin1(field, (id3_latin1_t const *)latinstr);
+                        id3_field_setfulllatin1 (field,
+                                                 (id3_latin1_t const *)latinstr);
                         is_set = 1;
-                    }else
+                    }
+                    else
+                    {
                         num--;
+                    }
                 }
-                break;
-            case ID3_FIELD_TYPE_STRING:
+        }
+        else if (curtype == ID3_FIELD_TYPE_STRING)
+        {
                 if (clear)
-                    id3_field_setstring(field, NULL);
+                {
+                    id3_field_setstring (field, NULL);
+                }
+
                 if ((type == curtype) && !is_set)
                 {
                     if (num == 0)
                     {
                         id3_field_setstring(field, buf);
                         is_set = 1;
-                    }else
+                    }
+                    else
+                    {
                         num--;
+                    }
                 }
-                break;
-            case ID3_FIELD_TYPE_STRINGFULL:
-                if (clear)
-                    id3_field_setfullstring(field, NULL);
-                if ((type == curtype) && !is_set)
+        }
+        else if (curtype == ID3_FIELD_TYPE_STRINGFULL)
+        {
+            if (clear)
+            {
+                id3_field_setfullstring (field, NULL);
+            }
+
+            if ((type == curtype) && !is_set)
+            {
+                if (num == 0)
                 {
-                    if (num == 0)
-                    {
-                        id3_field_setfullstring(field, buf);
-                        is_set = 1;
-                    }else
-                        num--;
+                    id3_field_setfullstring (field, buf);
+                    is_set = 1;
                 }
-                break;
-            case ID3_FIELD_TYPE_STRINGLIST:
-                if (clear)
-                    id3_field_setstrings(field, 0, NULL);
-                if ((type == curtype) && !is_set)
+                else
                 {
-                    if ((num == 0) && (buf))
-                    {
-                        id3_field_addstring(field, buf);
-                        is_set = 1;
-                    }else
-                        num--;
+                    num--;
                 }
-                break;
-            default:
-                break;
+            }
+        }
+        else if (curtype == ID3_FIELD_TYPE_STRINGLIST)
+        {
+            if (clear)
+            {
+                id3_field_setstrings (field, 0, NULL);
+            }
+
+            if ((type == curtype) && !is_set)
+            {
+                if ((num == 0) && (buf))
+                {
+                    id3_field_addstring (field, buf);
+                    is_set = 1;
+                }
+                else
+                {
+                    num--;
+                }
+            }
         }
+
         if (is_set)
         {
             free(latinstr);
diff --git a/src/tags/mp4_tag.cc b/src/tags/mp4_tag.cc
index b1cf2f9..6b371bf 100644
--- a/src/tags/mp4_tag.cc
+++ b/src/tags/mp4_tag.cc
@@ -456,6 +456,7 @@ mp4tag_write_file_tag (const ET_File *ETFile,
             case PICTURE_FORMAT_GIF:
                 f = TagLib::MP4::CoverArt::GIF;
                 break;
+            case PICTURE_FORMAT_UNKNOWN:
             default:
                 g_critical ("Unknown format");
                 f = TagLib::MP4::CoverArt::JPEG;
diff --git a/src/tags/mpeg_header.c b/src/tags/mpeg_header.c
index 159b526..d4b2cef 100644
--- a/src/tags/mpeg_header.c
+++ b/src/tags/mpeg_header.c
@@ -122,6 +122,8 @@ et_mpeg_header_read_file_info (GFile *file,
                 ETFileInfo->version = 2;
                 ETFileInfo->mpeg25 = TRUE;
                 break;
+            case MPEGVERSION_FALSE:
+            case MPEGVERSION_Reserved:
             default:
                 break;
         }
@@ -137,6 +139,8 @@ et_mpeg_header_read_file_info (GFile *file,
             case MPEGLAYER_III:
                 ETFileInfo->layer = 3;
                 break;
+            case MPEGLAYER_FALSE:
+            case MPEGLAYER_UNDEFINED:
             default:
                 break;
         }
@@ -159,6 +163,7 @@ et_mpeg_header_read_file_info (GFile *file,
             case MP3CHANNELMODE_SINGLE_CHANNEL:
                 ETFileInfo->mode = 3;
                 break;
+            case MP3CHANNELMODE_FALSE:
             default:
                 break;
         }
@@ -199,16 +204,17 @@ et_mpeg_header_display_file_info_to_ui (const ET_File *ETFile)
     info = ETFile->ETFileInfo;
     fields = g_slice_new (EtFileHeaderFields);
 
-    switch (ETFile->ETFileDescription->FileType)
+    if (ETFile->ETFileDescription->FileType == MP3_FILE)
     {
-        case MP3_FILE:
-            fields->description = _("MP3 File");
-            break;
-        case MP2_FILE:
-            fields->description = _("MP2 File");
-            break;
-        default:
-            g_assert_not_reached ();
+        fields->description = _("MP3 File");
+    }
+    else if (ETFile->ETFileDescription->FileType == MP2_FILE)
+    {
+        fields->description = _("MP2 File");
+    }
+    else
+    {
+        g_assert_not_reached ();
     }
 
     /* MPEG, Layer versions */
diff --git a/src/tags/ogg_header.c b/src/tags/ogg_header.c
index c7190e3..beb585b 100644
--- a/src/tags/ogg_header.c
+++ b/src/tags/ogg_header.c
@@ -382,16 +382,17 @@ et_ogg_header_display_file_info_to_ui (const ET_File *ETFile)
     info = ETFile->ETFileInfo;
     fields = g_slice_new (EtFileHeaderFields);
 
-    switch (ETFile->ETFileDescription->FileType)
+    if (ETFile->ETFileDescription->FileType == OGG_FILE)
     {
-        case OGG_FILE:
-            fields->description = _("Ogg Vorbis File");
-            break;
-        case SPEEX_FILE:
-            fields->description = _("Speex File");
-            break;
-        default:
-            g_assert_not_reached ();
+        fields->description = _("Ogg Vorbis File");
+    }
+    else if (ETFile->ETFileDescription->FileType == SPEEX_FILE)
+    {
+        fields->description = _("Speex File");
+    }
+    else
+    {
+        g_assert_not_reached ();
     }
 
     /* Encoder version */
diff --git a/src/tags/vcedit.c b/src/tags/vcedit.c
index f455ee3..2c1e26b 100644
--- a/src/tags/vcedit.c
+++ b/src/tags/vcedit.c
@@ -526,6 +526,7 @@ vcedit_open (EtOggState *state,
             headerpackets = 2;
 #endif
             break;
+        case ET_OGG_KIND_UNKNOWN:
         default:
             g_assert_not_reached ();
             break;
@@ -629,6 +630,7 @@ vcedit_open (EtOggState *state,
                             }
                             break;
 #endif
+                        case ET_OGG_KIND_UNKNOWN:
                         default:
                             g_assert_not_reached ();
                             break;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]