Various getopt nitpicks - #453
Closed
evelikov wants to merge 5 commits into
Closed
Conversation
Codecov Report❌ Patch coverage is
... and 10 files with indirect coverage changes 🚀 New features to boost your workflow:
|
evelikov
force-pushed
the
getopt
branch
2 times, most recently
from
August 3, 2026 20:50
11e9fe7 to
af7853f
Compare
Collaborator
Author
|
v2:
|
The struct option::flag is of type "int *", so we should be using NULL instead of 0. In addition, the sentinel entry can be left completely empty. With those in place, we can drop most of the clang-format notations. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
Pull the unistd.h for optind and adjust the loop to follow the in-documentation example. In addition, we don't need the unused idx. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
Was meaning to add a negative test or two to modinfo - where a invalid option is passed into the program - only to notice that the default will print the path, alongside the program name. While fixing that, I've decided to pimp-up the reporting to also show the help screen. Eg. from this: /usr/bin/insmod: unrecognized option '--versoin' ... to this insmod: ERROR: unrecognised option '--versoin' Usage: insmod [options] filename [module options] Options: -f, --force DANGEROUS: forces a module load, may cause data corruption and crash your machine. implies --force-modversion and --force-vermagic --force-modversion Ignore module's version --force-vermagic Ignore module's version magic -s, --syslog print to syslog, not stderr -v, --verbose enables more messages -V, --version show version -h, --help show this help Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
added 2 commits
August 5, 2026 09:07
Fix 47999f7 ("ci: Workaround alpine CI build") Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
lucasdemarchi
pushed a commit
that referenced
this pull request
Aug 5, 2026
The struct option::flag is of type "int *", so we should be using NULL instead of 0. In addition, the sentinel entry can be left completely empty. With those in place, we can drop most of the clang-format notations. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: #453 Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
lucasdemarchi
pushed a commit
that referenced
this pull request
Aug 5, 2026
Pull the unistd.h for optind and adjust the loop to follow the in-documentation example. In addition, we don't need the unused idx. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: #453 Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
lucasdemarchi
pushed a commit
that referenced
this pull request
Aug 5, 2026
Was meaning to add a negative test or two to modinfo - where a invalid option is passed into the program - only to notice that the default will print the path, alongside the program name. While fixing that, I've decided to pimp-up the reporting to also show the help screen. Eg. from this: /usr/bin/insmod: unrecognized option '--versoin' ... to this insmod: ERROR: unrecognised option '--versoin' Usage: insmod [options] filename [module options] Options: -f, --force DANGEROUS: forces a module load, may cause data corruption and crash your machine. implies --force-modversion and --force-vermagic --force-modversion Ignore module's version --force-vermagic Ignore module's version magic -s, --syslog print to syslog, not stderr -v, --verbose enables more messages -V, --version show version -h, --help show this help Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: #453 Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
Contributor
|
Applied, thanks |
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.
A small series that started off with "hey, let me add a test for modinfo --invalid" and ended up homogenising the getopt usage in-tree.