Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys




On Jun 9, 2005, at 6:06 AM, Andrew Brown wrote:

the nodes are const because only the core sysctl code should ever be
modifying it, not any of the helpers.  the "enforecement" of const by
the compiler provides a certain degree of protection from this.

I am really uncomfortable about abusing const in this way.

sysctl_lookup's argument is likewise non-const for a reason. So why is it ever correct to pass an __UNCONST'd const sysctlnode to sysctl_lookup?


sysctl_lookup may modify the contents of a sysctlnode, so it's clearly
not const.

So what happens if you pass in a sysctlnode that is actually contained in a read-only portion of memory by virtue of being declared const? BOOM!

It seems to me that the ONLY correct thing to do here is remove the const from the acutally-not-const sysctlnode argument.

-- thorpej




Home | Main Index | Thread Index | Old Index