-
-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move libcap use to (Linux) platform-specific code #564
Conversation
Follow up on the two items of feedback from cgzones review. Related to htop-dev#564
Follow up on the two items of feedback from cgzones review, and resolve a build failure picked up by CI on Mac OS X. Related to htop-dev#564
d43bf1c
to
b25e6b5
Compare
linux/Platform.h
Outdated
#define PLATFORM_LONG_OPTIONS_USAGE \ | ||
" --drop-capabilities[=none|basic|strict] Drop Linux capabilities when running as root\n" \ | ||
" none - do not drop any capabilities\n" \ | ||
" basic (default) - drop all capabilities not needed by htop\n" \ | ||
" strict - drop all capabilities except those needed for core functionality\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prone to format string issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess. Any better alternative you can suggest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One could split the printf()
call in htop.c:printHelpFlag()
into
printf("%s " VERSION "\n"
COPYRIGHT "\n"
"Released under the GNU GPLv2.\n\n"
"-C --no-color Use a monochrome color scheme\n"
...
"-V --version Print version info\n",
name);
Platform_printLongOptionsUsage(name);
printf("\n"
"Long options may be passed with a single dash.\n\n"
"Press F1 inside %s for online help.\n"
"See 'man %s' for more information.\n",
name, name);
but I am also fine with the current implementation, relying on -Wformat
to alert on format string issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cgzones nice - I like that, it's cleaner and more flexible. Will implement shortly and then merge, I think that's the last thing here.
htop.c
Outdated
"Press F1 inside %s for online help.\n" | ||
"See 'man %s' for more information.\n", | ||
name, name, name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use positional arguments here? Allows for re-use of the same argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good idea! Trying it out though, I get...
htop.c: In function ‘printHelpFlag’:
htop.c:64:10: warning: ISO C does not support %n$ operand number formats [-Wformat=]
64 | name);
| ^~~~
The libcap code is Linux-specific so move it all below the linux/ platform subdirectory. As this feature has custom command-line long options I provide a mechanism whereby each platform can add custom long options that augment the main htop options. We'll make use this of this with the pcp/ platform in due course to implement the --host and --archive options there. Related to htop-dev#536
Follow up on the two items of feedback from cgzones review, and resolve a build failure picked up by CI on Mac OS X. Related to htop-dev#564
0d8e563
to
253ff23
Compare
The libcap code is Linux-specific so move it all below
the linux/ platform subdirectory. As this feature has
custom command-line long options I provide a mechanism
whereby each platform can add custom long options that
augment the main htop options. We'll make use this of
this with the pcp/ platform in due course to implement
the --host and --archive options there.
Related to #536