From nobody@FreeBSD.org  Sat Apr  2 18:43:35 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A0531106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  2 Apr 2011 18:43:35 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 91ACA8FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  2 Apr 2011 18:43:35 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p32IhZTI088959
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 2 Apr 2011 18:43:35 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p32IhZQp088953;
	Sat, 2 Apr 2011 18:43:35 GMT
	(envelope-from nobody)
Message-Id: <201104021843.p32IhZQp088953@red.freebsd.org>
Date: Sat, 2 Apr 2011 18:43:35 GMT
From: Rozhuk Ivan <rozhuk.im@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: hints read: resource_longlong_value and resource_uintmax_value
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         156130
>Category:       kern
>Synopsis:       [kernel] [patch] hints read: resource_longlong_value and resource_uintmax_value
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Sat Apr 02 18:50:10 UTC 2011
>Closed-Date:    
>Last-Modified:  Sat Apr 09 19:57:13 UTC 2011
>Originator:     Rozhuk Ivan
>Release:        8.2-STABLE
>Organization:
>Environment:
FreeBSD firewall 8.2-STABLE FreeBSD 8.2-STABLE #4: Sun Mar 13 02:12:50 IRKT 2011     root@firewall:/usr/obj/usr/src/sys/RIMx64  amd64

>Description:
just additional functions for hints:
resource_longlong_value
resource_uintmax_value
>How-To-Repeat:
try to read from "hints" 64 bit values in your driver/module
>Fix:
apply patch :)

Patch attached with submission follows:

--- /usr/src/sys/kern/subr_hints_orig.c	2009-08-03 17:13:06.000000000 +0900
+++ /usr/src/sys/kern/subr_hints.c	2011-04-03 02:28:25.000000000 +0900
@@ -273,6 +273,53 @@ resource_long_value(const char *name, in
 	return 0;
 }
 
+
+int
+resource_longlong_value(const char *name, int unit, const char *resname, unsigned long long *result)
+{
+	int error;
+	const char *str;
+	char *op;
+	unsigned long val;
+	int line;
+
+	line = 0;
+	error = resource_find(&line, NULL, name, &unit, resname, NULL,
+	    NULL, NULL, NULL, NULL, NULL, &str);
+	if (error)
+		return error;
+	if (*str == '\0') 
+		return EFTYPE;
+	val = strtoull(str, &op, 0);
+	if (*op != '\0') 
+		return EFTYPE;
+	*result = val;
+	return 0;
+}
+
+int
+resource_uintmax_value(const char *name, int unit, const char *resname, uintmax_t *result)
+{
+	int error;
+	const char *str;
+	char *op;
+	unsigned long val;
+	int line;
+
+	line = 0;
+	error = resource_find(&line, NULL, name, &unit, resname, NULL,
+	    NULL, NULL, NULL, NULL, NULL, &str);
+	if (error)
+		return error;
+	if (*str == '\0') 
+		return EFTYPE;
+	val = strtoumax(str, &op, 0);
+	if (*op != '\0') 
+		return EFTYPE;
+	*result = val;
+	return 0;
+}
+
 int
 resource_string_value(const char *name, int unit, const char *resname,
     const char **result)


>Release-Note:
>Audit-Trail:

From: "Rozhuk Ivan" <Rozhuk_I@mail.ru>
To: <bug-followup@FreeBSD.org>
Cc:  
Subject: Re: kern/156130: hints read: resource_longlong_value and resource_uintmax_value
Date: Sun, 3 Apr 2011 23:08:54 +0900

 This is a multi-part message in MIME format.
 
 ------=_NextPart_000_006B_01CBF254.1B3F50A0
 Content-Type: text/plain;
 	charset="windows-1251"
 Content-Transfer-Encoding: quoted-printable
 
 Original patch has errors, this final version.
 
 =A0
 --
 Rozhuk Ivan
 =A0=20
 
 
 
 ------=_NextPart_000_006B_01CBF254.1B3F50A0
 Content-Type: text/plain;
 	name="subr_hints.txt"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment;
 	filename="subr_hints.txt"
 
 --- /usr/src/sys/kern/subr_hints_orig.c 2009-08-03 17:13:06.000000000 =
 +0900
 +++ /usr/src/sys/kern/subr_hints.c      2011-04-03 18:10:57.000000000 =
 +0900
 @@ -273,6 +273,30 @@
         return 0;
  }
 =20
 +
 +int
 +resource_quad_t_value(const char *name, int unit, const char *resname, =
 quad_t *result)
 +{
 +       int error;
 +       const char *str;
 +       char *op;
 +       quad_t val;
 +       int line;
 +
 +       line =3D 0;
 +       error =3D resource_find(&line, NULL, name, &unit, resname, NULL,
 +           NULL, NULL, NULL, NULL, NULL, &str);
 +       if (error)
 +               return error;
 +       if (*str =3D=3D '\0')=20
 +               return EFTYPE;
 +       val =3D strtoq(str, &op, 0);
 +       if (*op !=3D '\0')=20
 +               return EFTYPE;
 +       *result =3D val;
 +       return 0;
 +}
 +
  int
  resource_string_value(const char *name, int unit, const char *resname,
      const char **result)
 
 
 --- /usr/src/sys/sys/bus.h_orig 2011-02-09 06:08:00.000000000 +0800
 +++ /usr/src/sys/sys/bus.h      2011-04-03 18:13:07.000000000 +0900
 @@ -470,6 +470,8 @@
                            int *result);
  int    resource_long_value(const char *name, int unit, const char =
 *resname,
                             long *result);
 +int    resource_quad_t_value(const char *name, int unit, const char =
 *resname,
 +                               quad_t *result);
  int    resource_string_value(const char *name, int unit, const char =
 *resname,
                               const char **result);
  int    resource_disabled(const char *name, int unit);
 
 
 ------=_NextPart_000_006B_01CBF254.1B3F50A0--
 
>Unformatted:
