| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The warning message is
"array subscript has type 'char' [-Wchar-subscripts]"
Fix this by casting to 'unsigned char' before passing any character to a
`<ctype.h>` function.
Also add an assertion to RichString_writeFromAscii() to ensure the
characters in the string are all in ASCII range.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
All uses of meter drawing "mode" numbers now have the type
`MeterModeId`, including the uses in structures and arrays.
`MeterModeId` is defined as `unsigned int`, as (currently) it doesn't
save any code size by defining it to any smaller type.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
It is inappropriate to use the 'fd' name for 'FILE*' variables.
POSIX file descriptiors are of type 'int' and are distinguished from
ISO C stream pointers (type 'FILE*').
Rename these variables to 'fp', which is a preferred naming in POSIX.
(Note that ISO C preferred the 'stream' name for the variables.)
No code changes.
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| | |
Settings_write() is called on a crash inside of a signal handler. Using
fprintf(3) is not safe to call ins signal handlers due to file buffering
and memory allocations.
Format messages in signal handlers via snprintf(3) and output them via
write(2) on crash.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Check whether the configuration file (after symlink resolution) is
writable and is a regular file on htop startup, and only then, write the
configuration on exit.
Also permit reading when the legacy configuration file ("~/.htoprc") is
a symlink. Write the new configuration only when both the legacy file
and the new location are writable.
Thanks to Christian Göttsche (@cgzones) for providing the initial
version of the patch.
Fixes: #1426
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
|/
|
|
|
|
|
| |
Fixes regression caused by 15b4bc45b2b0ccf2
Fixes: #1449
Co-authored-by: Kang-Che Sung <explorer09@gmail.com>
|
|
|
|
|
|
|
|
|
|
| |
Read htop configuration file in the modern location first
("~/.config/htop/htoprc") before trying the legacy location
("~/.htoprc"). This would prevent a case where configuration files exist
in both locations and the new configuration gets replaced by the old
one.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
|
| |
|
|
|
|
|
|
| |
Only use the environment variables HOME and XDG_CONFIG_HOME, or the home
directory from getpwuid(3) if they are absolute paths.
Avoid different behavior depending on the current working directory.
|
|
|
|
| |
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
|
|
|
|
|
|
|
|
| |
Some configuration systems might link a htop configuration file and we
don't really want to replace the symlink but rather its source. This
will also allow us to fail in case the source is read only.
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
|
|
|
| |
Co-authored-by: BenBE <BenBE@geshi.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Over in the PCP project, Coverity has spotted a couple of minor
issues in the htop code.
This commit addresses them:
Settings.c
need to take control of the umask before calling mkstemp()
pcp/Platform.c
Although Platform_getMaxPid() returns a pid_t (which
strictly speaking is signed), the value is used to call
Row_setPidColumnWidth() and a negative value here is not good
... using INT_MAX instead of UNIT_MAX on the (unlikely) error
path makes no practical difference but may keep Coverity quiet
|
|
|
|
|
|
|
|
|
| |
Compare the return value of sscanf(3) and fscanf(3) explicitly against
the expected number of parsed items and avoid implicit boolean
conversion. Such an implicit conversion would treat EOF (-1) the same
as at least one item parsed successfully.
Reported by CodeQL.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the user removes all meters from the header on exit htop will write
no values for the settings column_meters_X and column_meter_modes_X.
The parser skips all configuration settings with no value, so on the
next start no header meter related key is processed and htop will add a
set of default meters to the header.
Write instead an invalid value of `!`, so the keys are parsed and htop
will not add the default meters back.
Closes: #1248
|
| |
|
| |
|
|
|
|
|
|
| |
Many thanks to @Explorer09 Kang-Che Sung (宋岡哲).
Also add a #error stanza to XUtils.h in case somebody forgets the beautiful mess GNU forces on us.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently when the runtime configuration is saved to file the true
configuration file is first truncated and then written to with each
available option.
If for any reason htop dies (e.g. program crash, or system shutdown)
while still performing the output the configuration file might end up
empty or corrupted.
Write to a temporary file and rename at the end on success.
As a side effect new configuration files are now created with a mode of
0600.
|
|
|
|
|
|
| |
Coverity scanning shows a couple of locations where a NULL
pointer dereference could happen; updated code to ensure it
cannot.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This implements our concept of 'dynamic screens' in htop, with a
first use-case of pcp-htop displaying things like top-filesystem
and top-cgroups under new screen tabs. However the idea is more
general than use in pcp-htop and we've paved the way here for us
to collectively build mroe general tabular screens in core htop,
as well.
From the pcp-htop side of things, dynamic screens are configured
using text-based configuration files that define the mapping for
PCP metrics to columns (and metric instances to rows). Metrics
are defined either directly (via metric names) or indirectly via
PCP derived metric specifications. Value scaling and the units
displayed is automatic based on PCP metric units and data types.
This commit represents a collaborative effort of several months,
primarily between myself, Nathan and BenBE.
Signed-off-by: Sohaib Mohamed <sohaib.amhmd@gmail.com>
Signed-off-by: Nathan Scott <nathans@redhat.com>
|
|
|
|
|
|
|
|
|
| |
This commit refactors the Process and ProcessList structures such
they each have a new parent - Row and Table, respectively. These
new classes handle screen updates relating to anything that could
be represented in tabular format, e.g. cgroups, filesystems, etc,
without us having to reimplement the display logic repeatedly for
each new entity.
|
|
|
|
|
|
|
|
| |
This removes the duplication of dynamic meter/column hashtable
pointers that has come in between the Settings and ProcessList
structures - only one copy of these is needed. With the future
planned dynamic screens feature adding another pointer, let us
first clean this up before any further duplication happens.
|
|
|
|
|
|
|
|
|
| |
Shadow path prefixes which are used by distributions, like
/usr/bin/
/usr/sbin/
/bin/
/sbin/
/usr/libexec/
|
|
|
|
|
|
|
| |
Skip over invalid process columns, such that later columns are displayed
fine.
Replace invalid sort key identifiers with the default sort column PID.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This includes:
- Wrap function implementations
- Pointer alignment for function signatures
- Pointer alignment for variable declarations
- Whitespace after keywords
- Whitespace after comma
- Whitespace around initializers
- Whitespace around operators
- Code indentation
- Line break for single line statements
- Misleading alignment
|
| |
|
|
|
|
|
| |
If the environment variable HOME is not set, try to get the home
directory from the systems password database.
|
|
|
|
| |
Fixes #1008
|
|
|
| |
Co-authored-by: BenBE <BenBE@geshi.org>
|
|
|
|
|
|
|
|
| |
Coverity scan reports that there is dead code in Settings_write
checking for nulls that have already been dereferenced on every
code path leading to the check. This is likely a hangover from
times when the screens pointer was only conditionally allocated
- they're not needed anymore.
|
|
|
|
|
|
|
| |
Coverity scan reports there may be a code path that would cause
an overrun in the (relatively new) ScreenSettings code where it
evaluates default sort direction. Add bounds check and default
to descending instead of a potentially invalid array access.
|
|
|
|
|
| |
Closes #880
Patch from BenBE and cgzones
|
|
|
|
|
| |
Respect the field option defaultSortDesc for the default screen sort
direction, e.g. for CPU%.
|
|
|
|
|
|
|
|
| |
When reading a configuration file with the syntax previous to the
screens update Settings_defaultScreens() will add the default fields and
later ScreenSettings_readFields() will add the ones from the
configuration file. This will duplicate some fields and corrupt the
columns due to the boundless Command field.
|
| |
|
| |
|
|
|
|
|
|
| |
Use C99 struct initialization, which also makes using calloc redundant.
htop: Process.c:1179: int Process_compareByKey_Base(const Process *, const Process *, ProcessField): Assertion `0 && "Process_compareByKey_Base: default key reached"' failed.
|
|
|
|
|
| |
Also tidy up the calloc call parameters in the initial allocation
of this pointer, thanks to @BenBE for noticing.
|
|
|
|
| |
Signed-off-by: Sohaib Mohamed <sohaib.amhmd@gmail.com>
|
|
|
|
|
|
|
|
| |
If the new htop is configured with htoprc having no tabs (eg on upgrade)
then the interface will not automatically introduce/enable them.
However, for a fresh install of htop, enabling them automatically
Signed-off-by: Sohaib Mohamed <sohaib.amhmd@gmail.com>
|
| |
|
| |
|
|
|
|
| |
This is a forward port (by nathans) of Hisham's original code.
|
| |
|
| |
|
|
|
|
|
|
| |
Header.c:150:26: error: implicit conversion loses integer precision: 'int' to 'uint8_t' (aka 'unsigned char') [-Werror,-Wimplicit-int-conversion]
colSettings->len = len;
~ ^~~
|
| |
|