From d052e66bbede71957694aacd97544ec81c77eefd Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Thu, 17 Feb 2022 17:00:21 +0530 Subject: [PATCH 1/4] i2c: Trim the device list to avoid errors If the user passes device list with whitespace before or after, like -l " 6:32", then " 6".parse::() fails. Fix this by trimming the argument for whitespace at start or end. Also add a test for the same. Signed-off-by: Viresh Kumar --- i2c/src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/i2c/src/main.rs b/i2c/src/main.rs index 0775cab..d7ee51a 100644 --- a/i2c/src/main.rs +++ b/i2c/src/main.rs @@ -163,7 +163,7 @@ impl TryFrom for I2cConfiguration { return Err(Error::SocketCountInvalid(0)); } - let devices = AdapterConfig::try_from(args.device_list.as_str())?; + let devices = AdapterConfig::try_from(args.device_list.trim())?; Ok(I2cConfiguration { socket_path: args.socket_path, socket_count: args.socket_count, @@ -324,6 +324,11 @@ mod tests { fn test_parse_successful() { let socket_name = "vi2c.sock"; + // Space before and after the device list + let cmd_args = I2cArgs::from_args(socket_name, " 1:4 ", 1); + I2cConfiguration::try_from(cmd_args).unwrap(); + + // Valid configuration let cmd_args = I2cArgs::from_args(socket_name, "1:4,2:32:21,5:5:23", 5); let config = I2cConfiguration::try_from(cmd_args).unwrap(); From b29a5e228583735a9cfd68e86559830fb4054c59 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Thu, 17 Feb 2022 17:00:21 +0530 Subject: [PATCH 2/4] i2c: Trim the socket-path to avoid errors If the user passes socket-path with whitespace before or after, like -l " /tmp/vi2c.sock", then the Listener API fails and errors out. Fix this by trimming the argument for whitespace at start or end. Also add a test for the same. Signed-off-by: Viresh Kumar --- i2c/src/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/i2c/src/main.rs b/i2c/src/main.rs index d7ee51a..91a06de 100644 --- a/i2c/src/main.rs +++ b/i2c/src/main.rs @@ -165,7 +165,7 @@ impl TryFrom for I2cConfiguration { let devices = AdapterConfig::try_from(args.device_list.trim())?; Ok(I2cConfiguration { - socket_path: args.socket_path, + socket_path: args.socket_path.trim().to_string(), socket_count: args.socket_count, devices, }) @@ -324,9 +324,10 @@ mod tests { fn test_parse_successful() { let socket_name = "vi2c.sock"; - // Space before and after the device list - let cmd_args = I2cArgs::from_args(socket_name, " 1:4 ", 1); - I2cConfiguration::try_from(cmd_args).unwrap(); + // Space before and after the device list and socket name + let cmd_args = I2cArgs::from_args(" ./vi2c.sock", " 1:4 ", 1); + let config = I2cConfiguration::try_from(cmd_args).unwrap(); + Listener::new(config.socket_path, true).unwrap(); // Valid configuration let cmd_args = I2cArgs::from_args(socket_name, "1:4,2:32:21,5:5:23", 5); From c27270a449911040c09a7b03d4f2b3a59caaf3e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Feb 2022 04:06:06 +0000 Subject: [PATCH 3/4] build(deps): bump rust-vmm-ci from `d216a46` to `ee6be8c` Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `d216a46` to `ee6be8c`. - [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases) - [Commits](https://github.com/rust-vmm/rust-vmm-ci/compare/d216a46879096a4f1e83af3a7b6c90c26e1a688d...ee6be8ca18bdfd9de294652472307c6776194f89) --- updated-dependencies: - dependency-name: rust-vmm-ci dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- rust-vmm-ci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-vmm-ci b/rust-vmm-ci index d216a46..ee6be8c 160000 --- a/rust-vmm-ci +++ b/rust-vmm-ci @@ -1 +1 @@ -Subproject commit d216a46879096a4f1e83af3a7b6c90c26e1a688d +Subproject commit ee6be8ca18bdfd9de294652472307c6776194f89 From ea45853f84b9ca629d6946df4bf9711628f1372c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Feb 2022 04:07:23 +0000 Subject: [PATCH 4/4] build(deps): bump libc from 0.2.117 to 0.2.119 Bumps [libc](https://github.com/rust-lang/libc) from 0.2.117 to 0.2.119. - [Release notes](https://github.com/rust-lang/libc/releases) - [Commits](https://github.com/rust-lang/libc/compare/0.2.117...0.2.119) --- updated-dependencies: - dependency-name: libc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 275c9f4..5992c95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -134,9 +134,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.117" +version = "0.2.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c" +checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" [[package]] name = "log"