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.
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
FlexMeter: Add FlexMeter functionality #1571
base: main
Are you sure you want to change the base?
FlexMeter: Add FlexMeter functionality #1571
Changes from all commits
be2fbbc
c337785
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Memory leak, if multiple lines with
name=
are provided.Similar below.
Have a look at
free_and_xStrdup
for the cases below.For the
xAsprintf
call site callingfree
onmeter->uiName
should suffice.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.
Note, that
fclose(NULL);
is undefined behaviour, usually characterized to crash your program. ;-)Doing it that way around also allows to lower the indentation level.
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.
Not strictly necessary. should best be removed.
For stack variables, calling
free
suffices. Only when the variable or its value is exposed to other scopes it's necessary to explicitly set the value toNULL
.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.
Note the comment by @Explorer09 regarding the
XDG_HOME_DIR
variable and fallbacks …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.
Is current
XDG_CONFIG_HOME
and fallbacks enough ?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.
getpwuid
has some bad side effects (calls to libpam and potentially causes network traffic; thus can potentially hang). Furthermore, when building htop with--enable-static
this may cause issues, thus call sites should be minimized.Not to mention the call can fail and is lacking error checks.
Please compare with
Settings_new
inSettings.c
. Possibly, we should refactor this code block to be a separate function. @Explorer09?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.
This allows for easy meter impersonation in the UI. IDK if this is a good thing to have …
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.
@BenBE can you please elaborate ?
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.
Given the unrestricted nature of how the
uiName
andcaption
are set, a FlexMeter could just configure to use the same strings as another (built-in) meter and thus impersonate another (e.g. built-in) meter. This is not a security issue directly, but more a point for discussion, if we want to allow the user to create FlexMeters that are indistinguishable from built-in meters.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.
Good point from @BenBE about meter impersonation. But since we have PCPDynamicMeter already, what would PCPDynamicMeter handle this situation?
I think @natoscott can come in and look at this whole PR and give a review.
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 think could be overcome with prefix or suffix to the
uiName
and for thecaption
it is matter of user decision what caption should be selected. It could be literally everythingThere 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.
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.
No, AFAIR not. But there is some code in
PCPDynamicColumn_validateColumnName
that does minimalistic filtering. Also there are checks to detect duplicate names.ACK.
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.
Flex:
prefix - okThere 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.
For
caption=
all*>=32
is fine. With just26<=c && c<=126
you cause two issues:caption=運勢
(when executingcommand=LANG=ja_JA fortune
)*Unicode filtering has its whole other can of worms … But that would apply to the output of command too …
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 didn't expect I would comment on Unicode filtering here. Do you guys plan to revise or improve the Unicode filtering code in
RichString
class?Here is a draft code of mine, just for reference.
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.
Only one of these (
METERS_LIST_SIZE
,MAX_METERS_COUNT
) should exist.Also, I'd suggest a slight rename:
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.
Keep the second blank after the list of includes.
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.
Space around binary operators:
Furthermore,
for
loops always should have a body; and be it empty.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.