From owner-freebsd-questions@FreeBSD.ORG Wed May 18 04:55:43 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C75E016A4CE for ; Wed, 18 May 2005 04:55:43 +0000 (GMT) Received: from mx2.fujixerox.co.jp (mx2.fujixerox.co.jp [192.26.96.12]) by mx1.FreeBSD.org (Postfix) with ESMTP id 82C7E43DCA for ; Wed, 18 May 2005 04:55:42 +0000 (GMT) (envelope-from Qiang.Xu@fujixerox.com) Received: from isvw2.fujixerox.co.jp ([129.249.27.132]) by mx2.fujixerox.co.jp (8.11.6p2a/3.7W) with ESMTP id j4I4tXm05955; Wed, 18 May 2005 13:55:34 +0900 (JST) Received: from ms1.fujixerox.co.jp (isvw2 [129.249.27.132]) by isvw2.fujixerox.co.jp (8.11.6p2a/3.7W) with ESMTP id j4I4tQs17786; Wed, 18 May 2005 13:55:26 +0900 (JST) Received: from sgpaphq-smtp01.fujixerox.com ([13.198.8.73]) by ms1.fujixerox.co.jp (8.11.6p2a/3.7W) with ESMTP id j4I4tWa26795; Wed, 18 May 2005 13:55:32 +0900 (JST) Received: from 10.198.8.10 by sgpaphq-smtp01.fujixerox.com with ESMTP id 50349891116392115; Wed, 18 May 2005 12:55:15 +0800 Received: from localhost (localhost [127.0.0.1]) by localhost.sgp.fujixerox.com (Postfix) with SMTP id A03CA1D93F; Wed, 18 May 2005 12:48:38 +0800 (SGT) Received: from sess.xssc.sgp.xerox.com (unknown [13.198.33.122]) by imss.sgp.fujixerox.com (Postfix) with ESMTP id C07951D936; Wed, 18 May 2005 12:48:35 +0800 (SGT) From: Xu Qiang To: Dan Nelson , Xu Qiang Date: Wed, 18 May 2005 12:58:04 +0800 X-Sent-Folder-Path: Sent Items X-Mailer: Oracle Connector for Outlook 9.0.4 60130 (9.0.2711) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Message-Id: <20050518044835.C07951D936@imss.sgp.fujixerox.com> cc: Giorgos Keramidas cc: freebsd-questions@freebsd.org Subject: RE: The availability of socketbits.h? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 May 2005 04:55:43 -0000 Dan Nelson wrote: > The rest of the code in command.c makes use of the command_count value > and assumes that all the array elements are fully populated. The > qsort routime tried to compare a NULL comm_name value and seg > faulted. His fix would have worked if the rest of the program used > the same code loop as the one at command.c:1149, but it doesn't. Yeah, you hit the point again! = Just found the variable noofcomms (=3D COUNTOF(command_list)) is used in th= e function qsort() = --------------------------------------------------------------------- qsort(&(command_list),noofcomms,sizeof command_list[0],&command_cmp); --------------------------------------------------------------------- No wonder trailing NULL element at the end of the array command_list[] is u= sed in qsort(), and the segmentation fault. Since the number of actual non-NULL elements in the array is one less than = the array's size, I changed the calculation of noofcomms as: = --------------------------------------------------------------------- noofcomms =3D COUNTOF(command_list) - 1; --------------------------------------------------------------------- Now the program can work properly. :) > The author may not have tested it on many systems, and since the > source is so old (relatively speaking), standards have changed. It's > no longer acceptable to provide your own prototypes for system > functions, for example (which was the cause of your first few compile > errors). = I am very lucky to have you and Giorgos around to help me in compiling this= software. Thank you two so much for your help and patience! with my best wishes, Xu Qiang