Commit Graph

39 Commits

Author SHA1 Message Date
Hisham Muhammad
09e241fb12 Security review: check results of snprintf.
Calls marked with xSnprintf shouldn't fail.
Abort program cleanly if any of them does.
2017-07-27 16:07:50 -03:00
Tomasz Kramkowski
2b5c1b4b13 Replace all uses of sprintf with snprintf
In all the cases where sprintf was being used within htop, snprintf
could have been used. This patch replaces all uses of sprintf with
snprintf which makes sure that if a buffer is too small to hold the
resulting string, the string is simply cut short instead of causing
a buffer overflow which leads to undefined behaviour.

`sizeof(variable)` was used in these cases, as opposed to `sizeof
variable` which is my personal preference because `sizeof(variable)`
was already used in one way or another in other parts of the code.
2016-12-29 19:42:41 +01:00
Explorer09
9dea20e068 Rename Meter.setValues() functions to updateValues()
Rationale (copied from htop issue #471):
The function name "setValues" is misleading. For most OOP (object-
oriented programming) contexts, setXXX functions mean they will change
some member variables of an object into something specified in
function arguments. But in the *Meter_setValues() case, the new values
are not from the arguments, but from a hard-coded source. The caller
is not supposed to change the values[] to anything it likes, but
rather to "update" the values from the source. Hence, updateValues is
a better name for this family of functions.
2016-05-04 13:39:26 +08:00
Explorer09
99fb3070a2 Explicit "maxItems" property of meters
Two changes in this commit:
- All meters now explicitly specify "maxItems" property, even for just
  1 item. (Exception is "container" CPU meter classes, which use
  CUSTOM_METERMODE.)
- "maxItems" being 0 is now allowed. This will let bar meters and graph
  meters render an empty meter.
2016-03-11 10:54:34 +08:00
Hisham
b54d2dde40 Check for failure in allocations. 2016-02-02 15:53:02 +01:00
Hisham Muhammad
71190654bc Calculate CPU averages on Darwin (See #295). 2015-10-23 13:46:21 -02:00
Christian Hesse
696e36cb45 remove extra space in dual meters without margins 2015-08-27 22:40:35 +02:00
Hisham Muhammad
14bd77c5f4 Add longer descriptions to available meters. 2015-02-03 22:31:44 +01:00
Hisham Muhammad
3383d8e556 Sorry about the mega-patch.
This is a work-in-progress, code is currently broken.
(Some actions, and notably, the header, are missing.)
2015-01-21 23:27:31 -02:00
Hisham Muhammad
100bd10b1d Make blue text more readable. Closes #55. 2014-04-24 13:15:52 -03:00
Hisham Muhammad
76a715ee8c Fix order of calloc arguments.
(Patch by Dawid Gajownik)
2014-01-16 18:51:16 -02:00
Hisham Muhammad
c1e0f6e17c BUGFIX: Fix crash when adding meters and toggling detailed CPU time.
See https://bugzilla.redhat.com/show_bug.cgi?id=987805 for details.
(thanks to Dawid Gajownik for the detailed analysis!)
2014-01-16 01:40:47 -02:00
Hisham Muhammad
8ace29c267 Make CPU meter optionally account guest time in its percentages 2013-12-18 02:58:34 +00:00
Hisham Muhammad
43a7231615 Remove explicit calls to curses.h in other files 2013-02-26 16:50:21 +00:00
Hisham Muhammad
00b324bfc1 Changes in object model: separate class objects to store vtable. Also, nicer UTF-8 display of big numbers. 2012-12-05 15:12:20 +00:00
Hisham Muhammad
45f7a4fc8d Remove old memory debugging routines. We have Valgrind nowadays. 2011-12-26 22:04:29 +00:00
Hisham Muhammad
84281bdc44 major header cleanup 2011-12-26 21:35:57 +00:00
Hisham Muhammad
7ca1081712 Mega-commit with features and tweaks for 1.0:
* Performance improvements
* Support for splitting CPU meters into two or four columns
  (thanks to Wim Heirman)
* Switch from PLPA, which is now deprecated, to HWLOC.
* Bring back support for native Linux sched_setaffinity,
  so we don't have to use HWLOC where we don't need to.
* Support for typing in user names and column fields in selection panels.
2011-11-18 06:08:56 +00:00
Hisham Muhammad
f7fe4b4722 Fix off-by-one error in PROCESSOR display 2011-09-08 02:48:53 +00:00
Hisham Muhammad
03322b62ec Realign display of text-mode CPU meters. Closes #3369526. 2011-09-08 01:29:59 +00:00
Hisham Muhammad
300caa076e Tempus fugit. 2011-05-26 16:35:07 +00:00
Hisham Muhammad
6382e03b68 fix broken height for All CPUs meter 2011-05-26 16:22:50 +00:00
Hisham Muhammad
bd459776a4 retain meter state when it is reinit'ed in the Setup screen 2011-03-31 20:24:59 +00:00
Hisham Muhammad
a9c0ea3753 * Option for counting CPUs from zero
(thanks to Sean Noonan)
* Meters update in every screen (no longer halting while on Setup, etc.)
2011-03-22 20:37:08 +00:00
Hisham Muhammad
d8e1480a27 Remove arbitrary limit from rich strings
Fix subtree hiding
Fix reading of CPU values in hidden threads
Fix hiding of zombie processes as kernel threads
Remove "debug proc" code
Code cleanup in processElements
2010-11-22 12:40:20 +00:00
Hisham Muhammad
6486229308 add support for steal/guest CPU time measurement
simplify processor data accounting (add CPUData structure)
remove Process_clone trick
2010-08-24 23:20:38 +00:00
Hisham Muhammad
655c29bce5 Fix display of nan% in CPU meters
(Fix by Steven Hampson)
2010-06-30 18:29:54 +00:00
Hisham Muhammad
a600d5a6e9 Tempus fugit. 2010-02-25 02:08:18 +00:00
Hisham Muhammad
5cc8998688 never show nan% 2010-02-25 01:40:14 +00:00
Hisham Muhammad
6330ff3a0a changes for htop 0.8.2 2009-06-02 04:51:23 +00:00
Hisham Muhammad
da23c8c5a1 Clean up headers by using 'static' whenever possible.
Reduces resulting code size.
2008-03-09 08:58:38 +00:00
Hisham Muhammad
855d9eaf9a IO-wait time now counts as idle time, which is a more
accurate description. It is still available in
split time, now called detailed CPU time.
(thanks to Samuel Thibault for the report)
2007-11-09 00:40:59 +00:00
Hisham Muhammad
3e4f06d101 Contribution by Philipp Richter: Display IO-Wait, IRQ and Soft-IRQ values in status bar
(minor modifications: default to false, add help)
2006-10-04 14:21:27 +00:00
Hisham Muhammad
dbe2670b69 Perform RichString operations by hand.
Avoid unnecessary operations when processing entries on ProcessList.
2006-07-12 01:16:03 +00:00
Hisham Muhammad
2f1f82ee87 Updates for new version of the MakeHeader.py script. 2006-06-06 20:41:01 +00:00
Hisham Muhammad
57a17420e0 Final fixes to make "All CPUs" the default CPU display mode. 2006-05-09 18:35:51 +00:00
Hisham Muhammad
33113fe0d7 - Overhaul meters implementation;
- add AllCPUsMeter;
- because of that, the new .htoprc is incompatible with previous released versions.
2006-04-10 20:40:38 +00:00
Hisham Muhammad
0df3ea08d3 Update copyrights. 2006-03-23 18:53:08 +00:00
Hisham Muhammad
d6231bab89 Initial import. 2006-03-04 18:16:49 +00:00