summaryrefslogtreecommitdiffstats
path: root/Process.c
Commit message (Collapse)AuthorAgeFilesLines
* Use size_t as type for buffer length in ProcessChristian Göttsche2020-12-061-3/+3
|
* Print G in gigabyte colorChristian Göttsche2020-11-291-1/+2
| | | | When printing a size like 27.2G print the G like the 27 in the gigabyte color.
* Replace more snprintfs, reduce buffer sizes to what is printedDaniel Lange2020-11-281-19/+19
|
* Use 'N/A' instead of 'no perm' for more consistencyBenny Baumann2020-11-281-6/+9
|
* Minor indentation fixBenny Baumann2020-11-241-1/+1
|
* Improving Command display/sortNarendran Gopalakrishnan2020-11-241-1/+6
|
* Rename virtual memory column from M_SIZE to M_VIRTChristian Göttsche2020-11-211-3/+3
| | | | Closes: #325
* IWYU update (Linux)Christian Göttsche2020-11-191-1/+2
|
* Add process column for normalized CPU usageChristian Göttsche2020-11-161-6/+12
| | | | Shows the process CPU usage divided by the number of CPU cores
* Merge branch 'hili-new-old' of adsr/htop into highlight-new-old-processesDaniel Lange2020-11-161-14/+34
|\
| * Address items from reviewAdam Saponara2020-10-311-6/+6
| |
| * Highlight new and old processes (#74)Adam Saponara2020-10-301-0/+17
| |
* | Use uid_t type for Process_getuidChristian Göttsche2020-11-151-4/+4
| |
* | Introduce spaceship comparison for ProcessesChristian Göttsche2020-11-151-30/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If currently two unsigned values are compared via `a - b`, in the case b is actually bigger than a, the result will not be an negative number (as -1 is expected) but a huge positive number as the subtraction is an unsigned subtraction. Avoid over-/underflow affected operations; use comparisons. Modern compilers will generate sane code, like: xor eax, eax cmp rdi, rsi seta al sbb eax, 0 ret
* | Embracing branchesBenny Baumann2020-11-021-13/+30
| |
* | Spacing around operatorsBenny Baumann2020-11-021-11/+11
| |
* | Whitespace and indentation issuesBenny Baumann2020-11-021-2/+2
| |
* | Spacing after keywords (if)Benny Baumann2020-11-021-1/+1
|/
* Hold only a const version of Settings in ProcessChristian Göttsche2020-10-261-1/+1
|
* Cache PAGE_SIZEChristian Göttsche2020-10-191-2/+2
| | | | | | man:sysconf(3) states: The values obtained from these functions are system configuration constants. They do not change during the lifetime of a process.
* Make all required includes explicitBenny Baumann2020-10-181-18/+17
| | | | Information as seen by IWYU 0.12 + clang 9 on Linux
* Rename StringUtils.[ch] to XUtils.[ch]Benny Baumann2020-10-161-1/+1
|
* Refactor generating starttime string into Process classChristian Göttsche2020-10-161-0/+6
|
* Mark Object pointer to _display function constChristian Göttsche2020-10-101-6/+6
|
* Mark Object instances constChristian Göttsche2020-10-071-1/+1
|
* Update License consistently to GPLv2 as per COPYING fileDaniel Lange2020-10-051-1/+1
|
* Process.{h,c}: Use integer types that are more portableMichael Witten2020-09-291-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Do not drop qualifier in castChristian Göttsche2020-09-241-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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); ^
* Update IO rate display to use NAN on errorBenny Baumann2020-09-241-1/+1
|
* Fix minor regression in number highlightingBenny Baumann2020-09-211-1/+1
| | | | Fixes #163
* Enhance highlighting of semi-large and large numbersBenny Baumann2020-09-171-28/+46
|
* Clean up some code duplication in the header filesHugo Musso Gualandi2020-09-121-23/+0
| | | | | | | | | | | | | PR htop-dev/htop#70 got rid of the infrastructure for generating header files, but it left behind some code duplication. Some of cases are things that belong in the header file and don't need to be repeated in the C file. Other cases are things that belong in the C file and don't need to be in the header file. In this commit I tried to fix all of these that I could find. When given a choice I preferred keeping things out of the header file, unless they were being used by someone else.
* Axe automated header generation.Zev Weiss2020-09-031-139/+0
| | | | | | | | | | | | | | Reasoning: - implementation was unsound -- broke down when I added a fairly basic macro definition expanding to a struct initializer in a *.c file. - made it way too easy (e.g. via otherwise totally innocuous git commands) to end up with timestamps such that it always ran MakeHeader.py but never used its output, leading to overbuild noise when running what should be a null 'make'. - but mostly: it's just an awkward way of dealing with C code.
* Avoid discarding const qualifiersChristian Göttsche2020-08-251-1/+1
|
* Merge branch 'hishamhm-pull-960'Nathan Scott2020-08-201-5/+5
|\
| * Clean up existing whitespaceDaniel Flanagan2019-10-311-5/+5
| |
* | Merge branch 'hishamhm-pull-872'Nathan Scott2020-08-201-0/+2
|\ \
| * | Fix configure 'major' workaround causing <sys/sysmacros.h> to miss.Explorer092019-06-141-0/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | A logic mistake in pull request #746 causes <sys/sysmacro.h> to be *not* included when AC_HEADER_MAJOR (before autoconf-2.70) finds 'major' in <sys/types.h>. Though this would still build htop, it would still bring deprecation warning in systems using glibc 2.25-2.27. Fix the logic and suppress the warning. Also, include config.h in Process.c for the sake of strengthening the code. Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
* | Merge branch 'hishamhm-pull-866'Nathan Scott2020-08-201-2/+1
|\ \
| * | Remove unnecessary HAVE_SYS_SYSMACROS_H checkWataru Ashihara2018-12-151-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | HAVE_SYS_SYSMACROS_H is always true if MAJOR_IN_SYSMACROS. This way of checking is recommended in autoconf 2.70 documentation: https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blobdiff;f=doc/autoconf.texi;h=4f041bd4e;hp=9ad7dc1c5f02c8ba25b2fe1218bf931c7113a5d5;hb=e17a30e987d7ee695fb4294a82d987ec3dc9b974;hpb=565a6dc50cfa01cec2fb4db894026689cdf4970c NOTE: currently https://www.gnu.org/software/autoconf/manual/autoconf.html is the doc for autoconf 2.69.
* | | Resolve compiler warnings and errors relating to the Arg unionNathan Scott2020-08-201-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Promote the Arg union to a core data type in Object.c such that it is visible everywhere (many source files need it), and correct declarations of several functions that use it. The Process_sendSignal function is also corrected to have the expected return type (bool, not void) - an error being masked by ignoring this not-quite-harmless warning. I've also added error checking to the kill(2) call here, which was previously overlooked / missing (?).
* | | Merge branch 'hishamhm-pull-869'Nathan Scott2020-08-191-6/+18
|\ \ \
| * | | Deal with larger numbers in colorNumber and outputRateadrien10182018-12-301-8/+16
| | | |
| * | | Fix numbers larger than 100 terabytesadrien10182018-12-181-1/+5
| |/ /
| * | Fix printf() unsigned placeholdersAlan Barr2018-10-301-7/+7
| | | | | | | | | | | | | | | | | | Unsigned numbers should be using "%u". Raised by cppcheck
* | | Merge branch 'hishamhm-pull-842'Nathan Scott2020-08-181-1/+1
|\ \ \ | |_|/ |/| |
| * | Widen ST_UID (UID) column to 5 chars to allow UIDs > 9999 without breaking ↵Daniel Lange2018-10-071-1/+1
| |/ | | | | | | | | | | alignment Issue Github #841, Debian bug #910492
* | Return of snprintf is not the number of written bytesHisham Muhammad2019-02-101-3/+8
| |
* | Fix printf() unsigned placeholdersAlan Barr2019-02-101-7/+7
|/ | | | | | Unsigned numbers should be using "%u". Raised by cppcheck
* Collapse current subtree pressing BackspaceHisham Muhammad2018-04-051-0/+2
|

© 2014-2024 Faster IT GmbH | imprint | privacy policy