Date: Sat, 6 Aug 2005 09:04:23 +0200 From: Jeremie Le Hen <jeremie@le-hen.org> To: "Thordur I. Bjornsson" <thib@mi.is> Cc: freebsd-hackers@freebsd.org Subject: Re: Checking sysctl values from within the kernel. Message-ID: <20050806070422.GW45385@obiwan.tataz.chchile.org> In-Reply-To: <20050805160415.44b0b05e.thib@mi.is> References: <20050805005543.5bd947f2.thib@mi.is> <20050805145046.GB78669@dan.emsphone.com> <42F386B2.1010108@samsco.org> <20050805160415.44b0b05e.thib@mi.is>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Thordur, > PS: If you don't mind, what is a "real accessor function" ? This is a function acting as a wrapper for accessing an integer declared as static. This function must of course live in the same file. This may be something like this, there may exist neater interfaces though : static int age; int age_accessor(int *get, int set) { if (get != NULL) *get = age; else if (set < 0 || set > 125) return -1; else age = set; return 0; } If `get' is not NULL, this means the caller wants to retrieve the current age value. Else, this means the caller wants to set the age value to a new one : if the latter is lower than 0 and greater than 125, this is an incredible age and the accessor reports an error. Else it sets the new value. I hope this helped. Regards, -- Jeremie Le Hen < jeremie at le-hen dot org >< ttz at chchile dot org >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050806070422.GW45385>