From 1a473fd89785cdd31e633f4afa57ab6269dbc265 Mon Sep 17 00:00:00 2001
From: "Norbraten, Terry" <tdnorbra@nps.edu>
Date: Mon, 27 Aug 2018 13:33:47 -0700
Subject: [PATCH] remove redundant casts, use System.err for error msgs

---
 src/edu/nps/moves/lifi/LiFiBenchmark.java | 25 +++++++++++------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/src/edu/nps/moves/lifi/LiFiBenchmark.java b/src/edu/nps/moves/lifi/LiFiBenchmark.java
index cad7734..ba310b5 100644
--- a/src/edu/nps/moves/lifi/LiFiBenchmark.java
+++ b/src/edu/nps/moves/lifi/LiFiBenchmark.java
@@ -104,7 +104,7 @@ public class LiFiBenchmark
     if(discards>0) {
       System.out.println("Ignoring first "+discards+" repetitions");
       if(discards>=reps) {
-        System.out.println("Error: discards >= repetitions");
+        System.err.println("Error: discards >= repetitions");
         System.exit(1);
       }
     }
@@ -130,7 +130,7 @@ public class LiFiBenchmark
           showRep(startms, readAcc);
       }
       catch (IOException ex) {
-        System.out.println("Exception " + ex.getClass().getSimpleName() + " in networkRead(): " + ex.getMessage());
+        System.err.println("Exception " + ex.getClass().getSimpleName() + " in networkRead(): " + ex.getMessage());
         System.exit(-1);
       }
     }
@@ -153,7 +153,7 @@ public class LiFiBenchmark
       }
     }
     catch (IOException ex) {
-      System.out.println("Exception waiting for connections: "+ex.getMessage());
+      System.err.println("Exception waiting for connections: "+ex.getMessage());
       System.exit(-1);
     }
   }
@@ -172,8 +172,8 @@ public class LiFiBenchmark
         }
       }
       catch (IOException ex) {
-        System.out.println("Shutting down: " + ex.getClass().getSimpleName() + ": " + ex.getLocalizedMessage());
-        System.out.println("Wrote "+wrote);
+        System.err.println("Shutting down: " + ex.getClass().getSimpleName() + ": " + ex.getLocalizedMessage());
+        System.err.println("Wrote "+wrote);
       }
     }).start();
   }
@@ -196,10 +196,10 @@ public class LiFiBenchmark
           return ret * 1000000000l;
         default:
           return ret;        
-      }}
+      }
+    }
 
-    
-    System.out.println("Error on command line.  Don't understand "+s+" argument for byte count");
+    System.err.println("Error on command line.  Don't understand "+s+" argument for byte count");
     System.exit(1);
     return -1;  // not executed
   }
@@ -242,7 +242,6 @@ public class LiFiBenchmark
         .longOpt("repetitions")
         .desc("Number of transfers to perform")
         .build());
-    
     opts.addOption(Option.builder("x")
         .hasArg()
         .required(false)
@@ -254,7 +253,7 @@ public class LiFiBenchmark
       return new DefaultParser().parse(opts, args);
     }
     catch (ParseException ex) {
-      System.out.println("Parsing failed: " + ex.getMessage());
+      System.err.println("Parsing failed: " + ex.getMessage());
       System.exit(1);
       return null;
     }
@@ -267,7 +266,7 @@ public class LiFiBenchmark
   {
     long endms = System.currentTimeMillis();
     long span = endms - startms;
-    double spansecs = (double) span / 1000.d;
+    double spansecs = span / 1000.d;
     
     System.out.println();
     System.out.println("Read " + read + " bytes in " + span + " msec.");
@@ -275,7 +274,7 @@ public class LiFiBenchmark
     //System.out.format("Rate: %.2e bytes/sec%n",((double)readAcc/spansecs));
     spanMsAccum += span;
     bytesAccum+= read;
-    double bits = (double) read * 8.d;
+    double bits = read * 8.d;
     //System.out.format("Rate: %.2e bits/sec%n",(bits/spansecs));
     System.out.format("Rate: %.2e Mbit/s%n", ((bits / 1000000.d) / spansecs));
     System.out.format("Rate: %.2f Gbit/s%n", ((bits / 1000000000.d) / spansecs));
@@ -296,7 +295,7 @@ public class LiFiBenchmark
     //System.out.format("Rate: %.2e bytes/msec%n", (bytesAvg / msAvg));
     //System.out.format("Rate: %.2e bytes/sec%n",((double)readAcc/spansecs));
 
-    double bits = (double) bytesAvg * 8.d;
+    double bits = bytesAvg * 8.d;
     //System.out.format("Rate: %.2e bits/sec%n",(bits/spansecs));
     System.out.format("Rate: %.2e Mbit/s%n", ((bits / 1000000.d) / (secAvg)));
     System.out.format("Rate: %.2f Gbit/s%n", ((bits / 1000000000.d) / (secAvg)));
-- 
GitLab