summaryrefslogtreecommitdiff
path: root/lib/Vyatta/Qos/Util.pm
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-05-28 16:12:13 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-05-28 16:12:13 -0700
commit0eca7ca8d325375643bf3d1f498345565fef24e0 (patch)
tree467f949bbc93c3ebb618436f35ce9163aeafcbd3 /lib/Vyatta/Qos/Util.pm
parent1e6b847205ba24e673152b8e67764145105b0062 (diff)
downloadvyatta-cfg-qos-0eca7ca8d325375643bf3d1f498345565fef24e0.tar.gz
vyatta-cfg-qos-0eca7ca8d325375643bf3d1f498345565fef24e0.zip
Handle percent without % sign
Bug 4465 When using percent for netem, allow value without percent
Diffstat (limited to 'lib/Vyatta/Qos/Util.pm')
-rw-r--r--lib/Vyatta/Qos/Util.pm23
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/Vyatta/Qos/Util.pm b/lib/Vyatta/Qos/Util.pm
index 7f5454d..151b1d3 100644
--- a/lib/Vyatta/Qos/Util.pm
+++ b/lib/Vyatta/Qos/Util.pm
@@ -113,18 +113,17 @@ sub getPercent {
my $percent = shift;
my ( $num, $suffix ) = get_num($percent);
- ( $suffix eq '%' )
- or die "$percent incorrect suffix (expect %)\n";
- defined $num
- or die "$percent is not a valid percent bandwidth (not a number)\n";
- ( $num >= 0 )
- or die
- "$percent is not a acceptable percent bandwidth (negative value)\n";
- ( $num <= 100 )
- or die
- "$percent is not a acceptable percent bandwidth (greater than 100%)\n";
-
- return $num;
+ if (defined $suffix && $suffix ne '%' ) {
+ die "$percent incorrect suffix (expect %)\n";
+ } elsif (! defined $num) {
+ die "$percent is not a valid percent (not a number)\n";
+ } elsif ( $num < 0 ) {
+ die "$percent is not a acceptable percent (negative value)\n";
+ } elsif ( $num > 100 ) {
+ die "$percent is not a acceptable percent (greater than 100%)\n";
+ } else {
+ return $num;
+ }
}
# Default time units for tc are usec.