Date: Tue, 17 May 2005 22:26:44 -0700 From: "Ted Mittelstaedt" <tedm@toybox.placo.com> To: "Xu Qiang" <Qiang.Xu@fujixerox.com>, "Dan Nelson" <dnelson@allantgroup.com> Cc: freebsd-questions@freebsd.org Subject: RE: The availability of socketbits.h? Message-ID: <LOBBIFDAGNMAMLGJJCKNGEHHFBAA.tedm@toybox.placo.com> In-Reply-To: <20050518044835.C07951D936@imss.sgp.fujixerox.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> -----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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?LOBBIFDAGNMAMLGJJCKNGEHHFBAA.tedm>