From 5ce27d9ee552ffe24ffdc234467ae4b817b956d1 Mon Sep 17 00:00:00 2001
From: chenjiayi <chenjiayi22@huawei.com>
Date: Fri, 19 Apr 2024 03:16:26 +0800
Subject: [PATCH 1/1] fix(devmaster): add device property when cmdline
 parameter has no value

If cmdline parameter has no value, assign "1" to it and add property
to the device.
---
 exts/devmaster/src/lib/rules/exec_mgr.rs | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/exts/devmaster/src/lib/rules/exec_mgr.rs b/exts/devmaster/src/lib/rules/exec_mgr.rs
index 54e0093e..4dd15a00 100644
--- a/exts/devmaster/src/lib/rules/exec_mgr.rs
+++ b/exts/devmaster/src/lib/rules/exec_mgr.rs
@@ -908,11 +908,20 @@ impl ExecuteManager {
                     return Ok(token.read().unwrap().as_ref().unwrap().op == OperatorType::Nomatch);
                 }
 
-                let value = cmdline.get_param(&token_value);
+                let value = match cmdline.get_param(&token_value) {
+                    Some(v) => {
+                        if v.is_empty() {
+                            "1".to_string()
+                        } else {
+                            v
+                        }
+                    }
+                    None => "1".to_string(),
+                };
 
                 execute_err!(
                     token.read().unwrap().as_ref().unwrap(),
-                    device.add_property(&token_value, &value.unwrap_or_default())
+                    device.add_property(&token_value, &value)
                 )?;
 
                 Ok(token.read().unwrap().as_ref().unwrap().op == OperatorType::Match)
-- 
2.33.0

