[librsvg] rsvg_return_*(): Removed. Use g_return_*_if_fail() instead



commit 2ac0f2c173ff94ef38943b567d5edcf813a6f523
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Jan 8 08:39:45 2019 -0600

    rsvg_return_*(): Removed.  Use g_return_*_if_fail() instead
    
    The intention was that argument checks for the public API would report
    failed assertions as part of the GError.
    
    This is wrong, however.  GError is for errors detected at
    runtime ("file not found", etc.), not for programming errors.

 librsvg/rsvg-base.c    |  6 ------
 librsvg/rsvg-handle.c  |  7 ++++---
 librsvg/rsvg-private.h | 20 --------------------
 3 files changed, 4 insertions(+), 29 deletions(-)
---
diff --git a/librsvg/rsvg-base.c b/librsvg/rsvg-base.c
index caf1453b..8ff77ff5 100644
--- a/librsvg/rsvg-base.c
+++ b/librsvg/rsvg-base.c
@@ -126,12 +126,6 @@ rsvg_cleanup (void)
 {
 }
 
-void
-rsvg_return_if_fail_warning (const char *pretty_function, const char *expression, GError ** error)
-{
-    g_set_error (error, RSVG_ERROR, 0, _("%s: assertion `%s' failed"), pretty_function, expression);
-}
-
 /* This is defined like this so that we can export the Rust function... just for
  * the benefit of rsvg-convert.c
  */
diff --git a/librsvg/rsvg-handle.c b/librsvg/rsvg-handle.c
index a6e28348..94695249 100644
--- a/librsvg/rsvg-handle.c
+++ b/librsvg/rsvg-handle.c
@@ -534,7 +534,8 @@ rsvg_handle_new_from_file (const gchar *file_name, GError **error)
     GFile *file;
     char *scheme;
 
-    rsvg_return_val_if_fail (file_name != NULL, NULL, error);
+    g_return_val_if_fail (file_name != NULL, NULL);
+    g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
     scheme = g_uri_parse_scheme (file_name);
     if (scheme) {
@@ -688,7 +689,7 @@ rsvg_handle_new_from_stream_sync (GInputStream   *input_stream,
 gboolean
 rsvg_handle_write (RsvgHandle *handle, const guchar *buf, gsize count, GError **error)
 {
-    rsvg_return_val_if_fail (RSVG_IS_HANDLE (handle), FALSE, error);
+    g_return_val_if_fail (RSVG_IS_HANDLE (handle), FALSE);
     g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
     g_return_val_if_fail ((buf != NULL && count != 0) || (count == 0), FALSE);
 
@@ -713,8 +714,8 @@ rsvg_handle_write (RsvgHandle *handle, const guchar *buf, gsize count, GError **
 gboolean
 rsvg_handle_close (RsvgHandle *handle, GError **error)
 {
+    g_return_val_if_fail (RSVG_IS_HANDLE (handle), FALSE);
     g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-    rsvg_return_val_if_fail (handle, FALSE, error);
 
     return rsvg_handle_rust_close(handle, error);
 }
diff --git a/librsvg/rsvg-private.h b/librsvg/rsvg-private.h
index e50b2a18..9fcda474 100644
--- a/librsvg/rsvg-private.h
+++ b/librsvg/rsvg-private.h
@@ -50,26 +50,6 @@ G_BEGIN_DECLS
 #define N_(X) X
 #endif
 
-G_GNUC_INTERNAL
-void rsvg_return_if_fail_warning (const char *pretty_function,
-                                  const char *expression, GError ** error);
-
-#define rsvg_return_if_fail(expr, error)    G_STMT_START{           \
-     if G_LIKELY(expr) { } else                                     \
-       {                                                            \
-           rsvg_return_if_fail_warning (G_STRFUNC,                  \
-                                        #expr, error);              \
-           return;                                                  \
-       };                              }G_STMT_END
-
-#define rsvg_return_val_if_fail(expr,val,error)        G_STMT_START{       \
-     if G_LIKELY(expr) { } else                                     \
-       {                                                            \
-           rsvg_return_if_fail_warning (G_STRFUNC,                  \
-                                        #expr, error);              \
-           return (val);                                            \
-       };                              }G_STMT_END
-
 G_END_DECLS
 
 #endif


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