]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
deal with malformed input a bit better
authorregehr <regehr>
Tue, 24 Jun 2008 15:34:39 +0000 (15:34 +0000)
committerregehr <regehr>
Tue, 24 Jun 2008 15:34:39 +0000 (15:34 +0000)
tools/tinyos/safe/tos-decode-flid

index 62893cb21fb43486d0c6ae1ecd8149432ac1800f..5dab226a93b662955381392658b3028ce494668c 100755 (executable)
@@ -12,6 +12,11 @@ sub decode ($$) {
     return $h;
 }
 
+sub usage() {
+    print "Usage: tos-decode-flid flid flid-file\n";
+    exit 2;
+}
+
 sub make_flid () {
 
     my $flid = $ARGV[0];
@@ -25,6 +30,8 @@ sub make_flid () {
        decode(substr($flid,6,1),substr($flid,7,1));
 }
 
+usage() if (scalar(@ARGV)!=2);
+
 my $flidstr = make_flid();
 
 my $fn = $ARGV[1];
@@ -60,8 +67,7 @@ if (defined ($fn)) {
     close INF;
 }
 else {
-    print "Usage: tos-decode-flid flid flid-file\n";
-    exit 2;
+    usage();
 }
 
 if (!$found) {