GNOME Bugzilla – Bug 144042
[PATCH] gdk-pixbuf/io-ani.c: constness
Last modified: 2013-12-19 04:02:35 UTC
The three tables in the MODULE_ENTRY function look like they should be const.
Ditto io-bmp.c Ditto io-gif.c Ditto io-ico.c Ditto io-jpeg.c Ditto io-pcx.c Ditto io-png.c Ditto io-pnm.c Ditto io-ras.c Ditto io-tga.c Ditto io-tiff.c Ditto io-wbmp.c Ditto io-xbm.c Ditto io-xpm.c
Created attachment 108191 [details] [review] Trivial patch to constify data Constifying the data causes few warnings, because the struct members that will point to this data are not const. For example: io-gif.c:1690: warning: assignment discards qualifiers from pointer target type io-gif.c:1692: warning: assignment from incompatible pointer type io-gif.c:1693: warning: assignment from incompatible pointer type Would a simple cast to non-const type be enough ? Or is there a trickier way to Do The Right Thing (TM) ?
It seems to me that declaring the struct-members as const too is the right thing. If that doesn't work, then the next best option is to add explicit casts. The warnings has to be quelched, somehow.
Are you sure I'm allowed to switch GdkPixbufFormat members to const ? May it cause some ABI/API breakage, as it's a public structure?
Created attachment 122380 [details] [review] Corrects the warnings with casts Making the struct members const was breaking too much stuff in gdk-pixbuf-io.c, so I used some casts to make the warnings disapear.
constifying (especially the strings arrays) would move the text into the read-only data section of the shared object. looks a good idea to me. in theory, the GdkPixbufFormat should be constified, but that would be a possible source breakage.
Review of attachment 122380 [details] [review]: I think this should go in (note: gdk-pixbuf was moved out of gtk+)