summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2020-10-05Update copyright statementDaniel Lange
2020-10-05Merge branch '0000/int-sizes/00' of https://github.com/mfwitten/htop into ↵Nathan Scott
mfwitten-0000/int-sizes/00
2020-10-05Merge pull request #205 from cgzones/arraysizeNathan Scott
Introduce ARRAYSIZE
2020-10-05Merge branch 'attr-nonnull' of https://github.com/BenBE/htop into ↵Nathan Scott
BenBE-attr-nonnull
2020-10-03Introduce ARRAYSIZEChristian Göttsche
2020-10-03Add clang analyzer CI jobChristian Göttsche
2020-10-03Resolve DEBUG compilation issuesChristian Göttsche
Use NDEBUG conditional instead of DEBUG. Do not call static functions in extern inline ones. Vector.c:67:11: error: static function 'Vector_isConsistent' is used in an inline function with external linkage [-Werror,-Wstatic-in-inline]
2020-10-03Add --enable-debug configure option to enable assertsChristian Göttsche
asserts are still disabled by default.
2020-10-03Add DiskIOMeter for IO read/write usageChristian Göttsche
2020-10-03Add security attribute process columnChristian Göttsche
2020-10-02Adjust colorsChristian Göttsche
- do not reverse CPU steal and guest in monochrome - black on black in Light Terminal is not visible, use blue on black - white on blue in Light Terminal is display as blue on black, use yellow on black - re-draw FunctionBar after color change
2020-10-02InfoScreen: update content on resizeChristian Göttsche
2020-10-02minor typo in Vector.cckath
2020-09-29Enable NULL pointer checks via compiler if supportedBenny Baumann
2020-09-29Process.{h,c}: Use integer types that are more portableMichael Witten
When building on a 32-bit system, the compiler warned that the following line uses a constant whose value is the overflow result of a compile-time computation: Process.c (line 109): } else if (number < 10000 * ONE_M) { Namely, this constant expression: 10000 * ONE_M was intended to produce the following value: 10485760000 However, the result overflowed to produce: 1895825408 The reason for this overflow is as follows: o The macros are expanded: 10000 * (ONE_K * ONE_K) 10000 * (1024L * 1024L) o The untyped constant expression "10000" is typed: 10000U * (1024L * 1024L) o The parenthesized expression is evaluated: 10000U * (1048576L) o The left operand ("10000U") is converted: 10000L * (1048576L) Unbound by integer sizes, that last multiplication would produce the following value: 10485760000 However, on a 32-bit machine, where a long is 32 bits (really 31 bits when talking about positive numbers), the maximum value that can be computed is 2**31-1: 2147483647 Consequently, the computation overflows. o The compiler produces a long int value that is the the result of overflow (10485760000 % 2**31): 1895825408L Actually, I think this overflow is implementation-defined, so it's not even a portable description of what happens. The solution is to use a long long int (or, even better, an unsigned long long int) type for the constant expression; the C standard mandates a sufficiently large maximum value for such types. Hence, the following change is made to the bad line: - } else if (number < 10000 * ONE_M) { + } else if (number < 10000ULL * ONE_M) { However, the whole line is now patently silly, because the variable "number" is typed "unsigned long", and so it will always be less than the constant expression (the compiler will warn about this, too). Hence, "number" must be typed "unsigned long long"; however, this necessitates changing all of the string formats from something like "%lu" to something like "%llu". Et voila! This commit is born. Then, for the sake of completeness, the declared types of the constant-expression macros are updated: o ONE_K is made unsigned (a "UL" instead of "L") o ONE_T is computed by introducing "1ULL *" o Similar changes are made for ONE_DECIMAL_{K,T} Also, a non-portable overflow-conversion to a signed value has been replaced with a portable comparison: - if ((long long) number == -1LL) { + if (number == ULLONG_MAX) { It might be worth reviewing the rest of the code for other cases where overflows are not handled correctly; even at runtime, it's often necessary to check for overflow unless such behavior is expected (especially for signed integer values, for which overflow has implementation-defined behavior).
2020-09-29Sort headers/includesBenny Baumann
2020-09-29Fix FreeBSD compile issueBenny Baumann
This issue was previously hidden as xSnprintf expanded to only one large command that didn't trigger the GCC formatting check.
2020-09-29Cleanse xStrdup messBenny Baumann
2020-09-29Reimplement xAsnprintf and xSnprintf as type-safe functionsBenny Baumann
2020-09-29Drop redundant declarationsChristian Göttsche
- `CRT_fatalError()` is declared twice in CRT.h - `Process_pidFormat`, `Process_writeField()` and `Process_compare` are declared twice in Process.h - `btime` is defined in LinuxProcess.c and also declared in LinuxProcess.h, so drop in LinuxProcessList.h
2020-09-29Drop redundant return statementsChristian Göttsche
2020-09-29Covert Meter attributes to file-local constant arraysChristian Göttsche
2020-09-29Drop redundant casts to the same typeChristian Göttsche
2020-09-29command screen: fill current line when scanningryenus
2020-09-28CPUMeter: add octuple-column CPU meters.multi
This is a straightforward extension of the existing multi-column CPU meter code, which now allows for up CPU meters to be displayed in up to 16 columns. This also adds the meter declarations to all the platform-specific code.
2020-09-28Add missing 4-column CPU meters to non-Linux platforms.multi
2020-09-28CPUMeter: refactor common CPU meter rendering code.multi
Instead of scanning the meter name to determine the number of columns in a CPU meter, move the common code behind some wrapper functions, and specify the number of columns as an explicit parameter when called from the wrappers. While this does add a bit of code for all the necessary wrapper functions, this should be less brittle in case of future changes to the CPU meter code.
2020-09-28Merge pull request #107 from cgzones/hwlock_linuxaffinityNathan Scott
Make --enable-hwloc and --enable-linux-affinity mutual exclusive
2020-09-28Merge pull request #116 from cgzones/valgrindNathan Scott
Add Valgrind script
2020-09-28Merge pull request #181 from cgzones/missing_prototypesNathan Scott
Add -Wmissing-prototypes compiler warning
2020-09-28Merge branch 'arc-is-not-cache' of https://github.com/multiplexd/htop into ↵Nathan Scott
multiplexd-arc-is-not-cache
2020-09-25Add -Wmissing-prototypes compiler warningChristian Göttsche
2020-09-24Linux: consider the ZFS ARC to be cache.multi
This commit is based on a patch originally by @edef1c. The ZFS ARC is a cache (it's in the name), which will be evicted by the kernel if memory pressure so requires. Hence, the ARC should not be counted towards a system's total used memory, and should instead be grouped with the other caches in the system. Signed-off-by: edef <edef@edef.eu>
2020-09-24Do not drop qualifier in castChristian Göttsche
ListItem.c:73:33: warning: cast from 'const void *' to 'struct ListItem_ *' drops const qualifier [-Wcast-qual] ListItem* obj1 = (ListItem*) cast1; ^ ListItem.c:74:33: warning: cast from 'const void *' to 'struct ListItem_ *' drops const qualifier [-Wcast-qual] ListItem* obj2 = (ListItem*) cast2; ^ Process.c:434:28: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual] Process* p1 = (Process*)v1; ^ Process.c:435:28: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual] Process* p2 = (Process*)v2; ^ Process.c:441:36: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual] Settings *settings = ((Process*)v1)->settings; ^ Process.c:443:22: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual] p1 = (Process*)v1; ^ Process.c:444:22: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual] p2 = (Process*)v2; ^ Process.c:446:22: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual] p2 = (Process*)v1; ^ Process.c:447:22: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual] p1 = (Process*)v2; ^ AffinityPanel.c:37:16: warning: cast from 'const char *' to 'void *' drops const qualifier [-Wcast-qual] free((void*)this->text); ^ AffinityPanel.c:39:19: warning: cast from 'const char *' to 'void *' drops const qualifier [-Wcast-qual] free((void*)this->indent); ^ linux/LinuxProcess.c:294:36: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual] Settings *settings = ((Process*)v1)->settings; ^ linux/LinuxProcess.c:296:27: warning: cast from 'const void *' to 'struct LinuxProcess_ *' drops const qualifier [-Wcast-qual] p1 = (LinuxProcess*)v1; ^ linux/LinuxProcess.c:297:27: warning: cast from 'const void *' to 'struct LinuxProcess_ *' drops const qualifier [-Wcast-qual] p2 = (LinuxProcess*)v2; ^ linux/LinuxProcess.c:299:27: warning: cast from 'const void *' to 'struct LinuxProcess_ *' drops const qualifier [-Wcast-qual] p2 = (LinuxProcess*)v1; ^ linux/LinuxProcess.c:300:27: warning: cast from 'const void *' to 'struct LinuxProcess_ *' drops const qualifier [-Wcast-qual] p1 = (LinuxProcess*)v2; ^ linux/LinuxProcessList.c:62:32: warning: cast from 'const void *' to 'struct TtyDriver_ *' drops const qualifier [-Wcast-qual] TtyDriver* a = (TtyDriver*) va; ^ linux/LinuxProcessList.c:63:32: warning: cast from 'const void *' to 'struct TtyDriver_ *' drops const qualifier [-Wcast-qual] TtyDriver* b = (TtyDriver*) vb; ^ linux/Battery.c:130:21: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual] free((char *) isOnline); ^ linux/Battery.c:197:26: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual] xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/type", entryName); ^ linux/Battery.c:209:29: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual] xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/uevent", entryName); ^ linux/Battery.c:262:29: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual] xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/online", entryName); ^
2020-09-24Avoid warning about unreachable break statementChristian Göttsche
htop.c:112:13: warning: 'break' will never be executed [-Wunreachable-code-break] break; ^~~~~ htop.c:109:13: warning: 'break' will never be executed [-Wunreachable-code-break] break; ^~~~~
2020-09-24Avoid bad function cast warningChristian Göttsche
linux/Platform.c:142:17: warning: cast from function call of type 'double' to non-matching type 'int' [-Wbad-function-cast] return (int) floor(uptime); ^~~~~~~~~~~~~
2020-09-24Drop unnecessary usage of comma operatorChristian Göttsche
2020-09-24Include prototype in Battery implementationChristian Göttsche
linux/Battery.c:291:6: warning: no previous prototype for function 'Battery_getData' [-Wmissing-prototypes] void Battery_getData(double* level, ACPresence* isOnAC) { ^
2020-09-24Drop unused macrosChristian Göttsche
2020-09-24Read CPU frequency from sysfs by defaultChristian Göttsche
Use the more portable sysfs node /sys/devices/system/cpu/cpuX/cpufreq/scaling_cur_freq to get the CPU frequency. In case of an error fall back to /proc/cpuinfo . Also use a fixed width of 4 for the frequency to avoid position jumps in case the frequency moves in the range 900-1100 MHz.
2020-09-24Add DeepCode inline suppressionChristian Göttsche
We just want a non-NUll pointer in the matching pid hashtable. The pointer is not dereferenced anyways.
2020-09-24Add DeepCode inline suppressionChristian Göttsche
commsize is bounded by the allocated length passed in by commLen, saved into commLenIn
2020-09-24Make --enable-hwloc and --enable-linux-affinity mutual exclusiveChristian Göttsche
They can not be supported both at the same time. Fail configure step instead of silently only use hwloc.
2020-09-24show selected command wrapped in a separate windowryenus
For a process with a very long command, especially with many long command line arguments, inspecting the command and its arguments could become inconvenient. Meanwhile htop supports the concept of "screen", or window, which is extended here to create a dedicated "CommandScreen", making it possible to display the command of the selected process in a separate window meanwhile being wrapped into multiple lines. Another benefit of using a command screen is, the user can navigate through the wrapped lines of the command and perform actions like searching and filtering.
2020-09-24Avoid unsigned integer overflowChristian Göttsche
unsigned integer overflows are well-defined, but they might point to a counting issue. Having the code free of unsigned overflows makes it easier to spot potential bugs. Action.c:332:27: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'uid_t' (aka 'unsigned int') changed the value to 4294967295 (32-bit, unsigned) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Action.c:332:27 in
2020-09-24Use return value of CLAMP functionBenny Baumann
2020-09-24Add -Wfloat-equal to default build flagsBenny Baumann
2020-09-24Update delay accounting to use NAN on errorBenny Baumann
2020-09-24Update CPU freq display to use NAN on errorBenny Baumann
2020-09-24Use threshold for display of guest/steal/irq metersBenny Baumann