[PATCH 00/37] Warning fixes (post 1.15 proposed changes)
Keith Packard
keithp at keithp.com
Wed Nov 20 13:08:13 PST 2013
Adam Jackson <ajax at nwnk.net> writes:
> I'm not totally happy with this. Casting away const on the argument to
> free() potentially hides bugs, because the point is you _shouldn't_ be
> able to free() things in .rodata, ie, actually constant values.
Agreed. The issue is that different parts of the X server use either
const values or allocated values and store those in the same structure
members. Each part "knows" what it has done; const values are "never"
freed, while allocated values "always" are.
So, we have three choices:
1) Stick casts where constant strings are assigned to non-const
members
2) Copy constant strings, and then figure out where to free them
reliably
3) Stick casts where non-constant strings are freed from const
members.
2) is the 'most correct', and would eliminate all casts, but is also
both the least efficient (meh, not a huge deal, but still), *and* the
most bug-prone within the existing code as it requires that we go and
find a suitable place to free the newly allocated storage.
Which is why I really only considered 1) and 3), and picked 3) because
it required fewer casts, and then only in calls to 'free', which might
make it slightly easier to audit.
--
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20131120/7f134dae/attachment-0001.pgp>
More information about the xorg-devel
mailing list