From owner-freebsd-questions@FreeBSD.ORG Wed May 18 05:27:04 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 0B58016A4CE for ; Wed, 18 May 2005 05:27:04 +0000 (GMT) Received: from mail.freebsd-corp-net-guide.com (mail.freebsd-corp-net-guide.com [65.75.192.90]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5660D43D7D for ; Wed, 18 May 2005 05:27:03 +0000 (GMT) (envelope-from tedm@toybox.placo.com) Received: from tedwin2k (nat-rtr.freebsd-corp-net-guide.com [65.75.197.130]) j4I5RLb34536; Tue, 17 May 2005 22:27:21 -0700 (PDT) (envelope-from tedm@toybox.placo.com) From: "Ted Mittelstaedt" To: "Xu Qiang" , "Dan Nelson" Date: Tue, 17 May 2005 22:26:44 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: <20050518044835.C07951D936@imss.sgp.fujixerox.com> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478 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 05:27:04 -0000 > -----Original Message----- > From: owner-freebsd-questions@freebsd.org > [mailto:owner-freebsd-questions@freebsd.org]On Behalf Of Xu Qiang > Sent: Tuesday, May 17, 2005 9:58 PM > To: Dan Nelson; Xu Qiang > Cc: Giorgos Keramidas; freebsd-questions@freebsd.org > Subject: RE: The availability of socketbits.h? > > > 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 (= COUNTOF(command_list)) is > used in the 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 used 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 = 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 > Would you post a diff of the files you had to change to the list once you get it running? Thanks, Ted