Christian Göttsche
18b1e9fba9
Do not drop qualifier in cast
...
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);
^
6 years ago
Christian Göttsche
cd1ba1422b
Avoid bad function cast warning
...
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);
^~~~~~~~~~~~~
6 years ago
Christian Göttsche
4296e74ada
Include prototype in Battery implementation
...
linux/Battery.c:291:6: warning: no previous prototype for function 'Battery_getData' [-Wmissing-prototypes]
void Battery_getData(double* level, ACPresence* isOnAC) {
^
6 years ago
Christian Göttsche
edf1b10d2c
Read CPU frequency from sysfs by default
...
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.
6 years ago
Christian Göttsche
594409f299
Add DeepCode inline suppression
...
commsize is bounded by the allocated length passed in by commLen, saved
into commLenIn
6 years ago
Benny Baumann
7ecea3d485
Use return value of CLAMP function
6 years ago
Benny Baumann
321960bd96
Update delay accounting to use NAN on error
6 years ago
Benny Baumann
3c65d78d77
Update CPU freq display to use NAN on error
6 years ago
Benny Baumann
d0d3deb73c
Properly query sysconf settting and use NAN if unavailable
...
This also fixes an issue with time returned negative if sysconf(_SC_CLK_TCK) returned an error.
6 years ago
Benny Baumann
29ec115143
Update IO rate display to use NAN on error
6 years ago
Benny Baumann
47e2cefe02
Update battery API to use NAN on error
6 years ago
Christian Göttsche
f9966b5be3
Use checked allocation wrappers
6 years ago
Christian Göttsche
eb260af6bf
Fix memory leak on cgroup read failure
6 years ago
Christian Göttsche
e719a85994
Mark noreturn functions
6 years ago
Christian Göttsche
c3952e7c20
Use strict function prototypes
...
int foo(); declares a function taking any number of arguments.
6 years ago
Christian Göttsche
5d4061732f
Allow third party sigsegv handler
...
For example from sanitizers.
6 years ago
Christian Göttsche
00665e2a2b
Avoid unsigned integer overflow
...
unsigned overflow is well defined, but creates noise when using
sanitizers. unsigned overflow can be a symptom of logic issues of
counter, so its reasonable to use.
linux/LinuxProcessList.c:64:50: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior linux/LinuxProcessList.c:64:50 in
linux/LinuxProcessList.c:64:11: runtime error: implicit conversion from type 'unsigned int' of value 4294967295 (32-bit, unsigned) to type 'int' changed the value to -1 (32-bit, signed)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior linux/LinuxProcessList.c:64:11 in
linux/LinuxProcessList.c:64:78: runtime error: unsigned integer overflow: 4 - 136 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior linux/LinuxProcessList.c:64:78 in
6 years ago
Christian Göttsche
98ee833932
Add Linux process column for context switches
...
Displays the incremental sum of voluntary_ctxt_switches and nonvoluntary_ctxt_switches.
6 years ago
Christian Göttsche
37921382f4
Use PROCDIR throughout instead of /proc on Linux
6 years ago
Christian Göttsche
b096fdbfc0
Avoid potential buffer overflow in LinuxProcessList_readStatFile
...
Pass size of allocated command buffer and limit write.
6 years ago
Christian Göttsche
d5eb72e64d
Drop always true condition
...
`env` is allocated by checked allocation functions and can not be NULL.
This checks confuses clang analyzer and causes a null-dereference
warning on `env[size-1]`.
6 years ago
Nathan Scott
4597332959
Switch variable/field naming from WhiteList to MatchList
6 years ago
Nathan Scott
c5808c56db
Consolidate repeated macro definitions into one header
...
The MIN, MAX, CLAMP, MINIMUM, and MAXIMUM macros appear
throughout the codebase with many re-definitions. Make
a single copy of each in a common header file, and use
the BSD variants of MINIMUM/MAXIMUM due to conflicts in
the system <sys/param.h> headers.
6 years ago
Nathan Scott
8ec5d4a3a0
Further, minor cleanups to headers post-MakeHeaders
...
Remove leftover empty ifdef/endif pairs, whitespace.
The generated htop.h file was also unused - removed.
6 years ago
Zev Weiss
7b7822b896
Remove superfluous 'extern's from function declarations.
...
Applied via:
$ find * -name '*.h' -exec sed -i -r 's/^extern (.+\()/\1/;' {} +
Suggested-by: Bert Wesarg <bert.wesarg@googlemail.com>
6 years ago
Zev Weiss
a1a027b9bd
Axe automated header generation.
...
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.
6 years ago
Christian Göttsche
e7f6d1ce5f
Reduce oom cast from long to int
...
Oom values should never be greater then INT_MAX, they should be in the
range 0 - 1000.
Improves: d9a5dd4b91
6 years ago
Christian Göttsche
5c99c6e942
Check btime sscanf parse from /proc/stat
...
Found by Coverity
6 years ago
Christian Göttsche
a850d81bf5
Avoid use of uninitialized variables
...
Found by Coverity
6 years ago
Christian Göttsche
05a5fdc47f
Ignore sscanf return value of /proc/stat
...
Found by Coverity
6 years ago
Christian Göttsche
af84d3dfa9
Fail on out-of-range CPU number
...
Found by Coverity
6 years ago
Christian Göttsche
d9a5dd4b91
Improve OOM output
...
* Fix sort by adding cast
* Shrink column size to 4
* Drop unnecessary maximum field width specifier in sscanf
6 years ago
Christian Göttsche
a48ce9d103
Really tell gcc to ignore return value of fscanf
6 years ago
Nathan Scott
b992d52bcf
Increae the size of sysfs power supply path buffers
...
Resolves https://github.com/htop-dev/htop/issues/15
6 years ago
Christian Göttsche
4e2b9f0965
Avoid shadowing warnings
6 years ago
Christian Göttsche
6b11769448
Avoid conversion warning
...
linux/Platform.c:47:90: error: implicit conversion from ‘enum LinuxProcessFields’ to ‘enum ProcessFields’ [-Werror=enum-conversion]
47 | ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
6 years ago
Nathan Scott
6900e57efd
Updates to project URLs in docs and embedded in source code
6 years ago
Nathan Scott
5dad65ac2a
Update header files to match whitespace changes in source files
6 years ago
Christian Göttsche
b92f62f912
Remove trailing whitespaces
6 years ago
Christian Göttsche
3856bf574b
Introduce xAsprintf as checked version of asprintf
6 years ago
Nathan Scott
2be0992700
Merge branch 'hishamhm-pull-890'
6 years ago
Nathan Scott
500fb283e9
Resolve compiler warnings and errors relating to the Arg union
...
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 (?).
6 years ago
Nathan Scott
eef6bc447d
Correction to smaps buffer size passed to smaps path snprintf
6 years ago
Nathan Scott
7ac1c709b7
Re-generate all headers with latest scripts/MakeHeader.py
...
Sync-up missing extern declarations for many functions.
6 years ago
Nathan Scott
dfd9279f87
Resolve complation issues with -fno-common (default from gcc-10)
...
Extends the MakeHeader script to auto-generate correct "extern"
function declarations in some cases that it currently does not.
Related to https://github.com/hishamhm/htop/pull/981
6 years ago
Christoph Budziszewski
7fdd8d3732
adding support for more than 2 smaller cpumeter columns
6 years ago
Jure Oder
88c9ebb8f7
Properly identify zombie processes
...
This closes issue #930 .
6 years ago
Daniel Flanagan
dd33444f7e
Clean up existing whitespace
6 years ago
smattie
1886117c72
Linux: fixes sysfs battery discovery
7 years ago
Ross Williams
a267003f2f
Linux fixes
7 years ago