[LEDE-DEV] [PATCH usbmode] fix indices of messages

Julian Labus julian at labus-online.de
Thu May 18 06:18:25 PDT 2017


the way how the script checked if a key already exists in a hash
leads to wrong indices for %messages.

Signed-off-by: Julian Labus <julian at labus-online.de>
---
 convert-modeswitch.pl | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/convert-modeswitch.pl b/convert-modeswitch.pl
index 7b2323b..6e7bb86 100755
--- a/convert-modeswitch.pl
+++ b/convert-modeswitch.pl
@@ -7,12 +7,13 @@ my %devices;
 
 sub add_message {
 	my $msg = shift;
-	my $val = $messages{$msg};
-
-	$val or do {
+	my $val;
+	if (exists $messages{$msg}) {
+		$val = $messages{$msg};
+	} else {
 		$val = $msg_ctr++;
 		$messages{$msg} = $val;
-	};
+	}
 
 	return $val;
 }
-- 
2.11.0




More information about the Lede-dev mailing list