+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
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);
}
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;
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);
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);
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);
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;
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;
{
GSList *l;
- g_assert (cancellable != NULL);
+ g_return_if_fail (cancellable != NULL);
l = g_static_private_get (¤t_cancellable);
l = g_slist_prepend (l, cancellable);
l = g_static_private_get (¤t_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 (¤t_cancellable, l, NULL);
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;
}
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;
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;
}
*out = '\0';
- g_assert (out - result <= strlen (escaped_string));
+ g_warn_if_fail (out - result <= strlen (escaped_string));
return result;
}
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)
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)
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)
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)
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)
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)
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)
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);
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);
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);
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);
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;
}
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;
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)
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)
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);
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;
}
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;
}
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);
{
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;
}
}
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;
}
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);
}
{
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;
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;
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;
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);
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;
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;
}
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;
}
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;
}
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;
GAsyncReadyCallback callback,
gpointer data)
{
- g_assert_not_reached ();
+ g_warn_if_reached ();
/* TODO: Not implemented */
}
GAsyncResult *result,
GError **error)
{
- g_assert_not_reached ();
+ g_warn_if_reached ();
/* TODO: Not implemented */
}
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;
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);
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
{
BookmarkAppInfo *retval;
- g_assert (name != NULL);
+ g_warn_if_fail (name != NULL);
retval = g_slice_new (BookmarkAppInfo);
gchar *retval;
gchar *name, *exec;
- g_assert (app_info != NULL);
+ g_warn_if_fail (app_info != NULL);
if (app_info->count == 0)
return NULL;
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);
{
BookmarkItem *item;
- g_assert (uri != NULL);
+ g_warn_if_fail (uri != NULL);
item = g_slice_new (BookmarkItem);
item->uri = g_strdup (uri);
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;
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;
return;
}
- g_assert (parse_data->current_item == NULL);
+ g_warn_if_fail (parse_data->current_item == NULL);
item = bookmark_item_new (uri);
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;
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);
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;
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)
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;
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)
const gchar *attr;
gint i;
- g_assert (parse_data != NULL);
+ g_warn_if_fail (parse_data != NULL);
if (!attribute_names || !attribute_names[0])
return;
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;
XBEL_METADATA_ELEMENT);
break;
default:
- g_assert_not_reached ();
+ g_warn_if_reached ();
break;
}
}
{
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 ();
case STATE_ICON:
break;
default:
- g_assert_not_reached ();
+ g_warn_if_reached ();
break;
}
GError *parse_error, *end_error;
gboolean retval;
- g_assert (bookmark != NULL);
+ g_warn_if_fail (bookmark != NULL);
if (!buffer)
return FALSE;
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);
}
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.
{
BookmarkItem *item = (BookmarkItem *) l->data;
- g_assert (item != NULL);
+ g_warn_if_fail (item != NULL);
uris[i++] = g_strdup (item->uri);
}
{
gchar *group_name = (gchar *) l->data;
- g_assert (group_name != NULL);
+ g_warn_if_fail (group_name != NULL);
retval[i++] = g_strdup (group_name);
}
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);
}
g_key_file_remove_group_node (key_file, group_node);
}
- g_assert (key_file->groups == NULL);
+ g_warn_if_fail (key_file->groups == NULL);
}
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;
key_end = value_start = strchr (line, '=');
- g_assert (key_end != NULL);
+ g_warn_if_fail (key_end != NULL);
key_end--;
value_start++;
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);
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
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
*/
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;
group = (GKeyFileGroup *) group_node->data;
- g_assert (group->name != NULL);
+ g_warn_if_fail (group->name != NULL);
groups[i++] = g_strdup (group->name);
}
/* 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.
/* 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);
}
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);
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)
{
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
}
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,
const int line,
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
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
{
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);
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,