[yelp] Fix unhandled case in switch warnings



commit 6753f261bc9b235c3588583213f6b2799a52b3ba
Author: David King <amigadave amigadave com>
Date:   Mon Feb 9 20:44:07 2015 +0000

    Fix unhandled case in switch warnings

 libyelp/yelp-document.c |   20 +++++++++++---------
 libyelp/yelp-view.c     |   18 +++++++++---------
 2 files changed, 20 insertions(+), 18 deletions(-)
---
diff --git a/libyelp/yelp-document.c b/libyelp/yelp-document.c
index 6839d32..271a899 100644
--- a/libyelp/yelp-document.c
+++ b/libyelp/yelp-document.c
@@ -158,6 +158,7 @@ YelpDocument *
 yelp_document_get_for_uri (YelpUri *uri)
 {
     static GHashTable *documents = NULL;
+    YelpUriDocumentType doctype;
     gchar *docuri = NULL;
     gchar *page_id, *tmp;
     YelpDocument *document = NULL;
@@ -168,10 +169,11 @@ yelp_document_get_for_uri (YelpUri *uri)
 
     g_return_val_if_fail (yelp_uri_is_resolved (uri), NULL);
 
-    switch (yelp_uri_get_document_type (uri)) {
-    case YELP_URI_DOCUMENT_TYPE_TEXT:
-    case YELP_URI_DOCUMENT_TYPE_HTML:
-    case YELP_URI_DOCUMENT_TYPE_XHTML:
+    doctype = yelp_uri_get_document_type (uri);
+
+    if (doctype == YELP_URI_DOCUMENT_TYPE_TEXT ||
+        doctype == YELP_URI_DOCUMENT_TYPE_HTML ||
+        doctype == YELP_URI_DOCUMENT_TYPE_XHTML) {
         /* We use YelpSimpleDocument for these, which is a single-file
          * responder. But the document URI may be set to the directory
          * holding the file, to allow a directory of HTML files to act
@@ -183,16 +185,15 @@ yelp_document_get_for_uri (YelpUri *uri)
         g_free (docuri);
         g_free (page_id);
         docuri = tmp;
-        break;
-    case YELP_URI_DOCUMENT_TYPE_MAN:
+    }
+    else if (doctype == YELP_URI_DOCUMENT_TYPE_MAN) {
         /* The document URI for man pages is just man:, so we use the
          * full canonical URI to look these up.
          */
         docuri = yelp_uri_get_canonical_uri (uri);
-        break;
-    default:
+    }
+    else {
         docuri = yelp_uri_get_document_uri (uri);
-        break;
     }
 
     if (docuri == NULL)
@@ -229,6 +230,7 @@ yelp_document_get_for_uri (YelpUri *uri)
     case YELP_URI_DOCUMENT_TYPE_EXTERNAL:
     case YELP_URI_DOCUMENT_TYPE_ERROR:
         break;
+    case YELP_URI_DOCUMENT_TYPE_UNRESOLVED:
     default:
         g_assert_not_reached ();
     }
diff --git a/libyelp/yelp-view.c b/libyelp/yelp-view.c
index 8027889..0a82119 100644
--- a/libyelp/yelp-view.c
+++ b/libyelp/yelp-view.c
@@ -1905,20 +1905,22 @@ uri_resolved (YelpUri  *uri,
               YelpView *view)
 {
     YelpViewPrivate *priv = GET_PRIV (view);
+    YelpUriDocumentType doctype;
     YelpDocument *document;
     YelpBackEntry *back;
     GError *error = NULL;
     gchar *struri;
     GParamSpec *spec;
 
-    if (yelp_uri_get_document_type (uri) != YELP_URI_DOCUMENT_TYPE_EXTERNAL) {
+    doctype = yelp_uri_get_document_type (uri);
+
+    if (doctype != YELP_URI_DOCUMENT_TYPE_EXTERNAL) {
         g_object_ref (uri);
         view_clear_load (view);
         priv->uri = uri;
     }
 
-    switch (yelp_uri_get_document_type (uri)) {
-    case YELP_URI_DOCUMENT_TYPE_EXTERNAL:
+    if (doctype == YELP_URI_DOCUMENT_TYPE_EXTERNAL) {
         g_object_set (view, "state", priv->prevstate, NULL);
         struri = yelp_uri_get_canonical_uri (uri);
         if (g_str_has_prefix (struri, "install:") ||
@@ -1932,7 +1934,8 @@ uri_resolved (YelpUri  *uri,
         }
         g_free (struri);
         return;
-    case YELP_URI_DOCUMENT_TYPE_NOT_FOUND:
+    }
+    else if (doctype == YELP_URI_DOCUMENT_TYPE_NOT_FOUND) {
         struri = yelp_uri_get_canonical_uri (uri);
         if (struri != NULL) {
             error = g_error_new (YELP_ERROR, YELP_ERROR_NOT_FOUND,
@@ -1944,16 +1947,13 @@ uri_resolved (YelpUri  *uri,
             error = g_error_new (YELP_ERROR, YELP_ERROR_NOT_FOUND,
                                  _("The URI does not point to a valid page."));
         }
-        break;
-    case YELP_URI_DOCUMENT_TYPE_ERROR:
+    }
+    else if (doctype == YELP_URI_DOCUMENT_TYPE_ERROR) {
         struri = yelp_uri_get_canonical_uri (uri);
         error = g_error_new (YELP_ERROR, YELP_ERROR_PROCESSING,
                              _("The URI ā€˜%sā€™ could not be parsed."),
                              struri);
         g_free (struri);
-        break;
-    default:
-        break;
     }
 
     if (error == NULL) {


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