Skip to content

Conversation

@codyps
Copy link
Owner

@codyps codyps commented Jul 17, 2025

No description provided.

@codyps codyps enabled auto-merge July 17, 2025 05:36
@codyps codyps requested a review from Copilot July 17, 2025 05:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a Nix flake development environment configuration and performs code improvements primarily focused on modernizing Rust code patterns. The changes include removing the deprecated sd_try! macro in favor of direct ffi_result calls and updating string formatting to use modern Rust syntax.

  • Adds Nix flake configuration for consistent development environment setup
  • Removes the deprecated sd_try! macro and replaces all usages with explicit ffi_result function calls
  • Updates string formatting from older format!("{}", var) syntax to modern format!("{var}") syntax

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
flake.nix Adds Nix flake configuration with Rust toolchain and systemd dependencies
.envrc Enables direnv integration with the Nix flake
src/lib.rs Removes the deprecated sd_try! macro definition
src/unit.rs Updates string formatting to modern syntax
src/login.rs Replaces sd_try! macro calls with ffi_result function calls
src/journal.rs Updates string formatting and replaces sd_try! macro usage
src/id128.rs Replaces sd_try! macro calls with ffi_result function calls
src/daemon.rs Replaces sd_try! macro calls with ffi_result function calls
src/bus/types.rs Removes unnecessary lifetime parameters from trait implementations
src/bus/mod.rs Replaces sd_try! macro calls with ffi_result function calls

src/id128.rs Outdated
pub fn from_cstr(s: &CStr) -> Result<Id128> {
let mut r = Id128::default();
sd_try!(ffi::id128::sd_id128_from_string(s.as_ptr(), &mut r.inner));
ffi_result(unsafe {ffi::id128::sd_id128_from_string(s.as_ptr(), &mut r.inner)})?;
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Missing space after opening brace in unsafe block. Should be unsafe { ffi::id128::sd_id128_from_string(s.as_ptr(), &mut r.inner) } for consistency with other unsafe blocks in the codebase.

Suggested change
ffi_result(unsafe {ffi::id128::sd_id128_from_string(s.as_ptr(), &mut r.inner)})?;
ffi_result(unsafe { ffi::id128::sd_id128_from_string(s.as_ptr(), &mut r.inner) })?;

Copilot uses AI. Check for mistakes.
src/id128.rs Outdated
pub fn from_random() -> Result<Id128> {
let mut r = Id128::default();
sd_try!(ffi::id128::sd_id128_randomize(&mut r.inner));
ffi_result(unsafe { ffi::id128::sd_id128_randomize(&mut r.inner)})?;
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Missing space before closing brace in unsafe block. Should be unsafe { ffi::id128::sd_id128_randomize(&mut r.inner) } for consistency with other unsafe blocks in the codebase.

Suggested change
ffi_result(unsafe { ffi::id128::sd_id128_randomize(&mut r.inner)})?;
ffi_result(unsafe { ffi::id128::sd_id128_randomize(&mut r.inner) })?;

Copilot uses AI. Check for mistakes.
src/id128.rs Outdated
pub fn from_machine() -> Result<Id128> {
let mut r = Id128::default();
sd_try!(ffi::id128::sd_id128_get_machine(&mut r.inner));
ffi_result(unsafe {ffi::id128::sd_id128_get_machine(&mut r.inner)})?;
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Missing space after opening brace in unsafe block. Should be unsafe { ffi::id128::sd_id128_get_machine(&mut r.inner) } for consistency with other unsafe blocks in the codebase.

Suggested change
ffi_result(unsafe {ffi::id128::sd_id128_get_machine(&mut r.inner)})?;
ffi_result(unsafe { ffi::id128::sd_id128_get_machine(&mut r.inner) })?;

Copilot uses AI. Check for mistakes.
src/id128.rs Outdated
pub fn from_boot() -> Result<Id128> {
let mut r = Id128::default();
sd_try!(ffi::id128::sd_id128_get_boot(&mut r.inner));
ffi_result(unsafe { ffi::id128::sd_id128_get_boot(&mut r.inner)})?;
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Missing space before closing brace in unsafe block. Should be unsafe { ffi::id128::sd_id128_get_boot(&mut r.inner) } for consistency with other unsafe blocks in the codebase.

Suggested change
ffi_result(unsafe { ffi::id128::sd_id128_get_boot(&mut r.inner)})?;
ffi_result(unsafe { ffi::id128::sd_id128_get_boot(&mut r.inner) })?;

Copilot uses AI. Check for mistakes.
src/daemon.rs Outdated
fn new(unset_environment: bool) -> Result<Self> {
// in order to use rust's locking of the environment, do the env var unsetting ourselves
let num_fds = sd_try!(ffi::sd_listen_fds(0));
let num_fds = ffi_result(unsafe {ffi::sd_listen_fds(0)})?;
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Missing space after opening brace in unsafe block. Should be unsafe { ffi::sd_listen_fds(0) } for consistency with other unsafe blocks in the codebase.

Suggested change
let num_fds = ffi_result(unsafe {ffi::sd_listen_fds(0)})?;
let num_fds = ffi_result(unsafe { ffi::sd_listen_fds(0) })?;

Copilot uses AI. Check for mistakes.
@codyps codyps merged commit c35b1dc into master Jul 17, 2025
5 checks passed
@codyps codyps deleted the fix-clippy branch July 17, 2025 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants