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

gEDA-cvs: gaf.git: branch: master updated (1.5.0-20080706-164-g78224ab)



The branch, master has been updated
       via  78224abe91c881df499244aff2691432f0e61b55 (commit)
      from  29010f3c07076c31eaaf39a0209b6b9e8cd7cadd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 libgeda/src/f_basic.c |   25 ++++++++++---------------
 1 files changed, 10 insertions(+), 15 deletions(-)


=================
 Commit Messages
=================

commit 78224abe91c881df499244aff2691432f0e61b55
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Thu Sep 11 21:31:30 2008 +0100

    Change f_open_flags to only return FALSE when the return GError is set.
    
    Callers assuming the GError is set when we return FALSE may crash
    if we return FALSE without setting it. Such a crash was noticed with
    development code where o_read() returned NULL without setting the GError.
    
    In the current code, o_read() should never return FALSE without setting
    the GError, and those cases where it could potentially in the future are
    g_return_val_if_fail() constructs used to detect programming errors.
    Programming errors are NOT meant to be reported via the GError mechanism.
    
    Call o_read() with a temporary GError, so we can still return FALSE from
    f_open_flags() if we encounter a problem and the user has passed
    err = NULL, disabling detailed error reporting.
    
    Don't test for NULL returns from o_read(), continue as if the page loaded
    was empty. If o_read() were to return a GList in the future, these errors
    become indistinguishable from an empty list. Tests returning NULL
    should log appropriate error messages via g_return_val_if_fail().
    
    Since we don't test it, don't assign the return value of o_read() to the
    page's object_tail. We already re-assign object_tail based on walking the
    linked list from its head anyway, so there is no need.

:100644 100644 1215b1d... 557f4fd... M	libgeda/src/f_basic.c

=========
 Changes
=========

commit 78224abe91c881df499244aff2691432f0e61b55
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Thu Sep 11 21:31:30 2008 +0100

    Change f_open_flags to only return FALSE when the return GError is set.
    
    Callers assuming the GError is set when we return FALSE may crash
    if we return FALSE without setting it. Such a crash was noticed with
    development code where o_read() returned NULL without setting the GError.
    
    In the current code, o_read() should never return FALSE without setting
    the GError, and those cases where it could potentially in the future are
    g_return_val_if_fail() constructs used to detect programming errors.
    Programming errors are NOT meant to be reported via the GError mechanism.
    
    Call o_read() with a temporary GError, so we can still return FALSE from
    f_open_flags() if we encounter a problem and the user has passed
    err = NULL, disabling detailed error reporting.
    
    Don't test for NULL returns from o_read(), continue as if the page loaded
    was empty. If o_read() were to return a GList in the future, these errors
    become indistinguishable from an empty list. Tests returning NULL
    should log appropriate error messages via g_return_val_if_fail().
    
    Since we don't test it, don't assign the return value of o_read() to the
    page's object_tail. We already re-assign object_tail based on walking the
    linked list from its head anyway, so there is no need.

diff --git a/libgeda/src/f_basic.c b/libgeda/src/f_basic.c
index 1215b1d..557f4fd 100644
--- a/libgeda/src/f_basic.c
+++ b/libgeda/src/f_basic.c
@@ -273,25 +273,21 @@ int f_open_flags(TOPLEVEL *toplevel, const gchar *filename,
    * the RC file, it's time to read in the file. */
   if (load_backup_file == 1) {
     /* Load the backup file */
-    toplevel->page_current->object_tail = (OBJECT *)
-    o_read(toplevel, toplevel->page_current->object_tail,
-	   backup_filename, err);
+    o_read (toplevel, toplevel->page_current->object_tail,
+            backup_filename, &tmp_err);
   } else {
     /* Load the original file */
-    toplevel->page_current->object_tail = (OBJECT *)
-    o_read(toplevel, toplevel->page_current->object_tail,
-	   full_filename, err);
+    o_read (toplevel, toplevel->page_current->object_tail,
+            full_filename, &tmp_err);
   }
 
-  if (toplevel->page_current->object_tail != NULL) {
+  if (tmp_err == NULL)
     opened = TRUE;
-  } else {
-    /* Failed to open page */
-    opened = FALSE;	 
-  }
+  else
+    g_propagate_error (err, tmp_err);
 
-  toplevel->page_current->object_tail
-    = (OBJECT *) return_tail(toplevel->page_current->object_head);
+  toplevel->page_current->object_tail =
+    return_tail(toplevel->page_current->object_head);
 
   /* make sure you init net_consolide to false (default) in all */
   /* programs */
@@ -302,8 +298,7 @@ int f_open_flags(TOPLEVEL *toplevel, const gchar *filename,
   if (load_backup_file == 0) {
     /* If it's not the backup file */
     toplevel->page_current->CHANGED=0; /* added 4/7/98 */
-  }
-  else {
+  } else {
     /* We are loading the backup file, so gschem should ask
        the user if save it or not when closing the page. */
     toplevel->page_current->CHANGED=1;




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs