Skip to content

fix(bsd): make sockaddr_in zero fill portable to unsigned c_char targets - #49

Merged
vnt-dev merged 1 commit into
tun-rs:mainfrom
pkubaj:ppc-fix
Oct 9, 2026
Merged

vnt-dev merged 1 commit into
tun-rs:mainfrom
pkubaj:ppc-fix

Conversation

@pkubaj

@pkubaj pkubaj commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

The bindgen-generated BSD bindings declare sockaddr_in::sin_zero as
[c_char; 8], and c_char is u8 on aarch64, powerpc64, powerpc64le and
riscv64 (it is i8 only on x86 and on Apple arm64). The literal
[0i8; 8] in From<Ipv4Addr> for sockaddr_in therefore fails to type
check on every non-x86 BSD target:

error[E0308]: mismatched types
   --> src/unix_bsd/mod.rs:630:24
    |
630 |             sin_zero: [0i8; 8],
    |                        ^^^ expected `u8`, found `i8`

Let the element type be inferred from the field instead.

Seen building rayfish 0.5.3 on FreeBSD 15.1 powerpc64le with rustc 1.98.1.

Summary by CodeRabbit

  • Chores
    • Made an internal initialization detail more concise; there are no user-visible behavior changes.

The bindgen-generated BSD bindings declare sockaddr_in::sin_zero as
[c_char; 8], and c_char is u8 on aarch64, powerpc64, powerpc64le and
riscv64 (it is i8 only on x86 and on Apple arm64). The literal
`[0i8; 8]` in `From<Ipv4Addr> for sockaddr_in` therefore fails to type
check on every non-x86 BSD target:

    error[E0308]: mismatched types
       --> src/unix_bsd/mod.rs:630:24
        |
    630 |             sin_zero: [0i8; 8],
        |                        ^^^ expected `u8`, found `i8`

Let the element type be inferred from the field instead.

Seen building rayfish 0.5.3 on FreeBSD 15.1 powerpc64le with rustc 1.98.1.
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fd5a73fb-b687-4df9-9d16-1d8487035a92
📥 Commits

Reviewing files that changed from the base of the PR and between da4a3cb and ad2af53.

📒 Files selected for processing (1)
  • src/unix_bsd/mod.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The IPv4 socket-address conversion now initializes sin_zero with an inferred zero-array type instead of an explicitly typed i8 array. No other behavior change is shown.

Changes

IPv4 Socket Address

Layer / File(s) Summary
Zero-array initialization
src/unix_bsd/mod.rs
The conversion initializes sin_zero with [0; 8] instead of [0i8; 8].

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to ad2af

This change preserves the zero-filled socket-address field while allowing its element type to match the platform binding. No merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the change: making sockaddr_in zero-fill portable to targets with unsigned c_char.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@vnt-dev
vnt-dev merged commit 3dffdaa into tun-rs:main Oct 9, 2026
7 checks passed
@pkubaj
pkubaj deleted the ppc-fix branch October 9, 2026 09:31
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