2007-12-10 15:08:59  Tim Janik  <timj@imendio.com>

        * let g_warn_if_fail replace g_assert as discussed here:
          http://mail.gnome.org/archives/gtk-devel-list/2007-October/msg00089.html

        * fix bug #502498: Test framework assertion failures should follow
        gcc error format.

        * gmessages.h, gmessages.c: deprecated g_assert_warning() which is
        unused now. removed g_assert*() definitions whcih are provided by 
        gtestutils.h now. added g_warn_if_reached() and g_warn_if_fail()  
        which are recommended as g_assert/g_assert_not_reached replacements
        for non-test programs.
        added g_warn_message() to implement g_warn_*() macros.
        use emacs-next-error friendly formatting for file:line: for warnings.

        * gtestutils.h, gtestutils.c: use emacs-next-error friendly formatting.
        implement g_assert_not_reached() with g_assertion_message() and
        g_assert() in terms of g_assertion_message_expr() so we'll be able to
        provide assertion messages in test logs.

        * gkeyfile.c, gbookmarkfile.c: changed g_assert*() to g_warn_if_fail()
        or g_return_if_fail() where suitable.

        * gio/: changed g_assert to g_warn_if_fail.



svn path=/trunk/; revision=6086
This commit is contained in:
15:08:59 Tim Janik 2007-12-10 14:07:42 +00:00 committed by Tim Janik
parent 0dbfa89ba1
commit cc3de68e21
31 changed files with 172 additions and 148 deletions

View File

@ -1,3 +1,29 @@
2007-12-10 15:08:59 Tim Janik <timj@imendio.com>
* let g_warn_if_fail replace g_assert as discussed here:
http://mail.gnome.org/archives/gtk-devel-list/2007-October/msg00089.html
* fix bug #502498: Test framework assertion failures should follow
gcc error format.
* gmessages.h, gmessages.c: deprecated g_assert_warning() which is
unused now. removed g_assert*() definitions whcih are provided by
gtestutils.h now. added g_warn_if_reached() and g_warn_if_fail()
which are recommended as g_assert/g_assert_not_reached replacements
for non-test programs.
added g_warn_message() to implement g_warn_*() macros.
use emacs-next-error friendly formatting for file:line: for warnings.
* gtestutils.h, gtestutils.c: use emacs-next-error friendly formatting.
implement g_assert_not_reached() with g_assertion_message() and
g_assert() in terms of g_assertion_message_expr() so we'll be able to
provide assertion messages in test logs.
* gkeyfile.c, gbookmarkfile.c: changed g_assert*() to g_warn_if_fail()
or g_return_if_fail() where suitable.
* gio/: changed g_assert to g_warn_if_fail.
2007-12-10 13:02:08 Tim Janik <timj@imendio.com>
* glib/gtestutils.c (g_assertion_message_cmpnum): applied patch by Tommi

View File

@ -111,7 +111,7 @@ fd_source_dispatch (GSource *source,
GFDSourceFunc func = (GFDSourceFunc)callback;
FDSource *fd_source = (FDSource *)source;
g_assert (func != NULL);
g_warn_if_fail (func != NULL);
return (*func) (user_data, fd_source->pollfd.revents, fd_source->pollfd.fd);
}

View File

@ -983,7 +983,7 @@ g_buffered_input_stream_real_fill_finish (GBufferedInputStream *stream,
gssize nread;
simple = G_SIMPLE_ASYNC_RESULT (result);
g_assert (g_simple_async_result_get_source_tag (simple) == g_buffered_input_stream_real_fill_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_buffered_input_stream_real_fill_async);
nread = g_simple_async_result_get_op_res_gssize (simple);
return nread;
@ -1161,7 +1161,7 @@ g_buffered_input_stream_read_finish (GInputStream *stream,
simple = G_SIMPLE_ASYNC_RESULT (result);
g_assert (g_simple_async_result_get_source_tag (simple) == g_buffered_input_stream_read_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_buffered_input_stream_read_async);
data = g_simple_async_result_get_op_res_gpointer (simple);
@ -1333,7 +1333,7 @@ g_buffered_input_stream_skip_finish (GInputStream *stream,
simple = G_SIMPLE_ASYNC_RESULT (result);
g_assert (g_simple_async_result_get_source_tag (simple) == g_buffered_input_stream_skip_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_buffered_input_stream_skip_async);
data = g_simple_async_result_get_op_res_gpointer (simple);

View File

@ -659,7 +659,7 @@ g_buffered_output_stream_write_finish (GOutputStream *stream,
buffered_stream = G_BUFFERED_OUTPUT_STREAM (stream);
priv = buffered_stream->priv;
g_assert (g_simple_async_result_get_source_tag (simple) ==
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) ==
g_buffered_output_stream_write_async);
wdata = g_simple_async_result_get_op_res_gpointer (simple);
@ -712,7 +712,7 @@ g_buffered_output_stream_flush_finish (GOutputStream *stream,
simple = G_SIMPLE_ASYNC_RESULT (result);
g_assert (g_simple_async_result_get_source_tag (simple) ==
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) ==
g_buffered_output_stream_flush_async);
return TRUE;
@ -754,7 +754,7 @@ g_buffered_output_stream_close_finish (GOutputStream *stream,
simple = G_SIMPLE_ASYNC_RESULT (result);
g_assert (g_simple_async_result_get_source_tag (simple) ==
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) ==
g_buffered_output_stream_flush_async);
return TRUE;

View File

@ -169,7 +169,7 @@ g_push_current_cancellable (GCancellable *cancellable)
{
GSList *l;
g_assert (cancellable != NULL);
g_return_if_fail (cancellable != NULL);
l = g_static_private_get (&current_cancellable);
l = g_slist_prepend (l, cancellable);
@ -190,8 +190,8 @@ g_pop_current_cancellable (GCancellable *cancellable)
l = g_static_private_get (&current_cancellable);
g_assert (l != NULL);
g_assert (l->data == cancellable);
g_return_if_fail (l != NULL);
g_return_if_fail (l->data == cancellable);
l = g_slist_delete_link (l, l);
g_static_private_set (&current_cancellable, l, NULL);

View File

@ -313,7 +313,7 @@ read_data (GDataInputStream *stream,
res = g_input_stream_read (G_INPUT_STREAM (stream),
buffer, size,
NULL, NULL);
g_assert (res == size);
g_warn_if_fail (res == size);
return TRUE;
}
@ -797,7 +797,7 @@ g_data_input_stream_read_line (GDataInputStream *stream,
NULL, NULL);
if (length)
*length = (gsize)found_pos;
g_assert (res == found_pos + newline_len);
g_warn_if_fail (res == found_pos + newline_len);
line[found_pos] = 0;
return line;
@ -917,7 +917,7 @@ g_data_input_stream_read_until (GDataInputStream *stream,
NULL, NULL);
if (length)
*length = (gsize)found_pos;
g_assert (res == found_pos + stop_char_len);
g_warn_if_fail (res == found_pos + stop_char_len);
data_until[found_pos] = 0;
return data_until;

View File

@ -496,7 +496,7 @@ unescape_string (const gchar *escaped_string,
}
*out = '\0';
g_assert (out - result <= strlen (escaped_string));
g_warn_if_fail (out - result <= strlen (escaped_string));
return result;
}

View File

@ -3291,7 +3291,7 @@ g_file_real_query_info_finish (GFile *file,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
QueryInfoAsyncData *data;
g_assert (g_simple_async_result_get_source_tag (simple) == g_file_real_query_info_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_real_query_info_async);
data = g_simple_async_result_get_op_res_gpointer (simple);
if (data->info)
@ -3368,7 +3368,7 @@ g_file_real_enumerate_children_finish (GFile *file,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
EnumerateChildrenAsyncData *data;
g_assert (g_simple_async_result_get_source_tag (simple) == g_file_real_enumerate_children_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_real_enumerate_children_async);
data = g_simple_async_result_get_op_res_gpointer (simple);
if (data->enumerator)
@ -3422,7 +3422,7 @@ g_file_real_read_finish (GFile *file,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
gpointer op;
g_assert (g_simple_async_result_get_source_tag (simple) == g_file_real_read_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_real_read_async);
op = g_simple_async_result_get_op_res_gpointer (simple);
if (op)
@ -3485,7 +3485,7 @@ g_file_real_append_to_finish (GFile *file,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
gpointer op;
g_assert (g_simple_async_result_get_source_tag (simple) == g_file_real_append_to_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_real_append_to_async);
op = g_simple_async_result_get_op_res_gpointer (simple);
if (op)
@ -3548,7 +3548,7 @@ g_file_real_create_finish (GFile *file,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
gpointer op;
g_assert (g_simple_async_result_get_source_tag (simple) == g_file_real_create_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_real_create_async);
op = g_simple_async_result_get_op_res_gpointer (simple);
if (op)
@ -3636,7 +3636,7 @@ g_file_real_replace_finish (GFile *file,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
ReplaceAsyncData *data;
g_assert (g_simple_async_result_get_source_tag (simple) == g_file_real_replace_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_real_replace_async);
data = g_simple_async_result_get_op_res_gpointer (simple);
if (data->stream)
@ -3710,7 +3710,7 @@ g_file_real_set_display_name_finish (GFile *file,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
SetDisplayNameAsyncData *data;
g_assert (g_simple_async_result_get_source_tag (simple) == g_file_real_set_display_name_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_real_set_display_name_async);
data = g_simple_async_result_get_op_res_gpointer (simple);
if (data->file)
@ -3785,7 +3785,7 @@ g_file_real_set_attributes_finish (GFile *file,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
SetInfoAsyncData *data;
g_assert (g_simple_async_result_get_source_tag (simple) == g_file_real_set_attributes_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_real_set_attributes_async);
data = g_simple_async_result_get_op_res_gpointer (simple);
@ -4338,7 +4338,7 @@ g_file_load_partial_contents_finish (GFile *file,
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
g_assert (g_simple_async_result_get_source_tag (simple) == g_file_load_contents_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_load_contents_async);
data = g_simple_async_result_get_op_res_gpointer (simple);
@ -4738,7 +4738,7 @@ g_file_replace_contents_finish (GFile *file,
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
g_assert (g_simple_async_result_get_source_tag (simple) == g_file_replace_contents_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_replace_contents_async);
data = g_simple_async_result_get_op_res_gpointer (simple);

View File

@ -602,7 +602,7 @@ g_file_enumerator_real_next_files_finish (GFileEnumerator *enumer
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
NextAsyncOp *op;
g_assert (g_simple_async_result_get_source_tag (simple) ==
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) ==
g_file_enumerator_real_next_files_async);
op = g_simple_async_result_get_op_res_gpointer (simple);
@ -663,7 +663,7 @@ g_file_enumerator_real_close_finish (GFileEnumerator *enumerator,
GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
g_assert (g_simple_async_result_get_source_tag (simple) ==
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) ==
g_file_enumerator_real_close_async);
return TRUE;
}

View File

@ -252,7 +252,7 @@ g_file_icon_load_finish (GLoadableIcon *icon,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
gpointer op;
g_assert (g_simple_async_result_get_source_tag (simple) == g_file_icon_load_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_icon_load_async);
if (type)
*type = NULL;

View File

@ -477,7 +477,7 @@ g_file_input_stream_real_query_info_finish (GFileInputStream *stream,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
QueryInfoAsyncData *data;
g_assert (g_simple_async_result_get_source_tag (simple) == g_file_input_stream_real_query_info_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_input_stream_real_query_info_async);
data = g_simple_async_result_get_op_res_gpointer (simple);
if (data->info)

View File

@ -591,7 +591,7 @@ g_file_output_stream_real_query_info_finish (GFileOutputStream *stream,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
QueryInfoAsyncData *data;
g_assert (g_simple_async_result_get_source_tag (simple) == g_file_output_stream_real_query_info_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_output_stream_real_query_info_async);
data = g_simple_async_result_get_op_res_gpointer (simple);
if (data->info)

View File

@ -976,7 +976,7 @@ g_input_stream_real_read_finish (GInputStream *stream,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
ReadData *op;
g_assert (g_simple_async_result_get_source_tag (simple) ==
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) ==
g_input_stream_real_read_async);
op = g_simple_async_result_get_op_res_gpointer (simple);
@ -1133,7 +1133,7 @@ g_input_stream_real_skip_finish (GInputStream *stream,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
SkipData *op;
g_assert (g_simple_async_result_get_source_tag (simple) == g_input_stream_real_skip_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_input_stream_real_skip_async);
op = g_simple_async_result_get_op_res_gpointer (simple);
return op->count_skipped;
}
@ -1190,7 +1190,7 @@ g_input_stream_real_close_finish (GInputStream *stream,
GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
g_assert (g_simple_async_result_get_source_tag (simple) == g_input_stream_real_close_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_input_stream_real_close_async);
return TRUE;
}

View File

@ -261,7 +261,7 @@ g_loadable_icon_real_load_finish (GLoadableIcon *icon,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
LoadData *data;
g_assert (g_simple_async_result_get_source_tag (simple) == g_loadable_icon_real_load_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_loadable_icon_real_load_async);
data = g_simple_async_result_get_op_res_gpointer (simple);

View File

@ -102,7 +102,7 @@ g_local_directory_monitor_constructor (GType type,
{
if (strcmp ("dirname", g_param_spec_get_name (construct_properties[i].pspec)) == 0)
{
g_assert (G_VALUE_HOLDS_STRING (construct_properties[i].value));
g_warn_if_fail (G_VALUE_HOLDS_STRING (construct_properties[i].value));
dirname = g_value_get_string (construct_properties[i].value);
break;
}

View File

@ -728,7 +728,7 @@ set_xattr (char *filename,
}
else
{
g_assert (g_str_has_prefix (escaped_attribute, "xattr_sys:"));
g_warn_if_fail (g_str_has_prefix (escaped_attribute, "xattr_sys:"));
escaped_attribute += 10;
is_user = FALSE;
}
@ -991,7 +991,7 @@ make_valid_utf8 (const char *name)
g_string_append (string, remainder);
g_assert (g_utf8_validate (string->str, -1, NULL));
g_warn_if_fail (g_utf8_validate (string->str, -1, NULL));
return g_string_free (string, FALSE);
}

View File

@ -83,13 +83,13 @@ g_local_file_monitor_constructor (GType type,
{
if (strcmp ("filename", g_param_spec_get_name (construct_properties[i].pspec)) == 0)
{
g_assert (G_VALUE_HOLDS_STRING (construct_properties[i].value));
g_warn_if_fail (G_VALUE_HOLDS_STRING (construct_properties[i].value));
filename = g_value_get_string (construct_properties[i].value);
break;
}
}
g_assert (filename != NULL);
g_warn_if_fail (filename != NULL);
local_monitor->filename = g_strdup (filename);
return obj;

View File

@ -322,7 +322,7 @@ g_memory_input_stream_read_finish (GInputStream *stream,
gssize nread;
simple = G_SIMPLE_ASYNC_RESULT (result);
g_assert (g_simple_async_result_get_source_tag (simple) == g_memory_input_stream_read_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_memory_input_stream_read_async);
nread = g_simple_async_result_get_op_res_gssize (simple);
return nread;
@ -358,7 +358,7 @@ g_memory_input_stream_skip_finish (GInputStream *stream,
gssize nskipped;
simple = G_SIMPLE_ASYNC_RESULT (result);
g_assert (g_simple_async_result_get_source_tag (simple) == g_memory_input_stream_skip_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_memory_input_stream_skip_async);
nskipped = g_simple_async_result_get_op_res_gssize (simple);
return nskipped;

View File

@ -543,7 +543,7 @@ g_memory_output_stream_write_finish (GOutputStream *stream,
simple = G_SIMPLE_ASYNC_RESULT (result);
g_assert (g_simple_async_result_get_source_tag (simple) ==
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) ==
g_memory_output_stream_write_async);
nwritten = g_simple_async_result_get_op_res_gssize (simple);
@ -581,7 +581,7 @@ g_memory_output_stream_close_finish (GOutputStream *stream,
simple = G_SIMPLE_ASYNC_RESULT (result);
g_assert (g_simple_async_result_get_source_tag (simple) ==
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) ==
g_memory_output_stream_close_async);
return TRUE;

View File

@ -1151,7 +1151,7 @@ g_output_stream_real_write_finish (GOutputStream *stream,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
WriteData *op;
g_assert (g_simple_async_result_get_source_tag (simple) == g_output_stream_real_write_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_output_stream_real_write_async);
op = g_simple_async_result_get_op_res_gpointer (simple);
return op->count_written;
}
@ -1221,7 +1221,7 @@ g_output_stream_real_splice_finish (GOutputStream *stream,
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
SpliceData *op;
g_assert (g_simple_async_result_get_source_tag (simple) == g_output_stream_real_splice_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_output_stream_real_splice_async);
op = g_simple_async_result_get_op_res_gpointer (simple);
return op->bytes_copied;
}
@ -1317,7 +1317,7 @@ g_output_stream_real_close_finish (GOutputStream *stream,
GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
g_assert (g_simple_async_result_get_source_tag (simple) == g_output_stream_real_close_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_output_stream_real_close_async);
return TRUE;
}

View File

@ -354,7 +354,7 @@ g_unix_input_stream_read_finish (GInputStream *stream,
gssize nread;
simple = G_SIMPLE_ASYNC_RESULT (result);
g_assert (g_simple_async_result_get_source_tag (simple) == g_unix_input_stream_read_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_unix_input_stream_read_async);
nread = g_simple_async_result_get_op_res_gssize (simple);
return nread;
@ -368,7 +368,7 @@ g_unix_input_stream_skip_async (GInputStream *stream,
GAsyncReadyCallback callback,
gpointer data)
{
g_assert_not_reached ();
g_warn_if_reached ();
/* TODO: Not implemented */
}
@ -377,7 +377,7 @@ g_unix_input_stream_skip_finish (GInputStream *stream,
GAsyncResult *result,
GError **error)
{
g_assert_not_reached ();
g_warn_if_reached ();
/* TODO: Not implemented */
}

View File

@ -345,7 +345,7 @@ g_unix_output_stream_write_finish (GOutputStream *stream,
gssize nwritten;
simple = G_SIMPLE_ASYNC_RESULT (result);
g_assert (g_simple_async_result_get_source_tag (simple) == g_unix_output_stream_write_async);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_unix_output_stream_write_async);
nwritten = g_simple_async_result_get_op_res_gssize (simple);
return nwritten;

View File

@ -62,7 +62,7 @@ g_unix_volume_finalize (GObject *object)
if (volume->drive)
_g_unix_drive_unset_volume (volume->drive, volume);
g_assert (volume->drive == NULL);
g_warn_if_fail (volume->drive == NULL);
g_free (volume->name);
g_free (volume->icon);
g_free (volume->mountpoint);

View File

@ -9,7 +9,7 @@ if ! which readelf 2>/dev/null >/dev/null; then
exit 0
fi
SKIP='\<g_access\|\<g_array_\|\<g_ascii\|\<g_list_\|\<g_assert_warning\|\<g_atomic_int\|\<g_build_filename\|\<g_byte_array\|\<g_child_watch\|\<g_convert\|\<g_dir_\|\<g_error_\|\<g_file_error_quark\|\<g_file_get_contents\|\<g_file_set_contents\|\<g_file_test\|\<g_filename_\|\<g_find_program_in_path\|\<g_free\|\<g_get_\|\<g_getenv\|\<g_hash_table_\|\<g_idle_\|\<g_intern_static_string\|\<g_io_channel_\|\<g_key_file_\|\<g_listenv\|\<g_locale_to_utf8\|\<g_log\|\<g_main_context_wakeup\|\<g_malloc\|\<g_markup_\|\<g_mkdir_\|\<g_mkstemp\|\<g_module_\|\<g_object_\|\<g_once_\|\<g_param_spec_\|\<g_path_\|\<g_printerr\|\<g_propagate_error\|\<g_ptr_array_\|\<g_qsort_\|\<g_quark_\|\<g_queue_\|\<g_realloc\|\<g_return_if_fail\|\<g_set_error\|\<g_shell_\|\<g_signal_\|\<g_slice_\|\<g_slist_\|\<g_snprintf\|\<g_source_\|\<g_spawn_\|\<g_static_\|\<g_str\|\<g_thread_pool_\|\<g_time_val_add\|\<g_timeout_\|\<g_type_\|\<g_unlink\|\<g_uri_\|\<g_utf8_\|\<g_value_\|\<g_enum_\|\<g_flags_\|\<g_checksum'
SKIP='\<g_access\|\<g_array_\|\<g_ascii\|\<g_list_\|\<g_assertion_message\|\<g_warn_message\|\<g_atomic_int\|\<g_build_filename\|\<g_byte_array\|\<g_child_watch\|\<g_convert\|\<g_dir_\|\<g_error_\|\<g_file_error_quark\|\<g_file_get_contents\|\<g_file_set_contents\|\<g_file_test\|\<g_filename_\|\<g_find_program_in_path\|\<g_free\|\<g_get_\|\<g_getenv\|\<g_hash_table_\|\<g_idle_\|\<g_intern_static_string\|\<g_io_channel_\|\<g_key_file_\|\<g_listenv\|\<g_locale_to_utf8\|\<g_log\|\<g_main_context_wakeup\|\<g_malloc\|\<g_markup_\|\<g_mkdir_\|\<g_mkstemp\|\<g_module_\|\<g_object_\|\<g_once_\|\<g_param_spec_\|\<g_path_\|\<g_printerr\|\<g_propagate_error\|\<g_ptr_array_\|\<g_qsort_\|\<g_quark_\|\<g_queue_\|\<g_realloc\|\<g_return_if_fail\|\<g_set_error\|\<g_shell_\|\<g_signal_\|\<g_slice_\|\<g_slist_\|\<g_snprintf\|\<g_source_\|\<g_spawn_\|\<g_static_\|\<g_str\|\<g_thread_pool_\|\<g_time_val_add\|\<g_timeout_\|\<g_type_\|\<g_unlink\|\<g_uri_\|\<g_utf8_\|\<g_value_\|\<g_enum_\|\<g_flags_\|\<g_checksum'
for so in .libs/lib*.so; do
echo Checking $so for local PLT entries

View File

@ -220,7 +220,7 @@ bookmark_app_info_new (const gchar *name)
{
BookmarkAppInfo *retval;
g_assert (name != NULL);
g_warn_if_fail (name != NULL);
retval = g_slice_new (BookmarkAppInfo);
@ -250,7 +250,7 @@ bookmark_app_info_dump (BookmarkAppInfo *app_info)
gchar *retval;
gchar *name, *exec;
g_assert (app_info != NULL);
g_warn_if_fail (app_info != NULL);
if (app_info->count == 0)
return NULL;
@ -406,7 +406,7 @@ bookmark_metadata_dump (BookmarkMetadata *metadata)
BookmarkAppInfo *app_info = (BookmarkAppInfo *) l->data;
gchar *app_data;
g_assert (app_info != NULL);
g_warn_if_fail (app_info != NULL);
app_data = bookmark_app_info_dump (app_info);
@ -462,7 +462,7 @@ bookmark_item_new (const gchar *uri)
{
BookmarkItem *item;
g_assert (uri != NULL);
g_warn_if_fail (uri != NULL);
item = g_slice_new (BookmarkItem);
item->uri = g_strdup (uri);
@ -585,7 +585,7 @@ static BookmarkAppInfo *
bookmark_item_lookup_app_info (BookmarkItem *item,
const gchar *app_name)
{
g_assert (item != NULL && app_name != NULL);
g_warn_if_fail (item != NULL && app_name != NULL);
if (!item->metadata)
return NULL;
@ -684,7 +684,7 @@ parse_bookmark_element (GMarkupParseContext *context,
BookmarkItem *item;
GError *add_error;
g_assert ((parse_data != NULL) && (parse_data->state == STATE_BOOKMARK));
g_warn_if_fail ((parse_data != NULL) && (parse_data->state == STATE_BOOKMARK));
i = 0;
uri = added = modified = visited = NULL;
@ -719,7 +719,7 @@ parse_bookmark_element (GMarkupParseContext *context,
return;
}
g_assert (parse_data->current_item == NULL);
g_warn_if_fail (parse_data->current_item == NULL);
item = bookmark_item_new (uri);
@ -761,7 +761,7 @@ parse_application_element (GMarkupParseContext *context,
BookmarkItem *item;
BookmarkAppInfo *ai;
g_assert ((parse_data != NULL) && (parse_data->state == STATE_APPLICATION));
g_warn_if_fail ((parse_data != NULL) && (parse_data->state == STATE_APPLICATION));
i = 0;
name = exec = count = stamp = NULL;
@ -806,7 +806,7 @@ parse_application_element (GMarkupParseContext *context,
return;
}
g_assert (parse_data->current_item != NULL);
g_warn_if_fail (parse_data->current_item != NULL);
item = parse_data->current_item;
ai = bookmark_item_lookup_app_info (item, name);
@ -846,7 +846,7 @@ parse_mime_type_element (GMarkupParseContext *context,
gint i;
BookmarkItem *item;
g_assert ((parse_data != NULL) && (parse_data->state == STATE_MIME));
g_warn_if_fail ((parse_data != NULL) && (parse_data->state == STATE_MIME));
i = 0;
type = NULL;
@ -868,7 +868,7 @@ parse_mime_type_element (GMarkupParseContext *context,
if (!type)
type = "application/octet-stream";
g_assert (parse_data->current_item != NULL);
g_warn_if_fail (parse_data->current_item != NULL);
item = parse_data->current_item;
if (!item->metadata)
@ -890,7 +890,7 @@ parse_icon_element (GMarkupParseContext *context,
gint i;
BookmarkItem *item;
g_assert ((parse_data != NULL) && (parse_data->state == STATE_ICON));
g_warn_if_fail ((parse_data != NULL) && (parse_data->state == STATE_ICON));
i = 0;
href = NULL;
@ -925,7 +925,7 @@ parse_icon_element (GMarkupParseContext *context,
if (!type)
type = "application/octet-stream";
g_assert (parse_data->current_item != NULL);
g_warn_if_fail (parse_data->current_item != NULL);
item = parse_data->current_item;
if (!item->metadata)
@ -956,7 +956,7 @@ map_namespace_to_name (ParseData *parse_data,
const gchar *attr;
gint i;
g_assert (parse_data != NULL);
g_warn_if_fail (parse_data != NULL);
if (!attribute_names || !attribute_names[0])
return;
@ -1002,8 +1002,8 @@ is_element_full (ParseData *parse_data,
const gchar *p, *element_name;
gboolean retval;
g_assert (parse_data != NULL);
g_assert (element_full != NULL);
g_warn_if_fail (parse_data != NULL);
g_warn_if_fail (element_full != NULL);
if (!element)
return FALSE;
@ -1253,7 +1253,7 @@ start_element_raw_cb (GMarkupParseContext *context,
XBEL_METADATA_ELEMENT);
break;
default:
g_assert_not_reached ();
g_warn_if_reached ();
break;
}
}
@ -1343,7 +1343,7 @@ text_raw_cb (GMarkupParseContext *context,
{
GList *groups;
g_assert (parse_data->current_item != NULL);
g_warn_if_fail (parse_data->current_item != NULL);
if (!parse_data->current_item->metadata)
parse_data->current_item->metadata = bookmark_metadata_new ();
@ -1363,7 +1363,7 @@ text_raw_cb (GMarkupParseContext *context,
case STATE_ICON:
break;
default:
g_assert_not_reached ();
g_warn_if_reached ();
break;
}
@ -1390,7 +1390,7 @@ g_bookmark_file_parse (GBookmarkFile *bookmark,
GError *parse_error, *end_error;
gboolean retval;
g_assert (bookmark != NULL);
g_warn_if_fail (bookmark != NULL);
if (!buffer)
return FALSE;
@ -1958,7 +1958,7 @@ static BookmarkItem *
g_bookmark_file_lookup_item (GBookmarkFile *bookmark,
const gchar *uri)
{
g_assert (bookmark != NULL && uri != NULL);
g_warn_if_fail (bookmark != NULL && uri != NULL);
return g_hash_table_lookup (bookmark->items_by_uri, uri);
}
@ -1969,8 +1969,8 @@ g_bookmark_file_add_item (GBookmarkFile *bookmark,
BookmarkItem *item,
GError **error)
{
g_assert (bookmark != NULL);
g_assert (item != NULL);
g_warn_if_fail (bookmark != NULL);
g_warn_if_fail (item != NULL);
/* this should never happen; and if it does, then we are
* screwing up something big time.
@ -2090,7 +2090,7 @@ g_bookmark_file_get_uris (GBookmarkFile *bookmark,
{
BookmarkItem *item = (BookmarkItem *) l->data;
g_assert (item != NULL);
g_warn_if_fail (item != NULL);
uris[i++] = g_strdup (item->uri);
}
@ -2958,7 +2958,7 @@ g_bookmark_file_get_groups (GBookmarkFile *bookmark,
{
gchar *group_name = (gchar *) l->data;
g_assert (group_name != NULL);
g_warn_if_fail (group_name != NULL);
retval[i++] = g_strdup (group_name);
}
@ -3481,8 +3481,8 @@ g_bookmark_file_get_applications (GBookmarkFile *bookmark,
ai = (BookmarkAppInfo *) l->data;
g_assert (ai != NULL);
g_assert (ai->name != NULL);
g_warn_if_fail (ai != NULL);
g_warn_if_fail (ai->name != NULL);
apps[i++] = g_strdup (ai->name);
}

View File

@ -236,7 +236,7 @@ g_key_file_clear (GKeyFile *key_file)
g_key_file_remove_group_node (key_file, group_node);
}
g_assert (key_file->groups == NULL);
g_warn_if_fail (key_file->groups == NULL);
}
@ -778,7 +778,7 @@ g_key_file_parse_comment (GKeyFile *key_file,
if (!(key_file->flags & G_KEY_FILE_KEEP_COMMENTS))
return;
g_assert (key_file->current_group != NULL);
g_warn_if_fail (key_file->current_group != NULL);
pair = g_slice_new (GKeyFileKeyValuePair);
pair->key = NULL;
@ -843,7 +843,7 @@ g_key_file_parse_key_value_pair (GKeyFile *key_file,
key_end = value_start = strchr (line, '=');
g_assert (key_end != NULL);
g_warn_if_fail (key_end != NULL);
key_end--;
value_start++;
@ -855,7 +855,7 @@ g_key_file_parse_key_value_pair (GKeyFile *key_file,
key_len = key_end - line + 2;
g_assert (key_len <= length);
g_warn_if_fail (key_len <= length);
key = g_strndup (line, key_len - 1);
@ -877,7 +877,7 @@ g_key_file_parse_key_value_pair (GKeyFile *key_file,
value = g_strndup (value_start, value_len);
g_assert (key_file->start_group != NULL);
g_warn_if_fail (key_file->start_group != NULL);
if (key_file->current_group
&& key_file->current_group->name
@ -1189,7 +1189,11 @@ g_key_file_get_groups (GKeyFile *key_file,
num_groups = g_list_length (key_file->groups);
g_assert (num_groups > 0);
g_return_val_if_fail (num_groups > 0, NULL);
group_node = g_list_last (key_file->groups);
g_return_val_if_fail (((GKeyFileGroup *) group_node->data)->name == NULL, NULL);
/* Only need num_groups instead of num_groups + 1
* because the first group of the file (last in the
@ -1198,9 +1202,6 @@ g_key_file_get_groups (GKeyFile *key_file,
*/
groups = g_new (gchar *, num_groups);
group_node = g_list_last (key_file->groups);
g_assert (((GKeyFileGroup *) group_node->data)->name == NULL);
i = 0;
for (group_node = group_node->prev;
@ -1211,7 +1212,7 @@ g_key_file_get_groups (GKeyFile *key_file,
group = (GKeyFileGroup *) group_node->data;
g_assert (group->name != NULL);
g_warn_if_fail (group->name != NULL);
groups[i++] = g_strdup (group->name);
}
@ -2586,10 +2587,10 @@ g_key_file_set_top_comment (GKeyFile *key_file,
/* The last group in the list should be the top (comments only)
* group in the file
*/
g_assert (key_file->groups != NULL);
g_warn_if_fail (key_file->groups != NULL);
group_node = g_list_last (key_file->groups);
group = (GKeyFileGroup *) group_node->data;
g_assert (group->name == NULL);
g_warn_if_fail (group->name == NULL);
/* Note all keys must be comments at the top of
* the file, so we can just free it all.
@ -2843,10 +2844,10 @@ g_key_file_get_top_comment (GKeyFile *key_file,
/* The last group in the list should be the top (comments only)
* group in the file
*/
g_assert (key_file->groups != NULL);
g_warn_if_fail (key_file->groups != NULL);
group_node = g_list_last (key_file->groups);
group = (GKeyFileGroup *) group_node->data;
g_assert (group->name == NULL);
g_warn_if_fail (group->name == NULL);
return get_group_comment (key_file, group, error);
}
@ -3046,7 +3047,7 @@ g_key_file_remove_key_value_pair_node (GKeyFile *key_file,
if (pair->key != NULL)
key_file->approximate_size -= strlen (pair->key) + 1;
g_assert (pair->value != NULL);
g_warn_if_fail (pair->value != NULL);
key_file->approximate_size -= strlen (pair->value);
g_key_file_key_value_pair_free (pair);
@ -3116,7 +3117,7 @@ g_key_file_remove_group_node (GKeyFile *key_file,
g_key_file_remove_key_value_pair_node (key_file, group, pair_node);
}
g_assert (group->key_value_pairs == NULL);
g_warn_if_fail (group->key_value_pairs == NULL);
if (group->lookup_map)
{

View File

@ -729,7 +729,10 @@ g_log_set_fatal_mask
g_log_set_handler
g_logv
g_return_if_fail_warning
g_warn_message
#ifndef G_DISABLE_DEPRECATED
g_assert_warning G_GNUC_NORETURN
#endif
g_print G_GNUC_PRINTF(1,2)
g_printerr G_GNUC_PRINTF(1,2)
g_set_printerr_handler

View File

@ -536,6 +536,27 @@ g_return_if_fail_warning (const char *log_domain,
expression);
}
void
g_warn_message (const char *domain,
const char *file,
int line,
const char *func,
const char *warnexpr)
{
char *s, lstr[32];
g_snprintf (lstr, 32, "%d", line);
if (warnexpr)
s = g_strconcat ("(", file, ":", lstr, "):",
func, func[0] ? ":" : "",
" runtime check failed: (", warnexpr, ")", NULL);
else
s = g_strconcat ("(", file, ":", lstr, "):",
func, func[0] ? ":" : "",
" ", "code should not be reached", NULL);
g_log (domain, G_LOG_LEVEL_WARNING, "%s", s);
g_free (s);
}
void
g_assert_warning (const char *log_domain,
const char *file,

View File

@ -112,11 +112,18 @@ G_GNUC_INTERNAL void _g_log_fallback_handler (const gchar *log_domain,
void g_return_if_fail_warning (const char *log_domain,
const char *pretty_function,
const char *expression);
void g_warn_message (const char *domain,
const char *file,
int line,
const char *func,
const char *warnexpr);
#ifndef G_DISABLE_DEPRECATED
void g_assert_warning (const char *log_domain,
const char *file,
const int line,
const char *pretty_function,
const char *expression) G_GNUC_NORETURN;
#endif /* !G_DISABLE_DEPRECATED */
#ifndef G_LOG_DOMAIN
@ -211,59 +218,15 @@ void g_printerr (const gchar *format,
GPrintFunc g_set_printerr_handler (GPrintFunc func);
/* Provide macros for error handling. The "assert" macros will
* exit on failure. The "return" macros will exit the current
* function. Two different definitions are given for the macros
* if G_DISABLE_ASSERT is not defined, in order to support gcc's
* __PRETTY_FUNCTION__ capability.
/* Provide macros for graceful error handling.
* The "return" macros will return from the current function.
* Two different definitions are given for the macros in
* order to support gcc's __PRETTY_FUNCTION__ capability.
*/
#ifdef G_DISABLE_ASSERT
#define g_assert(expr) G_STMT_START{ (void)0; }G_STMT_END
#define g_assert_not_reached() G_STMT_START{ (void)0; }G_STMT_END
#else /* !G_DISABLE_ASSERT */
#ifdef __GNUC__
#define g_assert(expr) G_STMT_START{ \
if G_LIKELY(expr) { } else \
g_assert_warning (G_LOG_DOMAIN, \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); }G_STMT_END
#define g_assert_not_reached() G_STMT_START{ \
g_assert_warning (G_LOG_DOMAIN, \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
NULL); }G_STMT_END
#else /* !__GNUC__ */
#define g_assert(expr) G_STMT_START{ \
if (expr) { } else \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d: assertion failed: (%s)", \
__FILE__, \
__LINE__, \
#expr); }G_STMT_END
#define g_assert_not_reached() G_STMT_START{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d: should not be reached", \
__FILE__, \
__LINE__); }G_STMT_END
#endif /* __GNUC__ */
#endif /* !G_DISABLE_ASSERT */
#define g_warn_if_reached() do { g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } while (0)
#define g_warn_if_fail(expr) do { if G_LIKELY (expr) ; else \
g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, #expr); } while (0)
#ifdef G_DISABLE_CHECKS

View File

@ -1106,9 +1106,11 @@ g_assertion_message (const char *domain,
{
char lstr[32];
char *s;
if (!message)
message = "code should not be reached";
g_snprintf (lstr, 32, "%d", line);
s = g_strconcat (domain ? domain : "", domain && domain[0] ? ":" : "",
file, ":", lstr, ":",
"ERROR:(", file, ":", lstr, "):",
func, func[0] ? ":" : "",
" ", message, NULL);
g_printerr ("**\n** %s\n", s);

View File

@ -48,10 +48,18 @@ typedef struct GTestSuite GTestSuite;
if (__n1 cmp __n2) ; else \
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
#n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'f'); } while (0)
#ifdef G_DISABLE_ASSERT
#define g_assert_not_reached() do { (void) 0; } while (0)
#define g_assert(expr) do { (void) 0; } while (0)
#else /* !G_DISABLE_ASSERT */
#define g_assert_not_reached() do { g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } while (0)
#define g_assert(expr) do { if G_LIKELY (expr) ; else \
g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
#expr); } while (0)
#endif /* !G_DISABLE_ASSERT */
int g_strcmp0 (const char *str1,
const char *str2);
// g_assert(condition) /*...*/
// g_assert_not_reached() /*...*/
/* report performance results */
void g_test_minimized_result (double minimized_quantity,