http://www.jwz.org/xscreensaver/xscreensaver-5.12.tar.gz
[xscreensaver] / hacks / glx / sonar.c
index 535b52fea5599ea0d014ada3804e7638a2b7a5d1..66d8b833ff8f006070a7086102cc0a52ce3965fb 100644 (file)
@@ -236,6 +236,9 @@ draw_screen (ModeInfo *mi, Bool mesh_p, Bool sweep_p)
 
       r0 = i     / (GLfloat) r_steps;
       r1 = (i+1) / (GLfloat) r_steps;
+
+      if (r1 > 1) r1 = 1; /* avoid asin lossage */
+
       z0 = cos (curvature/2 * asin (r0)) / 2 - zoff;
       z1 = cos (curvature/2 * asin (r1)) / 2 - zoff;
 
@@ -556,9 +559,11 @@ static void
 copy_and_insert_bogie (sonar_sensor_data *ssd, sonar_bogie *b,
                        sonar_bogie **to_list)
 {
-  sonar_bogie *ob, *prev;
+  sonar_bogie *ob, *next;
   if (!b) abort();
-  for (prev = 0, ob = *to_list; ob; prev = ob, ob = ob->next)
+  for (ob = *to_list, next = ob ? ob->next : 0; 
+       ob; 
+       ob = next, next = ob ? ob->next : 0)
     {
       if (ob == b) abort();   /* this will end badly */
       if (!strcmp (ob->name, b->name))  /* match! */