From: regehr Date: Tue, 24 Jun 2008 15:34:39 +0000 (+0000) Subject: deal with malformed input a bit better X-Git-Tag: release_tinyos_2_1_0_0~181 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=d80532de0bd9b17c9d0eb5086ac3de00d982d812 deal with malformed input a bit better --- diff --git a/tools/tinyos/safe/tos-decode-flid b/tools/tinyos/safe/tos-decode-flid index 62893cb2..5dab226a 100755 --- a/tools/tinyos/safe/tos-decode-flid +++ b/tools/tinyos/safe/tos-decode-flid @@ -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) {