modemmanager: improvement of readability by reversing the query
authorFlorian Eckert <redacted>
Thu, 26 Sep 2024 08:19:54 +0000 (10:19 +0200)
committerRobert Marko <redacted>
Thu, 17 Oct 2024 16:29:16 +0000 (18:29 +0200)
No functional change. The change makes reading the source clearer.

Signed-off-by: Florian Eckert <redacted>
net/modemmanager/files/lib/netifd/proto/modemmanager.sh

index 0827c27136d0920a78c66b66a9af35c5ee763d0d..23d73c75504f6dd57a08235da3a526fbddfef6e2 100644 (file)
@@ -338,19 +338,20 @@ modemmanager_check_state_locked() {
        local modemstatus="$3"
        local pincode="$4"
 
-       if [ -n "$pincode" ]; then
-               mmcli --modem="${device}" -i any --pin=${pincode} || {
-                       proto_notify_error "${interface}" MM_PINCODE_WRONG
-                       proto_block_restart "${interface}"
-                       return 1
-               }
-               return 0
-       else
+       if [ -z "$pincode" ]; then
                echo "PIN required"
                proto_notify_error "${interface}" MM_PINCODE_REQUIRED
                proto_block_restart "${interface}"
                return 1
        fi
+
+       mmcli --modem="${device}" -i any --pin=${pincode} || {
+               proto_notify_error "${interface}" MM_PINCODE_WRONG
+               proto_block_restart "${interface}"
+               return 1
+       }
+
+       return 0
 }
 
 modemmanager_check_state() {
git clone https://git.99rst.org/PROJECT