Subject: Re: CVS commit: src/sys
To: Andrew Brown <atatat@atatdot.net>
From: Jason Thorpe <thorpej@shagadelic.org>
List: source-changes
Date: 06/10/2005 11:15:41
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