OSDN Git Service

parted.h: use _GL_ATTRIBUTE_CONST and _GL_ATTRIBUTE_PURE in VC'd files
[android-x86/external-parted.git] / libparted / debug.c
index a7d73f9..ceca0c5 100644 (file)
@@ -1,10 +1,10 @@
 /*
     libparted - a library for manipulating disk partitions
-    Copyright (C) 2000, 2005, 2007 Free Software Foundation, Inc.
+    Copyright (C) 2000, 2005, 2007, 2009-2012 Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
+    the Free Software Foundation; either version 3 of the License, or
     (at your option) any later version.
 
     This program is distributed in the hope that it will be useful,
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "config.h"
+#include <config.h>
 #include <parted/parted.h>
 #include <parted/debug.h>
 
@@ -61,14 +60,14 @@ void ped_debug ( const int level, const char* file, int line,
 {
         va_list         arg_list;
         char*           msg_concat = ped_malloc(8192);
-        
+
         va_start ( arg_list, msg );
                 vsnprintf ( msg_concat, 8192, msg, arg_list );
         va_end ( arg_list );
-        
+
         debug_handler ( level, file, line, function, msg_concat );
 
-        ped_free ( msg_concat );
+        free ( msg_concat );
 }
 
 /*
@@ -83,39 +82,33 @@ void ped_debug_set_handler ( PedDebugHandler* handler )
  * Check an assertion.
  * Do not call this directly -- use PED_ASSERT() instead.
  */
-int ped_assert ( int cond, const char* cond_text,
-           const char* file, int line, const char* function )
+void ped_assert (const char* cond_text,
+                 const char* file, int line, const char* function)
 {
-       PedExceptionOption      opt;
-
-       if ( cond )
-               return 1;
-
 #if HAVE_BACKTRACE
-       /* Print backtrace stack */
-       void *stack[20];
-       char **strings, **string;
+        /* Print backtrace stack */
+        void *stack[20];
+        char **strings, **string;
         int size = backtrace(stack, 20);
-       strings = backtrace_symbols(stack, size);
+        strings = backtrace_symbols(stack, size);
 
-       if (strings) {
-               printf(_("Backtrace has %d calls on stack:\n"), size);
-               for (string = strings; size > 0; size--, string++)
-                       printf("  %d: %s\n", size, *string);
+        if (strings) {
+                printf(_("Backtrace has %d calls on stack:\n"), size);
 
-               free(strings);
-       }
-#endif
+                for (string = strings; size > 0; size--, string++)
+                        printf("  %d: %s\n", size, *string);
 
-       /* Throw the exception */
-       opt = ped_exception_throw (
-               PED_EXCEPTION_BUG,
-               PED_EXCEPTION_IGNORE_CANCEL,
-               _("Assertion (%s) at %s:%d in function %s() failed."),
-               cond_text, file, line, function );
+                free(strings);
+        }
+#endif
 
-       return ( opt == PED_EXCEPTION_IGNORE );
+        /* Throw the exception */
+        ped_exception_throw (
+                PED_EXCEPTION_BUG,
+                PED_EXCEPTION_FATAL,
+                _("Assertion (%s) at %s:%d in function %s() failed."),
+                cond_text, file, line, function);
+        abort ();
 }
 
 #endif /* DEBUG */
-