Repository navigation
[BUG] -t | -w suppress warning message, but help text is still shown (#312) - #374
Conversation
|
The following CI steps are failing at I am not able to see details of ./test-suite.log at https://app.circleci.com/pipelines/github/lsof-org/lsof/884/details?workflowId=8c9fec36-da21-4ac9-9914-68b5ef27c635. Nevertheless it passes in my local environment ( Maybe someone could support me to understand what is really failing at circleci (x86_64 vs. my aarch64 container??). |
There was a problem hiding this comment.
accidentally committed
There was a problem hiding this comment.
seems the repo's .gitignore ignores *.o, *.lo, etc., but not *.o.tmp, so libtool temp files can slip through. Maybe this also could be added to .gitignore?!
| "%s: -e not followed by a file system path: \"%s\"\n", | ||
| Pn, e); | ||
| return (1); | ||
| SoftErr = 1; return (1); |
There was a problem hiding this comment.
I prefer to change the return value, instead of using another global variable to express this difference, e.g. return (2).
There was a problem hiding this comment.
I see, nevertheless, 0 and 1 are the conventional success/failure returns that are used throughout lsof codebase, like read it as boolean. A bare 2 has no such convention, it is kind we need to guess what it means. I will take a look at this to make the solution more elegant, maybe using a 2 with a comment in the function header...
There was a problem hiding this comment.
In this case a full three-value enum ( OK , ERR , SOFT_ERR) would be cleaner, but the impact is huge. But 0 and 1 shall remain untouched and so I do agree that having the anonymous enum (e.g. SOFT_ERR = 2) is the compromise.
There was a problem hiding this comment.
I have replaced global SoftErr with enum { SOFT_ERR = 2 }, preserving existing 0/1 returns. Soft errors propagate through helpers without masking hard errors. Added regression tests.
Resolve the enter_efsys() conflict by keeping master's Readlink() cleanup (free(ec) and Readlink_op reset) and the PR's SoftErr marking.
Preserve hard-error precedence through argument helpers and keep warning-level failures local to argument processing. Add regression coverage for suppressed warnings, explicit help, option ordering, and mixed FD-list errors.
Summary
When
+D/+d(or other warning-guarded soft errors) targets a missing or invalid directory,enter_dir()returns failure and setserr, which unconditionally drivesusage()and prints the version/usage/help block. The-w/-tflags only setFwarn, suppressing the warning text but not the error-driven help text. ASoftErrflag now marks these warning-level failures; when warnings are suppressed (Fwarnset),main()exits silently with an error status instead of callingusage(), while normal (warnings-enabled) runs retain the existing warning + help output. Hard errors are unaffected and still show help text.Changes
src/arg.c: declareextern int SoftErr;and setSoftErr = 1on warning-guarded soft failures (enter_dir,enter_efsys,enter_fd_lst), with braces fixed on theReadlinkbranches.src/main.c: defineint SoftErr = 0;and, before callingusage(), callError(ctx)whenerr && Fwarn && SoftErrso suppressed soft errors exit silently.Verification
make-> build succeeds./lsof -w +D /test-> no output, exit 1./lsof -t +D /test-> no output, exit 1./lsof +D /test-> warning + help text preserved, exit 1./lsof -w -z-> hard error still shows help text, exit 1bash tests/case-20-exit-status.bash ...-> passbash tests/case-20-handle-missing-files.bash ...-> passRisks / Follow-ups
See CI failure description at #374 (comment)
This PR is AI Assisted.
Closes #312