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: > I am following FreeBSD drivers: A guide for the intrepid by Joseph= Kong to > learn to write FreeBSD device drivers. >=20 > =20 >=20 > I got to the sysctl subchapter where is more or less this code >=20 > =20 >=20 > #include <sys/param.h> >=20 > #include <sys/sysctl.h> >=20 > =20 >=20 > .... >=20 > =20 >=20 > static int sysctl_set_buffer_size(SYSCTL_HANDLER_ARGS) { >=20 > int error =3D 0; >=20 > int size =3D echo_message->buffer_size; >=20 > error =3D sysctl_handle_int(oidp, &size, 0, req); >=20 > if (error || !req->newptr || echo_message->buffer_size =3D= =3D size) return > (error); >=20 > if (size >=3D 128 && size <=3D 512) { >=20 > echo_message->buffer =3D realloc(echo_message->buffer, size,= M_ECHO, M_WAITOK); >=20 > echo_message->buffer_size =3D size; >=20 > if (echo_message->length >=3D size) { >=20 > echo_message->length =3D size - 1; >=20 > echo_message->buffer[size - 1] =3D '\0'; >=20 > } >=20 > } else { >=20 > error =3D EINVAL; >=20 > } >=20 > return (error); >=20 > } >=20 > =20 >=20 > but when compiling I got the error: >=20 > =20 >=20 > error: call to undeclared function 'sysctl_int_handle'; ISO C99 an= d later do > not support implicit function declarations [-Werror,-Wimplicit-fun= ction- > declaration] >=20 > 167 | error =3D sysctl_int_handle(oidp, &size, 0, req); >=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>