From owner-freebsd-arch@FreeBSD.ORG Fri Jan 4 01:59:45 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 06B0216A418 for ; Fri, 4 Jan 2008 01:59:45 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outF.internet-mail-service.net (outF.internet-mail-service.net [216.240.47.229]) by mx1.freebsd.org (Postfix) with ESMTP id E590E13C447 for ; Fri, 4 Jan 2008 01:59:44 +0000 (UTC) (envelope-from julian@elischer.org) Received: from mx0.idiom.com (HELO idiom.com) (216.240.32.160) by out.internet-mail-service.net (qpsmtpd/0.40) with ESMTP; Thu, 03 Jan 2008 17:59:43 -0800 Received: from julian-mac.elischer.org (localhost [127.0.0.1]) by idiom.com (Postfix) with ESMTP id 64276126E01 for ; Thu, 3 Jan 2008 17:59:43 -0800 (PST) Message-ID: <477D931D.4000303@elischer.org> Date: Thu, 03 Jan 2008 17:59:57 -0800 From: Julian Elischer User-Agent: Thunderbird 2.0.0.9 (Macintosh/20071031) MIME-Version: 1.0 To: arch@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: RFC: sysctl additional functions/macros X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jan 2008 01:59:45 -0000 I would like to extend the current SYSCTL_INT() with SYSCTL_INT_CLAMPED() or similar, where you also supply a maximum acceptable value. (and maybe a clue as to what to say if it is a bad value). so many users of SYSCTL_INT don't check for bad values because it's so much harder (you need to supply your own handler), and so many simple handlers exist fo rthe people that DO check that it seems to me that we should provide a pre-canned way to do this.... we are limited to using the existing structure, but as we have no existing callers we can redefine one element.... I would suggest: I'd like to test for a minimum too but I think I can only squeeze one field out of the existing struct sysctl_oid. SYSCTL_INT_CLAMPED(parent, nbr, name, access, ptr, max, descr) ^^^^ anyone think it's a bad idea? After all the macros are evaluated, (etc.) it would call: ( off the top of my head ) int sysctl_handle_int_max(SYSCTL_HANDLER_ARGS) { int error = 0; error = SYSCTL_OUT(req, arg1, sizeof(int)); if (error || !req->newptr) return (error); if (*(int *)arg1 > (int)arg2) error = EDOOFUS; else error = SYSCTL_IN(req, arg1, sizeof(int)); return (error); }