Date: Tue, 23 Mar 2010 12:22:47 +0100 From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no> To: Dmitry Krivenok <krivenok.dmitry@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: Strange behavior of kernel module (output terminated) Message-ID: <86ocifcmew.fsf@ds4.des.no> In-Reply-To: <da48cf211003230218n56794f0bs27eef860efc0da3e@mail.gmail.com> (Dmitry Krivenok's message of "Tue, 23 Mar 2010 12:18:24 %2B0300") References: <da48cf211003230218n56794f0bs27eef860efc0da3e@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Dmitry Krivenok <krivenok.dmitry@gmail.com> writes:
> /* The function called at load/unload. */
> static int event_handler(struct module *module, int event, void *arg)
> {
> int e =3D 0; /* Error, 0 for normal return status */
> switch (event)
> {
> case MOD_LOAD:
> uprintf("Hello FreeBSD kernel!\n");
I'm not sure it's such a good idea to use uprintf() here. The event
handler can be called in non-process context.
> int i =3D 0;
> for(i =3D 0; i < 1000; i++)
> {
> uprintf("%3d ", i);
> if(! (i % 10) ) uprintf("\n");
> }
(i % 10) is not a predicate. The test should be if (i % 10 =3D=3D 0).
If you want to work on FreeBSD, I recommend you get used to the
FreeBSD coding style; see 'man 9 style'.
> As you can see the loop was terminated after i=3D=3D466. I tried to
> load/unload the module many times but the last printed number was
> always 466.
You filled up a buffer somewhere...
DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86ocifcmew.fsf>
