From d6ca7e72c9ab04bcebbd557e08f795dbbba1dc8a Mon Sep 17 00:00:00 2001
From: renoseven <dev@renoseven.net>
Date: Fri, 22 Dec 2023 18:04:50 +0800
Subject: [PATCH 12/15] daemon: fix rust 1.60 compile issue

Signed-off-by: renoseven <dev@renoseven.net>
---
 daemon/src/patch/manager/driver/upatch/mod.rs | 21 +++++++------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/daemon/src/patch/manager/driver/upatch/mod.rs b/daemon/src/patch/manager/driver/upatch/mod.rs
index 4d06e84..191b327 100644
--- a/daemon/src/patch/manager/driver/upatch/mod.rs
+++ b/daemon/src/patch/manager/driver/upatch/mod.rs
@@ -1,7 +1,4 @@
-use std::{
-    ffi::CStr,
-    path::{Path, PathBuf},
-};
+use std::path::{Path, PathBuf};
 
 use anyhow::{anyhow, bail, ensure, Result};
 
@@ -130,15 +127,13 @@ impl UserPatchDriver {
                 msg_buf.capacity(),
             )
         };
-        if ret_val != 0 {
-            match CStr::from_bytes_until_nul(&msg_buf) {
-                Ok(err_msg) => bail!(format!("Upatch: {}", err_msg.to_string_lossy())),
-                Err(_) => bail!(format!(
-                    "Upatch: {}",
-                    std::io::Error::from_raw_os_error(ret_val)
-                )),
-            }
-        }
+        ensure!(
+            ret_val == 0,
+            format!(
+                "Upatch: {}",
+                String::from_utf8_lossy(&msg_buf).trim_end_matches(|c| c == '\0')
+            )
+        );
 
         Ok(())
     }
-- 
2.33.0

