Date: Wed, 18 May 2005 12:58:04 +0800 From: Xu Qiang <Qiang.Xu@fujixerox.com> To: Dan Nelson <dnelson@allantgroup.com>, Xu Qiang <Qiang.Xu@fujixerox.com> Cc: freebsd-questions@freebsd.org Subject: RE: The availability of socketbits.h? Message-ID: <20050518044835.C07951D936@imss.sgp.fujixerox.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050518044835.C07951D936>