forked from AuroraMiddleware/gtk
build: Add -Wnull-dereference
Sprinkle various g_assert() around the code where gcc cannot figure out on its own that a variable is not NULL and too much refactoring would be needed to make it do that. Also fix usage of g_assert_nonnull(x) to use g_assert(x) because the first is not marked as G_GNUC_NORETURN because of course GTester supports not aborting on aborts.
This commit is contained in:
parent
4be4799316
commit
e356d59a92
@ -4118,6 +4118,7 @@ tablet_pad_handle_button (void *data,
|
||||
wp_tablet_pad, button, state));
|
||||
|
||||
group = tablet_pad_lookup_button_group (pad, button);
|
||||
g_assert (group != NULL);
|
||||
n_group = g_list_index (pad->mode_groups, group);
|
||||
|
||||
event = gdk_event_pad_button_new (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED
|
||||
|
@ -1505,15 +1505,19 @@ update_xft_settings (GdkDisplay *display)
|
||||
TranslationEntry *entry;
|
||||
|
||||
entry = find_translation_entry_by_schema ("org.gnome.settings-daemon.plugins.xsettings", "antialiasing");
|
||||
g_assert (entry);
|
||||
antialiasing = entry->fallback.i;
|
||||
|
||||
entry = find_translation_entry_by_schema ("org.gnome.settings-daemon.plugins.xsettings", "hinting");
|
||||
g_assert (entry);
|
||||
hinting = entry->fallback.i;
|
||||
|
||||
entry = find_translation_entry_by_schema ("org.gnome.settings-daemon.plugins.xsettings", "rgba-order");
|
||||
g_assert (entry);
|
||||
order = entry->fallback.i;
|
||||
|
||||
entry = find_translation_entry_by_schema ("org.gnome.desktop.interface", "text-scaling-factor");
|
||||
g_assert (entry);
|
||||
dpi = 96.0 * entry->fallback.i / 65536.0 * 1024; /* Xft wants 1/1024th of an inch */
|
||||
}
|
||||
else
|
||||
|
@ -2673,7 +2673,11 @@ gdk_x11_display_error_trap_pop_internal (GdkDisplay *display,
|
||||
break;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (trap != NULL, Success);
|
||||
if (trap == NULL)
|
||||
{
|
||||
g_critical ("gdk_x11_display_error_trap_pop() called without gdk_x11_display_error_trap_push()");
|
||||
return Success;
|
||||
}
|
||||
g_assert (trap->end_sequence == 0);
|
||||
|
||||
/* May need to sync to fill in trap->error_code if we care about
|
||||
|
@ -129,7 +129,7 @@ _gdk_x11_surface_get_toplevel (GdkSurface *surface)
|
||||
{
|
||||
GdkX11Surface *impl;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
|
||||
g_assert (GDK_IS_SURFACE (surface));
|
||||
|
||||
impl = GDK_X11_SURFACE (surface);
|
||||
|
||||
|
@ -658,7 +658,7 @@ gsk_gl_driver_mark_texture_permanent (GskGLDriver *self,
|
||||
{
|
||||
Texture *t = gsk_gl_driver_get_texture (self, texture_id);
|
||||
|
||||
g_assert_nonnull (t);
|
||||
g_assert (t != NULL);
|
||||
|
||||
t->permanent = TRUE;
|
||||
}
|
||||
|
@ -332,6 +332,7 @@ internal_change_entry (const gchar *accel_path,
|
||||
{
|
||||
gtk_accel_map_add_entry (accel_path, 0, 0);
|
||||
entry = accel_path_lookup (accel_path);
|
||||
g_assert (entry);
|
||||
entry->accel_key = accel_key;
|
||||
entry->accel_mods = accel_mods;
|
||||
entry->changed = TRUE;
|
||||
|
@ -382,8 +382,7 @@ state_pop (ParserData *data)
|
||||
{
|
||||
gpointer old = NULL;
|
||||
|
||||
if (!data->stack)
|
||||
return NULL;
|
||||
g_assert (data->stack);
|
||||
|
||||
old = data->stack->data;
|
||||
data->stack = g_slist_delete_link (data->stack, data->stack);
|
||||
|
@ -4082,6 +4082,7 @@ gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self,
|
||||
/* We can't render emblemed icons atm, but at least render the base */
|
||||
while (G_IS_EMBLEMED_ICON (gicon))
|
||||
gicon = g_emblemed_icon_get_icon (G_EMBLEMED_ICON (gicon));
|
||||
g_assert (gicon); /* shut up gcc -Wnull-dereference */
|
||||
|
||||
if (GDK_IS_PIXBUF (gicon))
|
||||
{
|
||||
|
@ -234,6 +234,7 @@ gtk_menu_tracker_item_visibility_changed (GtkMenuTrackerItem *item,
|
||||
|
||||
/* remember: the item is our model */
|
||||
section = gtk_menu_tracker_section_find_model (tracker->toplevel, item, &offset);
|
||||
g_assert (section);
|
||||
|
||||
was_visible = section->items != NULL;
|
||||
|
||||
@ -424,6 +425,7 @@ gtk_menu_tracker_model_changed (GMenuModel *model,
|
||||
* position of that section within the overall menu.
|
||||
*/
|
||||
section = gtk_menu_tracker_section_find_model (tracker->toplevel, model, &offset);
|
||||
g_assert (section);
|
||||
|
||||
/* Next, seek through that section to the change point. This gives us
|
||||
* the correct GSList** to make the change to and also finds the final
|
||||
|
@ -690,6 +690,7 @@ gtk_path_bar_scroll_down (GtkPathBar *path_bar)
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_assert (down_button);
|
||||
|
||||
gtk_widget_get_allocation (GTK_WIDGET (path_bar), &allocation);
|
||||
gtk_widget_get_allocation (BUTTON_DATA (down_button->data)->button, &button_allocation);
|
||||
|
@ -441,6 +441,7 @@ gtk_rb_tree_remove_node_fixup (GtkRbTree *tree,
|
||||
gtk_rb_node_rotate_left (tree, p);
|
||||
w = p->right;
|
||||
}
|
||||
g_assert (w);
|
||||
if (is_black (w->left) && is_black (w->right))
|
||||
{
|
||||
set_red (w);
|
||||
@ -472,6 +473,7 @@ gtk_rb_tree_remove_node_fixup (GtkRbTree *tree,
|
||||
gtk_rb_node_rotate_right (tree, p);
|
||||
w = p->left;
|
||||
}
|
||||
g_assert (w);
|
||||
if (is_black (w->right) && is_black (w->left))
|
||||
{
|
||||
set_red (w);
|
||||
|
@ -693,6 +693,7 @@ gtk_shortcuts_section_reflow_groups (GtkShortcutsSection *self)
|
||||
n += height;
|
||||
}
|
||||
|
||||
g_assert (g);
|
||||
for (g = g->next; g; g = g->next)
|
||||
{
|
||||
GtkShortcutsGroup *group = g->data;
|
||||
|
@ -2849,8 +2849,9 @@ _gtk_text_btree_set_mark (GtkTextBTree *tree,
|
||||
seg = real_set_mark (tree, existing_mark,
|
||||
name, left_gravity, iter, should_exist,
|
||||
TRUE);
|
||||
g_assert (seg);
|
||||
|
||||
return seg ? seg->body.mark.obj : NULL;
|
||||
return seg->body.mark.obj;
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -3126,7 +3127,7 @@ _gtk_text_btree_last_could_contain_tag (GtkTextBTree *tree,
|
||||
{
|
||||
info = gtk_text_btree_get_existing_tag_info (tree, tag);
|
||||
|
||||
if (info->tag_root == NULL)
|
||||
if (info == NULL || info->tag_root == NULL)
|
||||
return NULL;
|
||||
|
||||
node = info->tag_root;
|
||||
@ -3135,7 +3136,6 @@ _gtk_text_btree_last_could_contain_tag (GtkTextBTree *tree,
|
||||
|
||||
while (node->level > 0)
|
||||
{
|
||||
g_assert (node != NULL); /* Failure probably means bad tag summaries. */
|
||||
last_node = NULL;
|
||||
node = node->children.node;
|
||||
while (node != NULL)
|
||||
@ -3146,6 +3146,7 @@ _gtk_text_btree_last_could_contain_tag (GtkTextBTree *tree,
|
||||
}
|
||||
|
||||
node = last_node;
|
||||
g_assert (node != NULL); /* Failure probably means bad tag summaries. */
|
||||
}
|
||||
|
||||
g_assert (node != NULL); /* The tag summaries said some node had
|
||||
@ -3450,6 +3451,7 @@ ensure_end_iter_segment (GtkTextBTree *tree)
|
||||
last_with_chars = seg;
|
||||
seg = seg->next;
|
||||
}
|
||||
g_assert (last_with_chars);
|
||||
|
||||
tree->end_iter_segment = last_with_chars;
|
||||
|
||||
@ -4455,10 +4457,6 @@ _gtk_text_line_next_could_contain_tag (GtkTextLine *line,
|
||||
|
||||
while (node->level > 0)
|
||||
{
|
||||
g_assert (node != NULL); /* If this fails, it likely means an
|
||||
incorrect tag summary led us on a
|
||||
wild goose chase down this branch of
|
||||
the tree. */
|
||||
node = node->children.node;
|
||||
while (node != NULL)
|
||||
{
|
||||
@ -4466,6 +4464,10 @@ _gtk_text_line_next_could_contain_tag (GtkTextLine *line,
|
||||
break;
|
||||
node = node->next;
|
||||
}
|
||||
g_assert (node != NULL); /* If this fails, it likely means an
|
||||
incorrect tag summary led us on a
|
||||
wild goose chase down this branch of
|
||||
the tree. */
|
||||
}
|
||||
|
||||
g_assert (node != NULL);
|
||||
|
@ -209,6 +209,8 @@ gtk_text_iter_make_real (const GtkTextIter *_iter)
|
||||
GtkTextRealIter *iter;
|
||||
|
||||
iter = gtk_text_iter_make_surreal (_iter);
|
||||
if (iter == NULL)
|
||||
return NULL;
|
||||
|
||||
if (iter->segments_changed_stamp !=
|
||||
_gtk_text_btree_get_segments_changed_stamp (iter->tree))
|
||||
@ -242,8 +244,8 @@ iter_init_common (GtkTextIter *_iter,
|
||||
{
|
||||
GtkTextRealIter *iter = (GtkTextRealIter*)_iter;
|
||||
|
||||
g_return_val_if_fail (iter != NULL, NULL);
|
||||
g_return_val_if_fail (tree != NULL, NULL);
|
||||
g_assert (iter != NULL);
|
||||
g_assert (tree != NULL);
|
||||
|
||||
memset (iter, 0, sizeof (GtkTextRealIter));
|
||||
|
||||
|
@ -3002,6 +3002,7 @@ gtk_tree_model_filter_get_iter_full (GtkTreeModel *model,
|
||||
}
|
||||
|
||||
elt = GET_ELT (siter);
|
||||
g_assert (elt);
|
||||
|
||||
if (!elt->children)
|
||||
gtk_tree_model_filter_build_level (filter, level, elt, FALSE);
|
||||
@ -3072,6 +3073,7 @@ gtk_tree_model_filter_get_iter (GtkTreeModel *model,
|
||||
}
|
||||
|
||||
elt = GET_ELT (siter);
|
||||
g_assert (elt);
|
||||
if (!elt->children)
|
||||
gtk_tree_model_filter_build_level (filter, level, elt, FALSE);
|
||||
level = elt->children;
|
||||
@ -4192,6 +4194,7 @@ gtk_tree_model_filter_convert_path_to_child_path (GtkTreeModelFilter *filter,
|
||||
}
|
||||
|
||||
elt = GET_ELT (siter);
|
||||
g_assert (elt);
|
||||
if (elt->children == NULL)
|
||||
gtk_tree_model_filter_build_level (filter, level, elt, FALSE);
|
||||
|
||||
|
@ -1285,6 +1285,7 @@ gtk_tree_model_sort_get_iter (GtkTreeModel *tree_model,
|
||||
}
|
||||
|
||||
elt = GET_ELT (siter);
|
||||
g_assert (elt);
|
||||
if (elt->children == NULL)
|
||||
gtk_tree_model_sort_build_level (tree_model_sort, level, elt);
|
||||
|
||||
@ -2395,6 +2396,7 @@ gtk_tree_model_sort_convert_path_to_child_path (GtkTreeModelSort *tree_model_sor
|
||||
}
|
||||
|
||||
elt = GET_ELT (siter);
|
||||
g_assert (elt);
|
||||
if (elt->children == NULL)
|
||||
gtk_tree_model_sort_build_level (tree_model_sort, level, elt);
|
||||
|
||||
|
@ -269,6 +269,7 @@ gtk_tree_rbtree_remove_node_fixup (GtkTreeRBTree *tree,
|
||||
gtk_tree_rbnode_rotate_left (tree, parent);
|
||||
w = parent->right;
|
||||
}
|
||||
g_assert (w);
|
||||
if (GTK_TREE_RBNODE_GET_COLOR (w->left) == GTK_TREE_RBNODE_BLACK && GTK_TREE_RBNODE_GET_COLOR (w->right) == GTK_TREE_RBNODE_BLACK)
|
||||
{
|
||||
GTK_TREE_RBNODE_SET_COLOR (w, GTK_TREE_RBNODE_RED);
|
||||
@ -300,6 +301,7 @@ gtk_tree_rbtree_remove_node_fixup (GtkTreeRBTree *tree,
|
||||
gtk_tree_rbnode_rotate_right (tree, parent);
|
||||
w = parent->left;
|
||||
}
|
||||
g_assert (w);
|
||||
if (GTK_TREE_RBNODE_GET_COLOR (w->right) == GTK_TREE_RBNODE_BLACK && GTK_TREE_RBNODE_GET_COLOR (w->left) == GTK_TREE_RBNODE_BLACK)
|
||||
{
|
||||
GTK_TREE_RBNODE_SET_COLOR (w, GTK_TREE_RBNODE_RED);
|
||||
@ -1595,6 +1597,8 @@ gtk_tree_rbtree_test_dirty (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
gint expected_dirtyness)
|
||||
{
|
||||
g_assert (node);
|
||||
|
||||
if (expected_dirtyness)
|
||||
{
|
||||
g_assert (GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_COLUMN_INVALID) ||
|
||||
|
@ -251,6 +251,7 @@ elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
|
||||
'-Wmissing-include-dirs',
|
||||
'-Wmissing-noreturn',
|
||||
'-Wnested-externs',
|
||||
'-Wnull-dereference',
|
||||
'-Wold-style-definition',
|
||||
'-Wpointer-arith',
|
||||
'-Wshadow',
|
||||
|
Loading…
Reference in New Issue
Block a user