fix: portable errno constants (ELOOP, ENOTEMPTY) + WRITE validation#210
Draft
Koan-Bot wants to merge 2 commits intocpanel:masterfrom
Draft
fix: portable errno constants (ELOOP, ENOTEMPTY) + WRITE validation#210Koan-Bot wants to merge 2 commits intocpanel:masterfrom
Koan-Bot wants to merge 2 commits intocpanel:masterfrom
Conversation
Contributor
|
View failures from CI pipeline |
Koan-Bot
added a commit
to atoomic/Test-MockFile
that referenced
this pull request
Feb 24, 2026
Contributor
Author
Rebase: fix: portable errno constants (ELOOP, ENOTEMPTY) + WRITE validationBranch Actions
Automated by Kōan |
atoomic
reviewed
Feb 24, 2026
|
|
||
| unless ( $len =~ m/^-?[0-9.]+$/ ) { | ||
| $! = qq{Argument "$len" isn't numeric in syswrite at ??}; | ||
| CORE::warn(qq{Argument "$len" isn't numeric in syswrite at @{[ join ' line ', (caller)[1,2] ]}.\n}); |
Replace hardcoded errno numbers with portable POSIX constants: - $! = 40 → $! = ELOOP in __sysopen (O_NOFOLLOW on symlink) - $! = 39 → $! = ENOTEMPTY in __rmdir (non-empty directory) These values differ across platforms (Linux ELOOP=40, macOS=62; Linux ENOTEMPTY=39, macOS=66), causing incorrect errno on non-Linux. Also fix FileHandle.pm WRITE method: - String assignments to $! replaced with proper warn/die - Negative length now dies (matches real syswrite behavior) - Offset outside string now dies (matches real syswrite) - Fix offset validation order: convert negative offset before bounds check (previously, too-negative offsets silently passed) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7deae76 to
e6b184b
Compare
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.
Summary
Errnoconstants:$! = 40→$! = ELOOPin__sysopen(O_NOFOLLOW on symlink)$! = 39→$! = ENOTEMPTYin__rmdir(non-empty directory)FileHandle::WRITEerror handling to match realsyswritebehavior:warninstead of assigning string to$!die(fatal, like real syswrite)die(fatal, like real syswrite)Motivation
Errno values differ across platforms:
Hardcoding Linux values means incorrect
$!on macOS/FreeBSD.The
WRITEmethod was assigning error message strings to$!, which is incorrect —$!expects a numeric errno or a system error string that maps to one. Realsyswriteuseswarn/diefor these error conditions.The offset validation bug meant
syswrite($fh, "hello", 2, -10)silently proceeded instead of dying with "Offset outside string" (offset -10 on a 5-char string is invalid).Test plan
t/portability_errno.twith 7 subtests covering ELOOP, ENOTEMPTY, and WRITE error casest/rmdir.tto useENOTEMPTYconstant instead of hardcoded39🤖 Generated with Claude Code