Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Jul 2024 21:23:39 -0000
From:      Nimbly2329 <hjlftdygaqf@use.startmail.com>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        freebsd-drivers@freebsd.org
Subject:   Re: Asistence with sysctl proc's handle in kernel space
Message-ID:  <172246101946.45.14456548573975496958@startmail.com>
In-Reply-To: <1116740a-8f7c-4adf-afdf-cc12d854ea84@FreeBSD.org>
References:  <172064548937.305907.8627778909077618453@startmail.com> <1116740a-8f7c-4adf-afdf-cc12d854ea84@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--===============3317729185132738339==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

I realized just after sending, still I have not found documentation in =
the
FreeBSD site: =20

>
>     On 7/10/24 17:04, Nimbly2329 wrote:
>     > I am following FreeBSD drivers: A guide for the intrepid by Jos=
eph
> Kong to
>     > learn to write FreeBSD device drivers.
>     >
>     > =20
>     >
>     > I got to the sysctl subchapter where is more or less this code
>     >
>     > =20
>     >
>     > #include <sys/param.h>
>     >
>     > #include <sys/sysctl.h>
>     >
>     > =20
>     >
>     > ....
>     >
>     > =20
>     >
>     > static int sysctl_set_buffer_size(SYSCTL_HANDLER_ARGS) {
>     >
>     > int error =3D 0;
>     >
>     > int size =3D echo_message->buffer_size;
>     >
>     > error =3D sysctl_handle_int(oidp, &size, 0, req);
>     >
>     > if (error || !req->newptr || echo_message->buffer_size =3D=3D s=
ize) return
>     > (error);
>     >
>     > if (size >=3D 128 && size <=3D 512) {
>     >
>     > echo_message->buffer =3D realloc(echo_message->buffer, size, M_=
ECHO,
> M_WAITOK);
>     >
>     > echo_message->buffer_size =3D size;
>     >
>     > if (echo_message->length >=3D size) {
>     >
>     > echo_message->length =3D size - 1;
>     >
>     > echo_message->buffer[size - 1] =3D '\0';
>     >
>     > }
>     >
>     > } else {
>     >
>     > error =3D EINVAL;
>     >
>     > }
>     >
>     > return (error);
>     >
>     > }
>     >
>     > =20
>     >
>     > but when compiling I got the error:
>     >
>     > =20
>     >
>     > error: call to undeclared function 'sysctl_int_handle'; ISO C99=
 and
> later do
>     > not support implicit function declarations [-Werror,-Wimplicit-
> function-
>     > declaration]
>     >
>     > 167 | error =3D sysctl_int_handle(oidp, &size, 0, req);
>     >
> =20
>     Your error here shows 'sysctl_int_handle' instead of 'sysctl_hand=
le_int'
> =20
>     --
>     John Baldwin
> =20
> =20
> =20
> =20
>     >

 =20


--===============3317729185132738339==
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<div xmlns=3D"http://www.w3.org/1999/xhtml"><span class=3D"font" style=
=3D"font-family: arial, helvetica, sans-serif;"><span class=3D"colour" =
style=3D"color:rgb(59, 67, 92)"><span class=3D"size" style=3D"font-size=
: medium"></span></span></span><span class=3D"font" style=3D"font-famil=
y: arial, helvetica, sans-serif;"><span class=3D"colour" style=3D"color=
:rgb(59, 67, 92)"><span class=3D"size" style=3D"font-size: medium">I re=
alized just after sending, still I have not found documentation in the =
FreeBSD site</span><span class=3D"size" style=3D"font-size: medium"></s=
pan></span><span class=3D"colour" style=3D"color:rgb(59, 67, 92)"><span=
 class=3D"size" style=3D"font-size: medium"></span></span><span class=
=3D"colour" style=3D"color:rgb(59, 67, 92)"><span class=3D"size" style=
=3D"font-size: medium"></span></span></span>:<span class=3D"font" style=
=3D"font-family: arial, helvetica, sans-serif;"><span class=3D"colour" =
style=3D"color:rgb(59, 67, 92)"><span class=3D"size" style=3D"font-size=
: medium"></span></span></span><br /></div><blockquote xmlns=3D"http://=
www.w3.org/1999/xhtml"><pre xmlns=3D"http://www.w3.org/1999/xhtml" id=
=3D"body.mime.1">On 7/10/24 17:04, Nimbly2329 wrote:
&gt; I am following FreeBSD drivers: A guide for the intrepid by Joseph=
 Kong to
&gt; learn to write FreeBSD device drivers.
&gt;=20
&gt;   =20
&gt;=20
&gt; I got to the sysctl subchapter where is more or less this code
&gt;=20
&gt;   =20
&gt;=20
&gt; #include &lt;sys/param.h&gt;
&gt;=20
&gt; #include &lt;sys/sysctl.h&gt;
&gt;=20
&gt;   =20
&gt;=20
&gt; ....
&gt;=20
&gt;   =20
&gt;=20
&gt; static int sysctl_set_buffer_size(SYSCTL_HANDLER_ARGS) {
&gt;=20
&gt; int error =3D 0;
&gt;=20
&gt; int size =3D echo_message-&gt;buffer_size;
&gt;=20
&gt; error =3D sysctl_handle_int(oidp, &amp;size, 0, req);
&gt;=20
&gt; if (error || !req-&gt;newptr || echo_message-&gt;buffer_size =3D=
=3D size) return
&gt; (error);
&gt;=20
&gt; if (size &gt;=3D 128 &amp;&amp; size &lt;=3D 512) {
&gt;=20
&gt; echo_message-&gt;buffer =3D realloc(echo_message-&gt;buffer, size,=
 M_ECHO, M_WAITOK);
&gt;=20
&gt; echo_message-&gt;buffer_size =3D size;
&gt;=20
&gt; if (echo_message-&gt;length &gt;=3D size) {
&gt;=20
&gt; echo_message-&gt;length =3D size - 1;
&gt;=20
&gt; echo_message-&gt;buffer[size - 1] =3D '\0';
&gt;=20
&gt; }
&gt;=20
&gt; } else {
&gt;=20
&gt; error =3D EINVAL;
&gt;=20
&gt; }
&gt;=20
&gt; return (error);
&gt;=20
&gt; }
&gt;=20
&gt;   =20
&gt;=20
&gt; but when compiling I got the error:
&gt;=20
&gt;   =20
&gt;=20
&gt; error: call to undeclared function 'sysctl_int_handle'; ISO C99 an=
d later do
&gt; not support implicit function declarations [-Werror,-Wimplicit-fun=
ction-
&gt; declaration]
&gt;=20
&gt; 167 | error =3D sysctl_int_handle(oidp, &amp;size, 0, req);
&gt;=20

Your error here shows 'sysctl_int_handle' instead of 'sysctl_handle_int'

--=20
John Baldwin



<br /></pre></blockquote><p xmlns=3D"http://www.w3.org/1999/xhtml" styl=
e=3D"word-wrap: break-word; overflow-wrap: break-word; margin: 0; color=
: rgb(59, 67, 92); font-family: arial, helvetica; font-size: medium;"><=
br /></p>

--===============3317729185132738339==--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?172246101946.45.14456548573975496958>