]> git.tdb.fi Git - ext/subsurface.git/commitdiff
Fix reference tank information for LP steel tanks.
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 1 Apr 2012 22:38:52 +0000 (15:38 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 1 Apr 2012 22:38:52 +0000 (15:38 -0700)
Commit f9bb3f79106b ("Clean up reference tank information table") had
cleaned up the tank info list so that you could sanely do tanks in
liters and with a working pressure in bar.

But the LP steel cylinders had somehow missed out on the ".psi =" part
of the equation, and as a result, what was supposed to be their working
pressure instead ended up being interpreted as their size in
milli-liters.

Oops.

Fix that, and also make the standard tank info filling code actually
verify the sanity of the reference tank table, so that if this happens
again, it will complain loudly instead of using nonsensical values.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
equipment.c

index abfb0e7b5979bba41b9af71b1d5391d610ed4359..d537cf7b13f64e3ed81d5e3f9be7ef6dafcb1af1 100644 (file)
@@ -664,10 +664,10 @@ static struct tank_info {
        { "AL100", .cuft = 100, .psi = 3300 },
 
        /* Somewhat common LP steel cylinders */
-       { "LP85",  .cuft =  85, 2640 },
-       { "LP95",  .cuft =  95, 2640 },
-       { "LP108", .cuft = 108, 2640 },
-       { "LP121", .cuft = 121, 2640 },
+       { "LP85",  .cuft =  85, .psi = 2640 },
+       { "LP95",  .cuft =  95, .psi = 2640 },
+       { "LP108", .cuft = 108, .psi = 2640 },
+       { "LP121", .cuft = 121, .psi = 2640 },
 
        /* Somewhat common HP steel cylinders */
        { "HP65",  .cuft =  65, .psi = 3442 },
@@ -696,23 +696,29 @@ static void fill_tank_list(GtkListStore *store)
        GtkTreeIter iter;
        struct tank_info *info = tank_info;
 
-       while (info->name) {
+       for (info = tank_info ; info->name; info++) {
                int ml = info->ml;
                int cuft = info->cuft;
                int psi = info->psi;
                int mbar;
                double bar = info->bar;
 
+               if (psi && bar)
+                       goto bad_tank_info;
+               if (ml && cuft)
+                       goto bad_tank_info;
+               if (cuft && !psi)
+                       goto bad_tank_info;
+
                /* Is it in cuft and psi? */
-               if (psi) {
+               if (psi)
                        bar = psi_to_bar(psi);
 
-                       if (cuft) {
-                               double airvolume = cuft_to_l(cuft) * 1000.0;
-                               double atm = bar_to_atm(bar);
+               if (cuft) {
+                       double airvolume = cuft_to_l(cuft) * 1000.0;
+                       double atm = bar_to_atm(bar);
 
-                               ml = airvolume / atm + 0.5;
-                       }
+                       ml = airvolume / atm + 0.5;
                }
 
                mbar = bar * 1000 + 0.5;
@@ -723,7 +729,10 @@ static void fill_tank_list(GtkListStore *store)
                        1, ml,
                        2, mbar,
                        -1);
-               info++;
+               continue;
+
+bad_tank_info:
+               fprintf(stderr, "Bad tank info for '%s'\n", info->name);
        }
 }