Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: problem wit...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 62 of 91 Topic 26095 of 27670
Post > Topic >>

Re: problem with output of the program on different OS

by pereges <Broli00@[EMAIL PROTECTED] > May 12, 2008 at 02:22 AM

On May 12, 6:35 am, Richard Heathfield <r...@[EMAIL PROTECTED]
> wrote:


> Well, I don't hold out a lot of hope for this review, judging by the
OP's
> reply to the first part thereof ("I think this is not the problem", for
> instance, shows a remarkable talent for disregarding general-principle
> comments simply because they don't appear to explain the immediate cause
> of the immediate segfault - if ever there were a short-sighted approach
to
> debugging, this has to be it).

well, i did include the assert(index >= 0) statement in the code but
while executing the assertion fails. What I'm trying to say is that
this is natural because index is bound to have value -1 for cases
where ray does not intersect the triangle. Also res.hit = FALSE for
such situations.


> Nevertheless, let's press on for now.
>
> I fixed the scanfs in initialize_radar(), checking the return values and
> returning FAILURE if they were incorrect. (As mentioned in my earlier
> article, I also C90ified and re-indented the code, purely for my own
> convenience.) The function now looks like this:
>
> int initialize_radar(bbox b,
>                      radar_detector * radar)
> {
>   int rc = SUCCESS;
>   vector *pointinarray = NULL;
>   int i;
>   unsigned long int ray_count;
>
>   radar->maxP = b.maxB;
>   radar->minP = b.minB;
>   radar->maxP.z = radar->minP.z = b.minB.z - 1000;
>
>   printf
>     ("Enter the frequency of the electromagnetic rays to be fired\n");
>   if(scanf("%le", &radar->frequency) != 1)
>   {
>     rc = FAILURE;
>   }
>   else
>   {
>     radar->wavenumber = 2 * M_PI * radar->frequency / VELOCITY;
>
>     printf("Enter the amplitude of electric field\n");
>     if(scanf("%le", &radar->E0) != 1)
>     {
>       rc = FAILURE;
>     }
>   }
>
>   if(rc == SUCCESS)
>   {
>     printf("Enter the number of electromagnetic rays to be fired\n");
>     if(scanf("%lu", &radar->numberofrays) != 1)
>     {
>       rc = FAILURE;
>     }
>   }
>
>   if(rc == SUCCESS)
>   {
>     real(radar->E_incident) = 0;
>     imag(radar->E_scattered) = 0;
>
>     i =
>       gen_grid_points(&pointinarray, &radar->numberofrays, b.maxB.x,
>                       b.minB.x, b.maxB.y, b.minB.y, b.minB.z - 1000);
>     if(i == FAILURE)
>     {
>       rc = FAILURE;
>     }
>   }
>   if(rc == SUCCESS)
>   {
>     ray_count = radar->numberofrays;
>     radar->raylist = malloc(ray_count * sizeof (ray));
>     if(radar->raylist == NULL)
>     {
>       perror("malloc has failed");
>       rc = FAILURE;
>     }
>   }
>
>   if(rc == SUCCESS)
>   {
>     for(ray_count = 0; ray_count < radar->numberofrays; ray_count++)
>     {
>       radar->raylist[ray_count].origin = pointinarray[ray_count];
>       radar->raylist[ray_count].direction.x = 0;
>       radar->raylist[ray_count].direction.y = 0;
>       radar->raylist[ray_count].direction.z = 1;
>       radar->raylist[ray_count].depth = 0;
>       radar->raylist[ray_count].pathlength = DBL_MAX;
>       radar->raylist[ray_count].child = NULL;
>       real(radar->raylist[ray_count].efield) = radar->E0;
>       imag(radar->raylist[ray_count].efield) = 0;
>     }
>   }
>
>   free(pointinarray);
>
>   return rc;
>
> }
>
> This source file (radar.c) now gives just two diagnostic messages, both
to
> do with passing an unsigned long int to sqrt. (Yes, I killed my
insertion
> of assert(*numpoints >= 0, now that I realise *numpoints has unsigned
> integer type.
>
> Continuing on my quest to get the diagnostic count down a bit, I moved
on
> to reader.c. Simply moving the definitions of tem****ary vectors up to
the
> top of the function, I made the code C90-compatible. The remaining
> warnings are:
>
> reader.c:68: warning: passing arg 2 of `calloc' as unsigned due to
> prototype
> reader.c:69: warning: passing arg 2 of `calloc' as unsigned due to
> prototype
> reader.c:109: warning: enumeration value `LAST_LINE' not handled in
switch
>
> Although I don't like the first two, I can live with them if you can -
the
> alternative (i.e. to use unsigned types for nvert and ntri) may be more
> painful to fix than is practical (I haven't delved).
>
> The last one, I leave in your hands. I'm not making any huge attempt to
> understand the program here - I'm just looking at the C.
>
> I needed to C90ify the test.c file, changing a comment to /* style */
and
> moving a definition up a bit. The reflection.c file also needed some
> comment-fixing.
>
> Now it compiles. It doesn't /link/, but that's my makefile's problem,
not
> yours. So let's run it:
>
> $ ./raytrace
> Enter the frequency of the electromagnetic rays to be fired
>
> Well, I have no idea what to type here, so I just entered 0 for
everything,
> and lo and behold, I got an assertion failure:
>
> raytrace: radar.c:49: gen_grid_points: Assertion `numpointsx > 1'
failed.
>
> I added this assertion because your code assumed that numpointsx could
not
> be 1 or lower. That assumption is clearly wrong.
>
> I suggest you fix this (by validating your data before passing it to the
> function that needs it to be > 1). If the code continues to give
problems
> after that's fixed, show us the fixed code so that we know that this
> particular problem is known not to be a candidate any longer.
>

thanks i will try to incor****ate the changes you have suggested
 




 91 Posts in Topic:
problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-08 01:20:05 
Re: problem with output of the program on different OS
Richard Heathfield <rj  2008-05-08 08:26:22 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-08 01:34:12 
Re: problem with output of the program on different OS
Ian Collins <ian-news@  2008-05-08 20:42:23 
Re: problem with output of the program on different OS
Richard Heathfield <rj  2008-05-08 09:13:32 
Re: problem with output of the program on different OS
jacob navia <jacob@[EM  2008-05-08 11:59:09 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-08 01:49:39 
Re: problem with output of the program on different OS
Nick Keighley <nick_ke  2008-05-08 02:19:06 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-08 06:45:10 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-08 22:40:28 
Re: problem with output of the program on different OS
Richard Heathfield <rj  2008-05-09 05:52:41 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-08 23:20:44 
Re: problem with output of the program on different OS
Richard Heathfield <rj  2008-05-09 07:32:33 
Re: problem with output of the program on different OS
Ian Collins <ian-news@  2008-05-09 19:59:46 
Re: problem with output of the program on different OS
Richard Heathfield <rj  2008-05-10 06:31:13 
Re: problem with output of the program on different OS
Richard Heathfield <rj  2008-05-12 01:35:03 
Re: problem with output of the program on different OS
Spiros Bousbouras <spi  2008-05-09 00:28:46 
Re: problem with output of the program on different OS
Richard Heathfield <rj  2008-05-09 07:51:07 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-09 01:22:57 
Re: problem with output of the program on different OS
Ian Collins <ian-news@  2008-05-09 21:08:08 
Re: problem with output of the program on different OS
Spiros Bousbouras <spi  2008-05-09 01:51:36 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-09 02:16:12 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-09 02:25:03 
Re: problem with output of the program on different OS
Ian Collins <ian-news@  2008-05-09 21:56:02 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-09 02:27:52 
Re: problem with output of the program on different OS
Antoninus Twink <nospa  2008-05-09 12:00:16 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-09 03:28:15 
Re: problem with output of the program on different OS
Ian Collins <ian-news@  2008-05-09 22:53:30 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-09 04:01:47 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-09 04:21:35 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-09 05:33:08 
Re: problem with output of the program on different OS
Richard<_rdev@[EMAIL P  2008-05-09 15:25:49 
Re: problem with output of the program on different OS
Chris Dollin <chris.do  2008-05-13 13:07:33 
Re: problem with output of the program on different OS
Richard Heathfield <rj  2008-05-13 12:29:31 
Re: problem with output of the program on different OS
Chris Dollin <chris.do  2008-05-13 16:03:51 
Re: problem with output of the program on different OS
CBFalconer <cbfalconer  2008-05-13 10:02:24 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-09 06:33:21 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-09 06:46:50 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-09 07:11:31 
Re: problem with output of the program on different OS
Ben Bacarisse <ben.use  2008-05-09 15:25:42 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-09 07:57:58 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-09 08:45:35 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-09 09:42:59 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-09 10:18:52 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-09 10:26:53 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-09 11:28:47 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-09 12:09:57 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-09 12:14:55 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-09 12:43:25 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-09 12:58:32 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-10 04:22:35 
Re: problem with output of the program on different OS
Richard Heathfield <rj  2008-05-10 12:24:42 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-10 09:26:16 
Re: problem with output of the program on different OS
Richard Heathfield <rj  2008-05-10 17:39:35 
Re: problem with output of the program on different OS
Flash Gordon <spam@[EM  2008-05-10 23:31:36 
Re: problem with output of the program on different OS
Joe Wright <joewwright  2008-05-11 10:04:20 
Re: problem with output of the program on different OS
dj3vande@[EMAIL PROTECTED  2008-05-11 20:40:39 
Re: problem with output of the program on different OS
pete <pfiland@[EMAIL P  2008-05-11 19:50:38 
Re: problem with output of the program on different OS
Harald van =?UTF-8?b?RMSz  2008-05-11 16:58:12 
Re: problem with output of the program on different OS
Spiros Bousbouras <spi  2008-05-11 18:52:11 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-12 02:17:17 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-12 02:22:09 
Re: problem with output of the program on different OS
Richard Heathfield <rj  2008-05-12 10:54:15 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-12 05:42:52 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-12 06:29:10 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-12 08:06:49 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-12 10:27:24 
Re: problem with output of the program on different OS
Ben Bacarisse <ben.use  2008-05-12 18:44:43 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-12 14:03:00 
Re: problem with output of the program on different OS
Ben Bacarisse <ben.use  2008-05-13 01:39:16 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-12 18:27:34 
Re: problem with output of the program on different OS
Ben Bacarisse <ben.use  2008-05-13 04:46:03 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-12 21:13:42 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-12 22:34:37 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-13 04:13:26 
Re: problem with output of the program on different OS
Ben Bacarisse <ben.use  2008-05-13 13:12:32 
Re: problem with output of the program on different OS
Ben Bacarisse <ben.use  2008-05-13 13:15:11 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-13 05:23:49 
Re: problem with output of the program on different OS
Ben Bacarisse <ben.use  2008-05-13 13:58:08 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-13 06:13:24 
Re: problem with output of the program on different OS
Ben Bacarisse <ben.use  2008-05-13 15:23:07 
Re: problem with output of the program on different OS
Ben Bacarisse <ben.use  2008-05-13 15:33:58 
Re: problem with output of the program on different OS
CBFalconer <cbfalconer  2008-05-13 09:53:22 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-16 02:16:28 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-16 03:01:45 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-16 03:03:12 
Re: problem with output of the program on different OS
Ben Bacarisse <ben.use  2008-05-16 12:24:06 
Re: problem with output of the program on different OS
pereges <Broli00@[EMAI  2008-05-16 04:55:17 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-16 05:02:26 
Re: problem with output of the program on different OS
Ben Bacarisse <ben.use  2008-05-16 14:27:26 
Re: problem with output of the program on different OS
Bart <bc@[EMAIL PROTEC  2008-05-16 08:02:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 22:15:42 CDT 2008.