[devhelp] DhLink: improve the pre-conditions checks of dh_link_new()



commit 3e5b06d75ed84bbb60712d6d68437415f3c71d92
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Jun 3 17:58:35 2017 +0200

    DhLink: improve the pre-conditions checks of dh_link_new()
    
    Based on the code in dh-parser, the only place where dh_link_new() is
    called.

 src/dh-link.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/dh-link.c b/src/dh-link.c
index 2f88e7c..4d4f236 100644
--- a/src/dh-link.c
+++ b/src/dh-link.c
@@ -88,8 +88,7 @@ link_free (DhLink *link)
  * @base_path and @book_id must be provided only for a link of type
  * %DH_LINK_TYPE_BOOK.
  *
- * If @type is not a #DH_LINK_TYPE_BOOK and not a #DH_LINK_TYPE_PAGE, then the
- * @book link must be provided.
+ * If @type is not a #DH_LINK_TYPE_BOOK, then the @book link must be provided.
  *
  * @name and @relative_url must always be provided.
  *
@@ -111,9 +110,10 @@ dh_link_new (DhLinkType   type,
         if (type == DH_LINK_TYPE_BOOK) {
                 g_return_val_if_fail (base_path != NULL, NULL);
                 g_return_val_if_fail (book_id != NULL, NULL);
-        }
-        if (type != DH_LINK_TYPE_BOOK &&
-            type != DH_LINK_TYPE_PAGE) {
+                g_return_val_if_fail (book == NULL, NULL);
+        } else {
+                g_return_val_if_fail (base_path == NULL, NULL);
+                g_return_val_if_fail (book_id == NULL, NULL);
                 g_return_val_if_fail (book != NULL, NULL);
         }
 


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