From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 23 11:22:49 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4D9D11065672 for ; Tue, 23 Mar 2010 11:22:49 +0000 (UTC) (envelope-from des@des.no) Received: from smtp.des.no (smtp.des.no [194.63.250.102]) by mx1.freebsd.org (Postfix) with ESMTP id 12F408FC20 for ; Tue, 23 Mar 2010 11:22:48 +0000 (UTC) Received: from ds4.des.no (des.no [84.49.246.2]) by smtp.des.no (Postfix) with ESMTP id C73EF1FFC51; Tue, 23 Mar 2010 11:22:47 +0000 (UTC) Received: by ds4.des.no (Postfix, from userid 1001) id A6F57844DA; Tue, 23 Mar 2010 12:22:47 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Dmitry Krivenok References: Date: Tue, 23 Mar 2010 12:22:47 +0100 In-Reply-To: (Dmitry Krivenok's message of "Tue, 23 Mar 2010 12:18:24 +0300") Message-ID: <86ocifcmew.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.95 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org Subject: Re: Strange behavior of kernel module (output terminated) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Mar 2010 11:22:49 -0000 Dmitry Krivenok 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