From owner-freebsd-questions@FreeBSD.ORG Fri May 16 15:32:38 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB3691065673 for ; Fri, 16 May 2008 15:32:38 +0000 (UTC) (envelope-from rvm@CBORD.com) Received: from smssmtp.cbord.com (mx1.cbord.com [24.39.174.11]) by mx1.freebsd.org (Postfix) with ESMTP id A6FBB8FC1C for ; Fri, 16 May 2008 15:32:38 +0000 (UTC) (envelope-from rvm@CBORD.com) X-AuditID: ac1f0165-00000d74000002f4-e3-482da63a11fe Received: from Email.cbord.com ([10.1.1.100]) by smssmtp.cbord.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 16 May 2008 11:20:26 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Fri, 16 May 2008 11:18:29 -0400 Message-ID: In-Reply-To: <20080516161816.M20005@wojtek.tensor.gdynia.pl> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Unable to talk to tap(4) Thread-Index: Aci3X/dru8dYuayoRV2OSwhZw6h5qwAAy12w References: <20080514234101.P2316@wojtek.tensor.gdynia.pl><20080516081903.333b342d@locust> <20080516161816.M20005@wojtek.tensor.gdynia.pl> From: "Bob McConnell" To: X-Brightmail-Tracker: AAAAAA== Subject: RE: Unable to talk to tap(4) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 May 2008 15:32:39 -0000 From: Wojciech Puchar >>>>>> if (buffer =3D NULL) { >> >> if (buffer =3D=3D NULL) { >> > anyway not using malloc is good habit :) but it should work anyway. > try The test after the malloc was the problem. I have been working in a poorly designed scripting language for several months where the single '=3D' is used for comparisons and didn't "see" the difference when I got back into C. Setting a pointer to NULL should always cause an EFAULT. Unfortunately, even 'gcc -Wall' didn't generate an appropriate warning for it. I only use malloc when I won't know how many buffers I need until run time. In this case the application will count records in a configuration file and malloc (1514 * count * 2) bytes, where count can range from 1 to 2000. That becomes an array of buffers, so I can pass just an index or pointer between threads, usually through a mailbox or message queue. It's a simple trick for message passing that I picked up years ago while using the CTASK and XINU kernels. Thanks for all the help, Bob McConnell