Date: Sat, 2 Apr 2011 18:43:35 GMT From: Rozhuk Ivan <rozhuk.im@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/156130: hints read: resource_longlong_value and resource_uintmax_value Message-ID: <201104021843.p32IhZQp088953@red.freebsd.org> Resent-Message-ID: <201104021850.p32IoAdl064682@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 156130 >Category: kern >Synopsis: 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: >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: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201104021843.p32IhZQp088953>