~kennylevinsen/greetd-devel

Use inline formatting strings whenever possible v1 APPLIED

Hugo Osvaldo Barrera: 1
 Use inline formatting strings whenever possible

 15 files changed, 108 insertions(+), 112 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~kennylevinsen/greetd-devel/patches/58088/mbox | git am -3
Learn more about email & git

[PATCH] Use inline formatting strings whenever possible Export this patch

---
 agreety/src/main.rs             | 26 +++++++++----------
 fakegreet/src/error.rs          |  4 +--
 fakegreet/src/main.rs           | 14 +++++-----
 greetd/src/config/mod.rs        | 30 ++++++++++-----------
 greetd/src/context.rs           |  8 +++---
 greetd/src/error.rs             |  4 +--
 greetd/src/main.rs              |  6 ++---
 greetd/src/pam/mod.rs           |  6 ++---
 greetd/src/server.rs            | 46 ++++++++++++++++-----------------
 greetd/src/session/conv.rs      |  4 +--
 greetd/src/session/interface.rs | 12 ++++-----
 greetd/src/session/worker.rs    | 18 ++++++-------
 greetd/src/terminal/mod.rs      | 32 +++++++++++------------
 greetd_ipc/src/codec/mod.rs     |  2 +-
 inish/src/lib.rs                |  8 +++---
 15 files changed, 108 insertions(+), 112 deletions(-)

diff --git a/agreety/src/main.rs b/agreety/src/main.rs
index 6fce87a..5bf945b 100644
--- a/agreety/src/main.rs
+++ b/agreety/src/main.rs
@@ -21,7 +21,7 @@ fn maybe_unquote(s: &str) -> Result<String, Box<dyn std::error::Error>> {
fn prompt_stderr(prompt: &str) -> Result<String, Box<dyn std::error::Error>> {
    let stdin = io::stdin();
    let mut stdin_iter = stdin.lock().lines();
    eprint!("{}", prompt);
    eprint!("{prompt}");
    Ok(stdin_iter.next().ok_or("no input")??)
}

@@ -43,7 +43,7 @@ fn get_issue() -> Result<String, Box<dyn std::error::Error>> {
            "\\S",
            &get_distro_name().unwrap_or_else(|_| "Linux".to_string()),
        )
        .replace("\\l", &format!("tty{}", vtnr))
        .replace("\\l", &format!("tty{vtnr}"))
        .replace("\\s", uts.sysname().to_str().unwrap())
        .replace("\\r", uts.release().to_str().unwrap())
        .replace("\\v", uts.version().to_str().unwrap())
@@ -64,11 +64,11 @@ fn login(
) -> Result<LoginResult, Box<dyn std::error::Error>> {
    let username = match user {
        Some(u) => {
            print!("{} login: {}\n", node, u);
            print!("{node} login: {u}\n");
            u.to_string()
        }
        None => loop {
            let username = prompt_stderr(&format!("{} login: ", node))?;
            let username = prompt_stderr(&format!("{node} login: "))?;
            if let Some(u) = username.strip_prefix('!') {
                *cmd = Some(u.to_string());
                eprintln!("Login command changed to: {u}");
@@ -94,11 +94,11 @@ fn login(
                    AuthMessageType::Visible => Some(prompt_stderr(&auth_message)?),
                    AuthMessageType::Secret => Some(prompt_password_stderr(&auth_message)?),
                    AuthMessageType::Info => {
                        eprintln!("info: {}", auth_message);
                        eprintln!("info: {auth_message}");
                        None
                    }
                    AuthMessageType::Error => {
                        eprintln!("error: {}", auth_message);
                        eprintln!("error: {auth_message}");
                        None
                    }
                };
@@ -127,9 +127,7 @@ fn login(
                Request::CancelSession.write_to(&mut stream)?;
                match error_type {
                    ErrorType::AuthError => return Ok(LoginResult::Failure),
                    ErrorType::Error => {
                        return Err(format!("login error: {:?}", description).into())
                    }
                    ErrorType::Error => return Err(format!("login error: {description:?}").into()),
                }
            }
        }
@@ -137,7 +135,7 @@ fn login(
}

fn print_usage(program: &str, opts: Options) {
    let brief = format!("Usage: {} [options]", program);
    let brief = format!("Usage: {program} [options]");
    print!("{}", opts.usage(&brief));
}

@@ -157,7 +155,7 @@ fn main() {
    let matches = match opts.parse(&args[1..]) {
        Ok(m) => m,
        Err(f) => {
            println!("{}", f);
            println!("{f}");
            print_usage(&program, opts);
            std::process::exit(1);
        }
@@ -171,7 +169,7 @@ fn main() {
    let max_failures: usize = match matches.opt_get("max-failures") {
        Ok(v) => v.unwrap_or(5),
        Err(e) => {
            eprintln!("unable to parse max failures: {}", e);
            eprintln!("unable to parse max failures: {e}");
            std::process::exit(1)
        }
    };
@@ -181,7 +179,7 @@ fn main() {
    };

    if let Ok(issue) = get_issue() {
        print!("{}", issue);
        print!("{issue}");
    }

    let uts = uname().unwrap();
@@ -190,7 +188,7 @@ fn main() {
            Ok(LoginResult::Success) => break,
            Ok(LoginResult::Failure) => eprintln!("Login incorrect\n"),
            Err(e) => {
                eprintln!("error: {}", e);
                eprintln!("error: {e}");
                std::process::exit(1);
            }
        }
diff --git a/fakegreet/src/error.rs b/fakegreet/src/error.rs
index 71feaa5..e790a0b 100644
--- a/fakegreet/src/error.rs
+++ b/fakegreet/src/error.rs
@@ -23,13 +23,13 @@ pub enum Error {

impl From<Box<dyn std::error::Error>> for Error {
    fn from(error: Box<dyn std::error::Error>) -> Self {
        Error::Error(format!("{}", error))
        Error::Error(error.to_string())
    }
}

impl From<std::io::Error> for Error {
    fn from(error: std::io::Error) -> Self {
        Error::Io(format!("{}", error))
        Error::Io(error.to_string())
    }
}

diff --git a/fakegreet/src/main.rs b/fakegreet/src/main.rs
index 6ce4708..a146790 100644
--- a/fakegreet/src/main.rs
+++ b/fakegreet/src/main.rs
@@ -24,7 +24,7 @@ fn wrap_result<T>(res: Result<T, Error>) -> Response {
        },
        Err(e) => Response::Error {
            error_type: ErrorType::Error,
            description: format!("{}", e),
            description: e.to_string(),
        },
    }
}
@@ -125,7 +125,7 @@ async fn client_handler(ctx: &Context, mut s: UnixStream) -> Result<(), Error> {
            Err(e) => return Err(e.into()),
        };

        println!("req: {:?}", req);
        println!("req: {req:?}");
        let resp = match req {
            Request::CreateSession { username } => match ctx.create_session(username).await {
                Ok(()) => client_get_question(ctx).await,
@@ -145,7 +145,7 @@ async fn client_handler(ctx: &Context, mut s: UnixStream) -> Result<(), Error> {
            ctx.cancel().await?;
        }

        println!("resp: {:?}", resp);
        println!("resp: {resp:?}");
        resp.write_to(&mut s).await?;
    }
}
@@ -162,7 +162,7 @@ pub async fn server() -> Result<(), Error> {

    let _ = std::fs::remove_file(&path);
    let listener =
        UnixListener::bind(&path).map_err(|e| format!("unable to open listener: {}", e))?;
        UnixListener::bind(&path).map_err(|e| format!("unable to open listener: {e}"))?;

    let arg = env::args().nth(1).expect("need argument");
    let _ = Command::new("sh").arg("-c").arg(arg).spawn()?;
@@ -175,11 +175,11 @@ pub async fn server() -> Result<(), Error> {
                let ctx = ctx.clone();
                task::spawn_local(async move {
                    if let Err(e) = client_handler(&ctx, stream).await {
                        eprintln!("client loop failed: {}", e);
                        eprintln!("client loop failed: {e}");
                    }
                });
            }
            Err(err) => return Err(format!("accept: {}", err).into()),
            Err(err) => return Err(format!("accept: {err}").into()),
        }
    }
}
@@ -190,6 +190,6 @@ async fn main() {
        .run_until(async move { server().await })
        .await;
    if let Err(e) = res {
        eprintln!("error: {}", e);
        eprintln!("error: {e}");
    }
}
diff --git a/greetd/src/config/mod.rs b/greetd/src/config/mod.rs
index 2d1d645..58fb1af 100644
--- a/greetd/src/config/mod.rs
+++ b/greetd/src/config/mod.rs
@@ -29,7 +29,7 @@ impl FromStr for VtSelection {
            v => v
                .parse()
                .map(VtSelection::Specific)
                .map_err(|e| format!("could not parse vt number: {}", e)),
                .map_err(|e| format!("could not parse vt number: {e}")),
        }
    }
}
@@ -84,14 +84,14 @@ pub struct Config {
}

fn print_usage(program: &str, opts: Options) {
    let brief = format!("Usage: {} [options]", program);
    let brief = format!("Usage: {program} [options]");
    println!("{}", opts.usage(&brief));
    println!("For more details, see greetd(1).");
}

fn maybe_unquote(s: &str) -> Result<String, Error> {
    Ok(match s.chars().next() {
        Some('"') | Some('\'') => unquote(s).map_err(|e| Error::ConfigError(format!("{}", e)))?,
        Some('"') | Some('\'') => unquote(s).map_err(|e| Error::ConfigError(e.to_string()))?,
        _ => s.to_string(),
    })
}
@@ -102,18 +102,18 @@ fn parse_config(config_str: &str) -> Result<ConfigFile, Error> {
        Some(section) => {
            let runfilestr = section.get("runfile").unwrap_or(&RUNFILE);
            let runfile = maybe_unquote(runfilestr)
                .map_err(|e| format!("unable to read general.runfile: {}", e))?;
                .map_err(|e| format!("unable to read general.runfile: {e}"))?;

            let servicestr = section.get("service").unwrap_or(&GENERAL_SERVICE);
            let service = maybe_unquote(servicestr)
                .map_err(|e| format!("unable to read general.service: {}", e))?;
                .map_err(|e| format!("unable to read general.service: {e}"))?;

            ConfigGeneral {
                source_profile: section
                    .get("source_profile")
                    .unwrap_or(&"true")
                    .parse()
                    .map_err(|e| format!("could not parse source_profile: {}", e))?,
                    .map_err(|e| format!("could not parse source_profile: {e}"))?,
                runfile,
                service,
            }
@@ -128,15 +128,15 @@ fn parse_config(config_str: &str) -> Result<ConfigFile, Error> {
                .get("command")
                .ok_or("default_session contains no command")?;
            let command = maybe_unquote(commandstr)
                .map_err(|e| format!("unable to read default_session.command: {}", e))?;
                .map_err(|e| format!("unable to read default_session.command: {e}"))?;

            let userstr = section.get("user").unwrap_or(&"greeter");
            let user = maybe_unquote(userstr)
                .map_err(|e| format!("unable to read default_session.user: {}", e))?;
                .map_err(|e| format!("unable to read default_session.user: {e}"))?;

            let servicestr = section.get("service").unwrap_or(&GREETER_SERVICE);
            let service = maybe_unquote(servicestr)
                .map_err(|e| format!("unable to read default_session.service: {}", e))?;
                .map_err(|e| format!("unable to read default_session.service: {e}"))?;

            Ok(ConfigSession {
                command,
@@ -153,18 +153,18 @@ fn parse_config(config_str: &str) -> Result<ConfigFile, Error> {
                .get("command")
                .ok_or("initial_session contains no command")?;
            let command = maybe_unquote(commandstr)
                .map_err(|e| format!("unable to read initial_session.command: {}", e))?;
                .map_err(|e| format!("unable to read initial_session.command: {e}"))?;

            let userstr = section
                .get("user")
                .ok_or("initial_session contains no user")?;
            let user = maybe_unquote(userstr)
                .map_err(|e| format!("unable to read initial_session.user: {}", e))?;
                .map_err(|e| format!("unable to read initial_session.user: {e}"))?;

            let generalservicestr = general.service.as_str();
            let servicestr = section.get("service").unwrap_or(&generalservicestr);
            let service = maybe_unquote(servicestr)
                .map_err(|e| format!("unable to read initial_session.service: {}", e))?;
                .map_err(|e| format!("unable to read initial_session.service: {e}"))?;

            Some(ConfigSession {
                command,
@@ -178,14 +178,14 @@ fn parse_config(config_str: &str) -> Result<ConfigFile, Error> {
    let terminal = match config.get("terminal") {
        Some(section) => Ok(ConfigTerminal {
            vt: maybe_unquote(section.get("vt").ok_or("VT not specified")?)
                .map_err(|e| format!("unable to read terminal.vt: {}", e))?
                .map_err(|e| format!("unable to read terminal.vt: {e}"))?
                .as_str()
                .parse()?,
            switch: section
                .get("switch")
                .unwrap_or(&"true")
                .parse()
                .map_err(|e| format!("could not parse switch: {}", e))?,
                .map_err(|e| format!("could not parse switch: {e}"))?,
        }),
        None => Err("no terminal specified"),
    }?;
@@ -214,7 +214,7 @@ pub fn read_config() -> Result<Config, Error> {
    );
    let matches = match opts.parse(&args[1..]) {
        Ok(m) => m,
        Err(f) => return Err(format!("could not parse arguments: {}", f).into()),
        Err(f) => return Err(format!("could not parse arguments: {f}").into()),
    };
    if matches.opt_present("h") {
        print_usage(&program, opts);
diff --git a/greetd/src/context.rs b/greetd/src/context.rs
index 6bd4d82..3a3824c 100644
--- a/greetd/src/context.rs
+++ b/greetd/src/context.rs
@@ -104,7 +104,7 @@ impl Context {
            match scheduled_session.get_state().await {
                Ok(SessionState::Ready) => break,
                Ok(SessionState::Question(_, _)) => scheduled_session.post_response(None).await?,
                Err(err) => return Err(format!("session start failed: {}", err).into()),
                Err(err) => return Err(format!("session start failed: {err}").into()),
            }
        }

@@ -151,7 +151,7 @@ impl Context {
    /// Create runfile used to check if greetd was already started since boot
    pub fn create_runfile(&self) {
        if let Err(err) = File::create(&self.runfile) {
            eprintln!("could not create runfile: {}", err);
            eprintln!("could not create runfile: {err}");
        }
    }

@@ -320,7 +320,7 @@ impl Context {
            drop(inner);
            let s = match p.session.start().await {
                Ok(s) => s,
                Err(e) => return Err(format!("session start failed: {}", e).into()),
                Err(e) => return Err(format!("session start failed: {e}").into()),
            };
            let mut inner = self.inner.write().await;
            inner.current = Some(SessionChildSet {
@@ -360,7 +360,7 @@ impl Context {
                            drop(inner);
                            let s = match scheduled.session.start().await {
                                Ok(s) => s,
                                Err(e) => return Err(format!("session start failed: {}", e).into()),
                                Err(e) => return Err(format!("session start failed: {e}").into()),
                            };
                            let mut inner = self.inner.write().await;
                            inner.current = Some(SessionChildSet {
diff --git a/greetd/src/error.rs b/greetd/src/error.rs
index 68aa07c..ada3782 100644
--- a/greetd/src/error.rs
+++ b/greetd/src/error.rs
@@ -23,13 +23,13 @@ pub enum Error {

impl From<Box<dyn std::error::Error>> for Error {
    fn from(error: Box<dyn std::error::Error>) -> Self {
        Error::Error(format!("{}", error))
        Error::Error(error.to_string())
    }
}

impl From<std::io::Error> for Error {
    fn from(error: std::io::Error) -> Self {
        Error::Io(format!("{}", error))
        Error::Io(error.to_string())
    }
}

diff --git a/greetd/src/main.rs b/greetd/src/main.rs
index 92a53d4..e66fdf1 100644
--- a/greetd/src/main.rs
+++ b/greetd/src/main.rs
@@ -34,12 +34,12 @@ async fn main() {
    let config = match config::read_config() {
        Ok(config) => config,
        Err(e) => {
            eprintln!("{}", e);
            eprintln!("{e}");
            std::process::exit(1);
        }
    };
    if cfg!(feature = "debug") {
        eprintln!("config: {:?}", config);
        eprintln!("config: {config:?}");
    }
    mlockall(MlockAllFlags::all()).expect("unable to lock pages");
    let res = task::LocalSet::new()
@@ -52,6 +52,6 @@ async fn main() {
        })
        .await;
    if let Err(e) = res {
        eprintln!("error: {}", e);
        eprintln!("error: {e}");
    }
}
diff --git a/greetd/src/pam/mod.rs b/greetd/src/pam/mod.rs
index 7c7d7ca..6c72c7d 100644
--- a/greetd/src/pam/mod.rs
+++ b/greetd/src/pam/mod.rs
@@ -20,7 +20,7 @@ pub enum PamError {
impl PamError {
    pub fn from_rc(prefix: &str, rc: PamReturnCode) -> PamError {
        match rc {
            PamReturnCode::ABORT => PamError::AbortError(format!("{}: {:?}", prefix, rc)),
            PamReturnCode::ABORT => PamError::AbortError(format!("{prefix}: {rc:?}")),
            PamReturnCode::AUTH_ERR
            | PamReturnCode::MAXTRIES
            | PamReturnCode::CRED_EXPIRED
@@ -28,8 +28,8 @@ impl PamError {
            | PamReturnCode::CRED_INSUFFICIENT
            | PamReturnCode::USER_UNKNOWN
            | PamReturnCode::PERM_DENIED
            | PamReturnCode::SERVICE_ERR => PamError::AuthError(format!("{}: {:?}", prefix, rc)),
            _ => PamError::Error(format!("{}: {:?}", prefix, rc)),
            | PamReturnCode::SERVICE_ERR => PamError::AuthError(format!("{prefix}: {rc:?}")),
            _ => PamError::Error(format!("{prefix}: {rc:?}")),
        }
    }
}
diff --git a/greetd/src/server.rs b/greetd/src/server.rs
index b215c4a..b3aac27 100644
--- a/greetd/src/server.rs
+++ b/greetd/src/server.rs
@@ -51,7 +51,7 @@ fn wrap_result<T>(res: Result<T, Error>) -> Response {
        },
        Err(e) => Response::Error {
            error_type: ErrorType::Error,
            description: format!("{}", e),
            description: e.to_string(),
        },
    }
}
@@ -121,7 +121,7 @@ fn get_tty(config: &Config) -> Result<TerminalMode, Error> {
                {
                    let vt = term_name[TTY_PREFIX.len()..]
                        .parse()
                        .map_err(|e| Error::Error(format!("unable to parse tty number: {}", e)))?;
                        .map_err(|e| Error::Error(format!("unable to parse tty number: {e}")))?;

                    TerminalMode::Terminal {
                        path: term_name,
@@ -135,12 +135,12 @@ fn get_tty(config: &Config) -> Result<TerminalMode, Error> {
                // We don't have a usable terminal, so we have to jump through some hoops
                _ => {
                    let sys_term = Terminal::open("/dev/tty0")
                        .map_err(|e| format!("unable to open terminal: {}", e))?;
                        .map_err(|e| format!("unable to open terminal: {e}"))?;
                    let vt = sys_term
                        .vt_get_current()
                        .map_err(|e| format!("unable to get current VT: {}", e))?;
                        .map_err(|e| format!("unable to get current VT: {e}"))?;
                    TerminalMode::Terminal {
                        path: format!("/dev/tty{}", vt),
                        path: format!("/dev/tty{vt}"),
                        vt,
                        switch: false,
                    }
@@ -148,20 +148,20 @@ fn get_tty(config: &Config) -> Result<TerminalMode, Error> {
            }
        }
        VtSelection::Next => {
            let term = Terminal::open("/dev/tty0")
                .map_err(|e| format!("unable to open terminal: {}", e))?;
            let term =
                Terminal::open("/dev/tty0").map_err(|e| format!("unable to open terminal: {e}"))?;
            let vt = term
                .vt_get_next()
                .map_err(|e| format!("unable to get next VT: {}", e))?;
                .map_err(|e| format!("unable to get next VT: {e}"))?;
            TerminalMode::Terminal {
                path: format!("/dev/tty{}", vt),
                path: format!("/dev/tty{vt}"),
                vt,
                switch: config.file.terminal.switch,
            }
        }
        VtSelection::None => TerminalMode::Stdin,
        VtSelection::Specific(vt) => TerminalMode::Terminal {
            path: format!("/dev/tty{}", vt),
            path: format!("/dev/tty{vt}"),
            vt,
            switch: config.file.terminal.switch,
        },
@@ -178,9 +178,9 @@ impl Listener {
        let path = format!("/run/greetd-{}.sock", getpid().as_raw());
        let _ = std::fs::remove_file(&path);
        let listener =
            UnixListener::bind(&path).map_err(|e| format!("unable to open listener: {}", e))?;
            UnixListener::bind(&path).map_err(|e| format!("unable to open listener: {e}"))?;
        chown(path.as_str(), Some(uid), Some(gid))
            .map_err(|e| format!("unable to chown greetd socket at {}: {}", path, e))?;
            .map_err(|e| format!("unable to chown greetd socket at {path}: {e}"))?;
        Ok((path, Listener(listener)))
    }
}
@@ -234,7 +234,7 @@ pub async fn main(config: Config) -> Result<(), Error> {
    let term_mode = get_tty(&config)?;

    if !config.file.terminal.switch {
        wait_vt(&term_mode).map_err(|e| format!("unable to wait VT: {}", e))?;
        wait_vt(&term_mode).map_err(|e| format!("unable to wait VT: {e}"))?;
    }

    let ctx = Rc::new(Context::new(
@@ -250,14 +250,14 @@ pub async fn main(config: Config) -> Result<(), Error> {

    if let (Some(s), true) = (config.file.initial_session, ctx.is_first_run()) {
        if let Err(e) = ctx.start_user_session(&s.user, vec![s.command]).await {
            eprintln!("unable to start greeter: {}", e);
            reset_vt(&term_mode).map_err(|e| format!("unable to reset VT: {}", e))?;
            eprintln!("unable to start greeter: {e}");
            reset_vt(&term_mode).map_err(|e| format!("unable to reset VT: {e}"))?;

            std::process::exit(1);
        }
    } else if let Err(e) = ctx.greet().await {
        eprintln!("unable to start greeter: {}", e);
        reset_vt(&term_mode).map_err(|e| format!("unable to reset VT: {}", e))?;
        eprintln!("unable to start greeter: {e}");
        reset_vt(&term_mode).map_err(|e| format!("unable to reset VT: {e}"))?;

        std::process::exit(1);
    }
@@ -271,14 +271,14 @@ pub async fn main(config: Config) -> Result<(), Error> {

    loop {
        tokio::select! {
            _ = child.recv() => ctx.check_children().await.map_err(|e| format!("check_children: {}", e))?,
            _ = alarm.recv() => ctx.alarm().await.map_err(|e| format!("alarm: {}", e))?,
            _ = child.recv() => ctx.check_children().await.map_err(|e| format!("check_children: {e}"))?,
            _ = alarm.recv() => ctx.alarm().await.map_err(|e| format!("alarm: {e}"))?,
            _ = term.recv() => {
                ctx.terminate().await.map_err(|e| format!("terminate: {}", e))?;
                ctx.terminate().await.map_err(|e| format!("terminate: {e}"))?;
                break;
            }
            _ = int.recv() => {
                ctx.terminate().await.map_err(|e| format!("terminate: {}", e))?;
                ctx.terminate().await.map_err(|e| format!("terminate: {e}"))?;
                break;
            }
            stream = listener.0.accept() => match stream {
@@ -287,11 +287,11 @@ pub async fn main(config: Config) -> Result<(), Error> {
                    task::spawn_local(async move {
                        if let Err(e) = client_handler(&client_ctx, stream).await {
                            client_ctx.cancel().await.expect("unable to cancel session");
                            eprintln!("client loop failed: {}", e);
                            eprintln!("client loop failed: {e}");
                        }
                    });
                },
                Err(err) => return Err(format!("accept: {}", err).into()),
                Err(err) => return Err(format!("accept: {err}").into()),
            }
        }
    }
diff --git a/greetd/src/session/conv.rs b/greetd/src/session/conv.rs
index 8560d65..7b67b93 100644
--- a/greetd/src/session/conv.rs
+++ b/greetd/src/session/conv.rs
@@ -15,10 +15,10 @@ impl<'a> SessionConv<'a> {
            msg: msg.to_string(),
        };
        msg.send(self.sock)
            .map_err(|e| eprintln!("pam_conv: {}", e))?;
            .map_err(|e| eprintln!("pam_conv: {e}"))?;

        let msg = ParentToSessionChild::recv(self.sock, &mut data)
            .map_err(|e| eprintln!("pam_conv: {}", e))?;
            .map_err(|e| eprintln!("pam_conv: {e}"))?;

        match msg {
            ParentToSessionChild::PamResponse { resp, .. } => Ok(resp),
diff --git a/greetd/src/session/interface.rs b/greetd/src/session/interface.rs
index 7e6c502..188c75c 100644
--- a/greetd/src/session/interface.rs
+++ b/greetd/src/session/interface.rs
@@ -32,10 +32,10 @@ trait AsyncSend {
impl<'a> AsyncSend for ParentToSessionChild<'a> {
    async fn send(&self, sock: &mut TokioUnixDatagram) -> Result<(), Error> {
        let mut out =
            serde_json::to_vec(self).map_err(|e| format!("unable to serialize message: {}", e))?;
            serde_json::to_vec(self).map_err(|e| format!("unable to serialize message: {e}"))?;
        sock.send(&out)
            .await
            .map_err(|e| format!("unable to send message: {}", e))?;
            .map_err(|e| format!("unable to send message: {e}"))?;
        out.scramble();
        Ok(())
    }
@@ -48,9 +48,9 @@ impl AsyncRecv<SessionChildToParent> for SessionChildToParent {
        let len = sock
            .recv(&mut data[..])
            .await
            .map_err(|e| format!("unable to recieve message: {}", e))?;
            .map_err(|e| format!("unable to recieve message: {e}"))?;
        let msg = serde_json::from_slice(&data[..len])
            .map_err(|e| format!("unable to deserialize message: {}", e))?;
            .map_err(|e| format!("unable to deserialize message: {e}"))?;
        Ok(msg)
    }
}
@@ -97,7 +97,7 @@ impl Session {
    pub fn new_external() -> Result<Session, Error> {
        // Pipe used to communicate the true PID of the final child.
        let (parentfd, childfd) =
            UnixDatagram::pair().map_err(|e| format!("could not create pipe: {}", e))?;
            UnixDatagram::pair().map_err(|e| format!("could not create pipe: {e}"))?;

        let raw_child = childfd.as_raw_fd();
        let mut cur_flags = FdFlag::from_bits_retain(fcntl(raw_child, FcntlArg::F_GETFD)?);
@@ -107,7 +107,7 @@ impl Session {
        let cur_exe = std::env::current_exe()?;
        let bin = CString::new(cur_exe.to_str().expect("unable to get current exe name"))?;

        let child = match unsafe { fork() }.map_err(|e| format!("unable to fork: {}", e))? {
        let child = match unsafe { fork() }.map_err(|e| format!("unable to fork: {e}"))? {
            ForkResult::Parent { child, .. } => child,
            ForkResult::Child => {
                execv(
diff --git a/greetd/src/session/worker.rs b/greetd/src/session/worker.rs
index 71c9d10..5c145bd 100644
--- a/greetd/src/session/worker.rs
+++ b/greetd/src/session/worker.rs
@@ -120,7 +120,7 @@ fn worker(sock: &UnixDatagram) -> Result<(), Error> {
                listener_path,
            ),
            ParentToSessionChild::Cancel => return Err("cancelled".into()),
            msg => return Err(format!("expected InitiateLogin or Cancel, got: {:?}", msg).into()),
            msg => return Err(format!("expected InitiateLogin or Cancel, got: {msg:?}").into()),
        };

    let conv = Box::pin(SessionConv::new(sock));
@@ -147,7 +147,7 @@ fn worker(sock: &UnixDatagram) -> Result<(), Error> {
    let (env, cmd) = match ParentToSessionChild::recv(sock, &mut data)? {
        ParentToSessionChild::Args { env, cmd } => (env, cmd),
        ParentToSessionChild::Cancel => return Err("cancelled".into()),
        msg => return Err(format!("expected Args or Cancel, got: {:?}", msg).into()),
        msg => return Err(format!("expected Args or Cancel, got: {msg:?}").into()),
    };

    SessionChildToParent::Success.send(sock)?;
@@ -156,7 +156,7 @@ fn worker(sock: &UnixDatagram) -> Result<(), Error> {
    match ParentToSessionChild::recv(sock, &mut data)? {
        ParentToSessionChild::Start => (),
        ParentToSessionChild::Cancel => return Err("cancelled".into()),
        msg => return Err(format!("expected Start or Cancel, got: {:?}", msg).into()),
        msg => return Err(format!("expected Start or Cancel, got: {msg:?}").into()),
    };

    let pam_username = pam.get_user()?;
@@ -164,14 +164,14 @@ fn worker(sock: &UnixDatagram) -> Result<(), Error> {
    let user = nix::unistd::User::from_name(&pam_username)?.ok_or("unable to get user info")?;

    // Make this process a session leader.
    setsid().map_err(|e| format!("unable to become session leader: {}", e))?;
    setsid().map_err(|e| format!("unable to become session leader: {e}"))?;

    match tty {
        TerminalMode::Stdin => (),
        TerminalMode::Terminal { path, vt, switch } => {
            // Tell PAM what TTY we're targetting, which is used by logind.
            pam.set_item(PamItemType::TTY, &format!("tty{}", vt))?;
            pam.putenv(&format!("XDG_VTNR={}", vt))?;
            pam.set_item(PamItemType::TTY, &format!("tty{vt}"))?;
            pam.putenv(&format!("XDG_VTNR={vt}"))?;

            // Opening our target terminal.
            let target_term = terminal::Terminal::open(&path)?;
@@ -242,7 +242,7 @@ fn worker(sock: &UnixDatagram) -> Result<(), Error> {
    // PAM is weird and gets upset if you exec from the process that opened
    // the session, registering it automatically as a log-out. Thus, we must
    // exec in a new child.
    let child = match unsafe { fork() }.map_err(|e| format!("unable to fork: {}", e))? {
    let child = match unsafe { fork() }.map_err(|e| format!("unable to fork: {e}"))? {
        ForkResult::Parent { child, .. } => child,
        ForkResult::Child => {
            // It is important that we do *not* return from here by
@@ -260,7 +260,7 @@ fn worker(sock: &UnixDatagram) -> Result<(), Error> {

            // Change working directory
            if let Err(e) = env::set_current_dir(user.dir) {
                eprintln!("unable to set working directory: {}", e);
                eprintln!("unable to set working directory: {e}");
            }

            // Run
@@ -293,7 +293,7 @@ fn worker(sock: &UnixDatagram) -> Result<(), Error> {
        match waitpid(child, None) {
            Err(nix::errno::Errno::EINTR) => continue,
            Err(e) => {
                eprintln!("session: waitpid on inner child failed: {}", e);
                eprintln!("session: waitpid on inner child failed: {e}");
                break;
            }
            Ok(_) => break,
diff --git a/greetd/src/terminal/mod.rs b/greetd/src/terminal/mod.rs
index 987f6cc..4254fec 100644
--- a/greetd/src/terminal/mod.rs
+++ b/greetd/src/terminal/mod.rs
@@ -50,9 +50,9 @@ fn ttyname_r(fd: RawFd) -> Result<String, Error> {
    }
    let len = unsafe { libc::strnlen(&arr[0] as *const u8 as *const libc::c_char, 31) };
    let s = CStr::from_bytes_with_nul(&arr[..len + 1])
        .map_err(|e| Error::Error(format!("ttyname_r result conversion failed: {}", e)))?;
        .map_err(|e| Error::Error(format!("ttyname_r result conversion failed: {e}")))?;
    Ok(s.to_str()
        .map_err(|e| Error::Error(format!("ttyname_r result conversion failed: {}", e)))?
        .map_err(|e| Error::Error(format!("ttyname_r result conversion failed: {e}")))?
        .to_string())
}

@@ -69,7 +69,7 @@ impl Terminal {
                fd,
                autoclose: true,
            }),
            Err(e) => return Err(format!("terminal: unable to open: {}", e).into()),
            Err(e) => return Err(format!("terminal: unable to open: {e}").into()),
        }
    }

@@ -94,7 +94,7 @@ impl Terminal {
        let ret = unsafe { ioctl::kd_setmode(self.fd, mode) };

        if let Err(v) = ret {
            Err(format!("terminal: unable to set kernel display mode: {}", v).into())
            Err(format!("terminal: unable to set kernel display mode: {v}").into())
        } else {
            Ok(())
        }
@@ -103,10 +103,10 @@ impl Terminal {
    /// Switches to the specified VT and waits for completion of switch.
    fn vt_activate(&self, target_vt: usize) -> Result<(), Error> {
        if let Err(v) = unsafe { ioctl::vt_activate(self.fd, target_vt as i32) } {
            return Err(format!("terminal: unable to activate: {}", v).into());
            return Err(format!("terminal: unable to activate: {v}").into());
        }
        if let Err(v) = unsafe { ioctl::vt_waitactive(self.fd, target_vt as i32) } {
            return Err(format!("terminal: unable to wait for activation: {}", v).into());
            return Err(format!("terminal: unable to wait for activation: {v}").into());
        }
        Ok(())
    }
@@ -114,7 +114,7 @@ impl Terminal {
    /// Waits for specified VT to become active.
    pub fn vt_waitactive(&self, target_vt: usize) -> Result<(), Error> {
        if let Err(v) = unsafe { ioctl::vt_waitactive(self.fd, target_vt as i32) } {
            return Err(format!("terminal: unable to wait for activation: {}", v).into());
            return Err(format!("terminal: unable to wait for activation: {v}").into());
        }
        Ok(())
    }
@@ -131,7 +131,7 @@ impl Terminal {
        let res = unsafe { ioctl::vt_setmode(self.fd, &mode) };

        if let Err(v) = res {
            Err(format!("terminal: unable to set vt mode: {}", v).into())
            Err(format!("terminal: unable to set vt mode: {v}").into())
        } else {
            Ok(())
        }
@@ -155,10 +155,10 @@ impl Terminal {
                },
            };
            if let Err(v) = unsafe { ioctl::vt_setactivate(self.fd, &arg) } {
                return Err(format!("terminal: unable to setactivate: {}", v).into());
                return Err(format!("terminal: unable to setactivate: {v}").into());
            }
            if let Err(v) = unsafe { ioctl::vt_waitactive(self.fd, target_vt as i32) } {
                return Err(format!("terminal: unable to wait for activation: {}", v).into());
                return Err(format!("terminal: unable to wait for activation: {v}").into());
            }
        } else {
            self.vt_mode_clean()?;
@@ -177,7 +177,7 @@ impl Terminal {
        let res = unsafe { ioctl::vt_getstate(self.fd, &mut state as *mut ioctl::vt_state) };

        if let Err(v) = res {
            Err(format!("terminal: unable to get current vt: {}", v).into())
            Err(format!("terminal: unable to get current vt: {v}").into())
        } else if state.v_active < 1 {
            Err(format!("terminal: current vt invalid: {}", state.v_active).into())
        } else {
@@ -193,9 +193,9 @@ impl Terminal {
        let res = unsafe { ioctl::vt_openqry(self.fd, &mut next_vt as *mut i64) };

        if let Err(v) = res {
            Err(format!("terminal: unable to get next vt: {}", v).into())
            Err(format!("terminal: unable to get next vt: {v}").into())
        } else if next_vt < 1 {
            Err(format!("terminal: next vt invalid: {}", next_vt).into())
            Err(format!("terminal: next vt invalid: {next_vt}").into())
        } else {
            Ok(next_vt as usize)
        }
@@ -209,7 +209,7 @@ impl Terminal {
            .and_then(|_| dup2(self.fd, 2));

        if let Err(v) = res {
            Err(format!("terminal: unable to connect pipes: {}", v).into())
            Err(format!("terminal: unable to connect pipes: {v}").into())
        } else {
            Ok(())
        }
@@ -220,7 +220,7 @@ impl Terminal {
    pub fn term_clear(&self) -> Result<(), Error> {
        let res = write(self.fd, b"\x1B[H\x1B[2J");
        if let Err(v) = res {
            Err(format!("terminal: unable to clear: {}", v).into())
            Err(format!("terminal: unable to clear: {v}").into())
        } else {
            Ok(())
        }
@@ -231,7 +231,7 @@ impl Terminal {
        let res = unsafe { ioctl::term_tiocsctty(self.fd, 1) };

        match res {
            Err(e) => Err(format!("terminal: unable to take controlling terminal: {}", e).into()),
            Err(e) => Err(format!("terminal: unable to take controlling terminal: {e}").into()),
            Ok(_) => Ok(()),
        }
    }
diff --git a/greetd_ipc/src/codec/mod.rs b/greetd_ipc/src/codec/mod.rs
index beb37cc..4bdbf1d 100644
--- a/greetd_ipc/src/codec/mod.rs
+++ b/greetd_ipc/src/codec/mod.rs
@@ -30,7 +30,7 @@ impl From<serde_json::error::Error> for Error {

impl From<std::io::Error> for Error {
    fn from(error: std::io::Error) -> Self {
        Error::Io(format!("{}", error))
        Error::Io(error.to_string())
    }
}

diff --git a/inish/src/lib.rs b/inish/src/lib.rs
index 131c941..a75437e 100644
--- a/inish/src/lib.rs
+++ b/inish/src/lib.rs
@@ -34,11 +34,9 @@ pub fn parse<'a>(s: &'a str) -> Result<Inish<'a>, Box<dyn Error>> {
                current_section_name = line[1..len - 1].trim();
            }
            (Some('['), v) => {
                return Err(format!(
                    "expected Some(']') to terminate section name, but got {:?}",
                    v
                )
                .into());
                return Err(
                    format!("expected Some(']') to terminate section name, but got {v:?}",).into(),
                );
            }
            _ if line.is_empty() => continue,
            _ => {
-- 
2.48.1
Applied, thanks!