From 62b226e9c47fea0e812ec5513b70a52546b60879 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 1 Oct 2021 16:45:19 +0200 Subject: [PATCH] rest: daemon: sd notify: code cleanup Signed-off-by: Thomas Lamprecht --- proxmox-rest-server/src/daemon.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/proxmox-rest-server/src/daemon.rs b/proxmox-rest-server/src/daemon.rs index 495ff888..45d18ad0 100644 --- a/proxmox-rest-server/src/daemon.rs +++ b/proxmox-rest-server/src/daemon.rs @@ -330,13 +330,11 @@ pub enum SystemdNotify { /// Tells systemd the startup state of the service (see: ``man sd_notify``) pub fn systemd_notify(state: SystemdNotify) -> Result<(), Error> { - - if let SystemdNotify::Ready = &state { - log::info!("service is ready"); - } - let message = match state { - SystemdNotify::Ready => CString::new("READY=1"), + SystemdNotify::Ready => { + log::info!("service is ready"); + CString::new("READY=1") + }, SystemdNotify::Reloading => CString::new("RELOADING=1"), SystemdNotify::Stopping => CString::new("STOPPING=1"), SystemdNotify::Status(msg) => CString::new(format!("STATUS={}", msg)), @@ -344,10 +342,7 @@ pub fn systemd_notify(state: SystemdNotify) -> Result<(), Error> { }?; let rc = unsafe { sd_notify(0, message.as_ptr()) }; if rc < 0 { - bail!( - "systemd_notify failed: {}", - std::io::Error::from_raw_os_error(-rc), - ); + bail!("systemd_notify failed: {}", std::io::Error::from_raw_os_error(-rc)); } Ok(())