Repository navigation
fix(extract): normalize stat.st_mode to libc::mode_t for 32-bit Android - #1328
Conversation
|
Warning Amazon Q Developer for GitHub: end of support On January 30, 2027, AWS will discontinue support for the Amazon Q Developer for GitHub App. New app installations will no longer be available starting November 18, 2026. For capabilities similar to the Amazon Q Developer for GitHub App, explore Kiro and the Kiro GitHub App. For more information about the end of support, see Amazon Q Developer end-of-support announcement on the AWS DevOps Blog. |
There was a problem hiding this comment.
The fix is correct and well-scoped. The new stat_mode helper function properly abstracts the st.st_mode as libc::mode_t narrowing cast needed on 32-bit Android targets (where libc::stat::st_mode is u32 but libc::mode_t is u16), and is a no-op on all other Unix platforms. All 9 call sites have been consistently updated, the #[allow(clippy::unnecessary_cast)] suppression is narrowly scoped with a clear comment, and the incidental return Ok(()) → Ok(()) cleanup is a valid clippy fix for the macOS/BSD branch.
No blocking issues found. The change is ready to merge.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
On 32-bit Android targets (such as armv7-linux-androideabi and i686-linux-android), libc defines libc::mode_t and the S_IF* constants as u16, while libc::stat::st_mode is c_uint (u32). This caused type mismatch errors when masking st_mode against S_IFMT / S_IF* and when passing derived directory modes from open_dir_beneath to libc::fchmod and libc::fchmodat. Add a stat_mode helper in src/read/extract.rs to normalize st.st_mode to libc::mode_t across all Unix call sites, and remove an unneeded return in the macOS/BSD branch of set_permissions_dirfd_entry flagged by clippy on macOS. Fixes zip-rs#1327
83e37f9 to
1a4f331
Compare
Fixes #1327
Problem
On 32-bit Android targets (
armv7-linux-androideabi,i686-linux-android, etc.),libcdefineslibc::mode_t(along withlibc::S_IFMT,S_IFREG,S_IFDIR, andS_IFLNK) asu16, whereaslibc::stat::st_modeisu32(c_uint).Because of this mismatch, building on 32-bit Android fails in
src/read/extract.rsat:open_dir_beneath, wheredesiredinheritsu32fromst.st_modeand is passed tolibc::fchmod/libc::fchmodatexpectingu16(*.st_mode & libc::S_IFMT) ==/!= libc::S_IF*checks (u32vsu16)Changes
const fn stat_mode(st: &libc::stat) -> libc::mode_thelper insrc/read/extract.rsand updated all 9st_modesites to go through it.returnin the macOS/BSD branch ofset_permissions_dirfd_entrythat triggeredclippy::needless_returnwhen checkingaarch64-apple-darwin.Testing
armv7-linux-androideabibefore the fix.cargo clippy --lib --no-default-features -- -D warningsafter the fix across 23 targets covering allmode_t/st_mode/ endianness / pointer-width combinations (armv7-linux-androideabi,i686-linux-android,aarch64-linux-android,armv7-unknown-linux-gnueabihf,armv7-unknown-linux-musleabihf,x86_64-unknown-linux-gnu,s390x-unknown-linux-gnu,powerpc-unknown-linux-gnu,aarch64-apple-darwin,aarch64-apple-ios,x86_64-unknown-freebsd,x86_64-unknown-netbsd,x86_64-pc-solaris,x86_64-unknown-illumos,x86_64-unknown-redox,x86_64-pc-windows-msvc,i686-pc-windows-msvc,aarch64-pc-windows-msvc,wasm32-unknown-unknown,wasm32-wasip1,wasm32-wasip2,wasm32-unknown-emscripten,x86_64-unknown-fuchsia).cargo fmt --all -- --checkandcargo test --lib --no-default-featureson Windows host.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.