Browse Source

TT#24097 Do not use magic variable names

These variables have magic meanings, we should avoid their usage to not
confuse readers nor trigger side-effects.

Change-Id: Ieb759f74ccde6ba6466f5c02743e3f881b5d53b7
changes/09/16709/3
Guillem Jover 8 years ago
parent
commit
d5ad4a9f88
2 changed files with 21 additions and 21 deletions
  1. +9
    -9
      tests/blist.pl
  2. +12
    -12
      tests/simulator-ng.pl

+ 9
- 9
tests/blist.pl View File

@ -13,21 +13,21 @@ my $len = length(pack($format, (0) x 100));
open(my $fh, "<", "/proc/rtpengine/$t/blist") or die;
my $buf;
while (sysread($fh, $buf, $len)) {
my @b = unpack($format, $buf);
my @buf = unpack($format, $buf);
for (2,6,10) {
if ($b[$_] == AF_INET) {
$b[$_ + 1] = inet_ntoa($b[$_ + 1]);
if ($buf[$_] == AF_INET) {
$buf[$_ + 1] = inet_ntoa($buf[$_ + 1]);
}
elsif ($b[$_] == AF_INET6) {
$b[$_ + 1] = inet_ntop(AF_INET6, $b[$_ + 1]);
elsif ($buf[$_] == AF_INET6) {
$buf[$_ + 1] = inet_ntop(AF_INET6, $buf[$_ + 1]);
}
elsif ($b[$_] == 0) {
$b[$_ + 1] = '---';
elsif ($buf[$_] == 0) {
$buf[$_ + 1] = '---';
}
}
for (18, 20, 22) {
$b[$_] += $b[$_ + 1] * 2**32;
$buf[$_] += $buf[$_ + 1] * 2**32;
}
printf("%5u %15s:%-5u -> %15s:%-5u (-> %15s:%-5u) [%u] [%llu %llu %llu]\n", @b[0,3,4,7,8,11,12,14,18,20,22]);
printf("%5u %15s:%-5u -> %15s:%-5u (-> %15s:%-5u) [%u] [%llu %llu %llu]\n", @buf[0,3,4,7,8,11,12,14,18,20,22]);
}
close($fh);

+ 12
- 12
tests/simulator-ng.pl View File

@ -334,24 +334,24 @@ sub rtp_savp {
sub savp_crypto {
my ($sdp, $ctx, $ctx_o) = @_;
my @a = $sdp =~ /[\r\n]a=crypto:(\d+) (\w+) inline:([\w\/+=]{40,})(?:\|(?:2\^(\d+)|(\d+)))?(?:\|(\d+):(\d+))?(?: (.*?))?[\r\n]/sig;
@a or die;
my @aa = $sdp =~ /[\r\n]a=crypto:(\d+) (\w+) inline:([\w\/+=]{40,})(?:\|(?:2\^(\d+)|(\d+)))?(?:\|(\d+):(\d+))?(?: (.*?))?[\r\n]/sig;
@aa or die;
my $i = 0;
while (@a >= 8) {
$$ctx[$i]{in}{crypto_suite} = $NGCP::Rtpclient::SRTP::crypto_suites{$a[1]} or die;
$$ctx[$i]{in}{crypto_tag} = $a[0];
while (@aa >= 8) {
$$ctx[$i]{in}{crypto_suite} = $NGCP::Rtpclient::SRTP::crypto_suites{$aa[1]} or die;
$$ctx[$i]{in}{crypto_tag} = $aa[0];
($$ctx[$i]{in}{rtp_master_key}, $$ctx[$i]{in}{rtp_master_salt})
= NGCP::Rtpclient::SRTP::decode_inline_base64($a[2], $$ctx[$i]{in}{crypto_suite});
$$ctx[$i]{in}{rtp_mki} = $a[5];
$$ctx[$i]{in}{rtp_mki_len} = $a[6];
= NGCP::Rtpclient::SRTP::decode_inline_base64($aa[2], $$ctx[$i]{in}{crypto_suite});
$$ctx[$i]{in}{rtp_mki} = $aa[5];
$$ctx[$i]{in}{rtp_mki_len} = $aa[6];
undef($$ctx[$i]{in}{rtp_session_key});
undef($$ctx[$i]{in}{rtcp_session_key});
($a[7] || '') =~ /UNENCRYPTED_SRTP/ and $$ctx[$i]{in}{unenc_srtp} = 1;
($a[7] || '') =~ /UNENCRYPTED_SRTCP/ and $$ctx[$i]{in}{unenc_srtcp} = 1;
($a[7] || '') =~ /UNAUTHENTICATED_SRTP/ and $$ctx[$i]{in}{unauth_srtp} = 1;
($aa[7] || '') =~ /UNENCRYPTED_SRTP/ and $$ctx[$i]{in}{unenc_srtp} = 1;
($aa[7] || '') =~ /UNENCRYPTED_SRTCP/ and $$ctx[$i]{in}{unenc_srtcp} = 1;
($aa[7] || '') =~ /UNAUTHENTICATED_SRTP/ and $$ctx[$i]{in}{unauth_srtp} = 1;
$i++;
@a = @a[8 .. $#a];
@aa = @aa[8 .. $#aa];
}
}


Loading…
Cancel
Save