GNOME Bugzilla – Bug 75754
Data tables should be marked "const"
Last modified: 2005-03-01 16:48:25 UTC
In gtk/gtkcolorsel.c, the tables dropper_bits and dropper_mask really ought to be marked const so they can go into the right elf section. "picker" too, I guess.
In gtk/gtkimcontextsimple.c, gtk_compose_ignore and gtk_compose_seqs appear to need it too. In gtk_style, check_black_bits and friends need it. Maybe gtk_default_normal_fg and its friends too.
Move open bugs from milestones 2.0.[012] -- > 2.0.3, since 2.0.2 is already out.
If someone makes a patch for this, please add the PATCH keyword.
I think the picker and dropper of gtkcolorsel should rather be converted into stock icons (so that they become themable like the dnd cursors).
Created attachment 12083 [details] [review] a patch
The patch looks fine, but doesn't catch nearly all the missing const in GTK+. (The one addition I would suggest for what is covered is that theme-bits/decompose-bits.c should be modified to output const) For libgtk alone, I checked through the output of nm | grep '\<d\>' and found: drag_types/drop_types in gtkdnd.c bidi_menu_entries in gtktextutil.c axis_use_strings in gtkinputdialog.c tree_minus.xpm/tree_plus.xpm default_option_indicator_size/spacing in gtkstyle.c gray in gtkstyle.c gray50_bits in gtkstyle.c builtin_items in gtkstock.c clist_target_table in gtkclist.c default_colors in gtkcolorsel.c default_default_border, default_default_outside_border in gtkbutton.c default_props in gtkoptionmenu.c gtk_default_[insensitive/active/etc.]_base/bg/fg in gtkstyle.c line_arrow.xbm/line_wrap.xbm nothing in gtkfilesel.c [two copies] row_targets in gtktreeview.c target_table in gtkentry.c, gtktextview.c I can't think of any more automated way of doing this without fairly extensive compiler support. Not all of these actually get the symbol in readonly date because many of them contain references to other symbols, but they all should be const so the compiler at least has a chance. Another class not counted in the above are all the variables static const (g|)char *foo = "abcd"; that should be: static const (g|)har foo[] = "abcd"; There are 10-15 of these in libgtk.
Created attachment 12489 [details] [review] patch addressing some more things
Why don't you go ahead and commit the patches above, and if there is remaining stuff (a complete survey of GDK/gdk-pixbuf?), move the bug to 2.2.1.
Committed to HEAD now, keeping open for complete survey.
Things like static const char *tree_plus[] = { could probably be +static const char *const tree_plus[] = { as well.
Looks like mclasen just fixed this.
Well, I fixed all that was easily fixable. There are still some more things one could look into.