Repository navigation
Conversation
germ-mark
marked this pull request as draft
August 10, 2026 22:29
Bionic annotates the dst parameter as `char * _Nonnull`, so it imports as a non-optional pointer and the call fails to compile in an Android SDK build. Darwin, Glibc and WinSDK import it as optional. Hoisting the unwrap above the platform branches fixes both call sites and removes the existing force-unwrap further down, rather than adding another.
germ-mark
force-pushed
the
android-inet-ntop-nullability
branch
from
August 10, 2026 22:31
0791098 to
0c12cea
Compare
Author
|
Apologies, this was prematurely opened against upstream instead of our fork. But yes, we're trying to compile for Android SDK and ran into this |
Contributor
No problem, great to see growing support for Android. Let us know when it's ready for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
sys_inet_ntopdoes not compile when building for Android.Bionic annotates
inet_ntop'sdstparameter aschar * _Nonnull, so Swift imports itas a non-optional
UnsafeMutablePointer<Int8>. Darwin, Glibc and WinSDK leave itunannotated, so it imports as an optional and passing
baseAddressdirectly type-checksthere.
Building for
aarch64-unknown-linux-android28with the 6.3.3 Android Swift SDK:Modifications
Unwrap
addressBytesPtr.baseAddressonce with aguard, above the platform branches,and use the result in both.
This covers the Windows and POSIX calls with one unwrap and replaces the existing
baseAddress!further down, so the function ends up with fewer force-unwraps thanbefore rather than one more. It also removes the trap that unwrap represented: a
zero-
lengthbuffer previously would have crashed there, and now returnsnillike anyother failure.
Behaviour is otherwise unchanged — on platforms where
dstimports as optional, passinga non-optional pointer is the same call.
Result
The package builds for Android, and the function no longer force-unwraps at all.
Test Plan
swift buildandswift teston macOS — clean, 3 tests pass.swift-format lint --strictclean, andswift-format formatproduces no diff.aarch64-unknown-linux-android28(Swift 6.3.3 host toolchain,swift-6.3.3-RELEASE_android.artifactbundle, NDK r27d): fails with the error abovebefore this change, builds cleanly after it.
CI has no Android job, so nothing here exercises that path automatically — the change is
inert on every platform CI does cover.