After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 75754 - Data tables should be marked "const"
Data tables should be marked "const"
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.0.x
Other All
: Normal trivial
: Small fix
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2002-03-21 14:41 UTC by Morten Welinder
Modified: 2005-03-01 16:48 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10


Attachments
a patch (7.40 KB, patch)
2002-11-05 23:59 UTC, Matthias Clasen
none Details | Review
patch addressing some more things (15.59 KB, patch)
2002-11-22 23:46 UTC, Matthias Clasen
committed Details | Review

Description Morten Welinder 2002-03-21 14:41:39 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.
Comment 1 Morten Welinder 2002-03-21 14:49:48 UTC
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.
Comment 2 Matthias Clasen 2002-04-05 13:33:57 UTC
Move open bugs from milestones 2.0.[012] -- > 2.0.3, since 2.0.2 is already out.
Comment 3 Owen Taylor 2002-05-14 21:54:41 UTC
If someone makes a patch for this, please add the PATCH keyword.
Comment 4 Matthias Clasen 2002-05-17 09:42:55 UTC
I think the picker and dropper of gtkcolorsel should rather be
converted into stock 
icons (so that they become themable like the 
dnd cursors).
Comment 5 Matthias Clasen 2002-11-05 23:59:26 UTC
Created attachment 12083 [details] [review]
a patch
Comment 6 Owen Taylor 2002-11-13 19:43:55 UTC
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.

Comment 7 Matthias Clasen 2002-11-22 23:46:04 UTC
Created attachment 12489 [details] [review]
patch addressing some more things
Comment 8 Owen Taylor 2002-12-10 00:05:54 UTC
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.
Comment 9 Matthias Clasen 2002-12-10 00:28:52 UTC
Committed to HEAD now, keeping open for complete survey.
Comment 10 nos 2004-06-14 13:36:51 UTC
Things like 
static const char *tree_plus[] = {
could probably be 
+static const char *const tree_plus[] = {
as well.
Comment 11 Morten Welinder 2005-03-01 16:46:00 UTC
Looks like mclasen just fixed this.
Comment 12 Matthias Clasen 2005-03-01 16:48:25 UTC
Well, I fixed all that was easily fixable. There are still some more things 
one could look into.