summaryrefslogtreecommitdiffstats
path: root/Header.c
Commit message (Collapse)AuthorAgeFilesLines
* Use struct member to determine size of allocationsBenny Baumann8 days1-2/+2
|
* Define MeterModeId to unsigned int and use it throughoutExplorer098 days1-1/+1
| | | | | | | | | 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>
* Explicitly check sscanf(3) and fscanf(3) return valuesChristian Göttsche2024-01-251-3/+2
| | | | | | | | | 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.
* Update includes based on IWYUBenny Baumann2023-12-261-0/+1
|
* Add includes for config.h as per the discussion in PR #1337Daniel Lange2023-12-261-0/+2
| | | | | | 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.
* Introduce Machine class for host-specific info (split from ProcessList)Nathan Scott2023-05-081-11/+13
| | | | | | | | | | | First stage in sanitizing the process list structure so that htop can support other types of lists too (cgroups, filesystems, ...), in the not-too-distant future. This introduces struct Machine for system-wide information while keeping process-list information in ProcessList (now much less). Next step is to propogate this separation into each platform, to match these core changes.
* Refactor and consolidate dynamic meters/columns pointersNathan Scott2023-04-061-4/+5
| | | | | | | | 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.
* Do not render a margin around the header if there are any metersBenny Baumann2022-10-221-1/+10
|
* Do not leave empty last column in headerChristian Göttsche2021-12-091-1/+4
| | | | | | | Do not leave empty last column in header meters by refactoring the width and separator logic. Closes: #784
* Introduce screen tabsHisham Muhammad2021-12-071-0/+3
| | | | This is a forward port (by nathans) of Hisham's original code.
* Header: allocate memory for terminating entryChristian Göttsche2021-10-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The names array is terminated by a NULL entry, thus allocate space for one more than entries. Fixes: #844 ==6708==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6060000045b8 at pc 0x000000589ee1 bp 0x7ffcd1dee220 sp 0x7ffcd1dee218 READ of size 8 at 0x6060000045b8 thread T0 #0 0x589ee0 in String_freeArray ./XUtils.c:157:23 #1 0x56c9af in Settings_delete ./Settings.c:31:7 #2 0x4ee44b in CommandLine_run ./CommandLine.c:395:4 #3 0x4d6fb2 in main ./htop.c:15:11 #4 0x7ff3b8154e49 in __libc_start_main csu/../csu/libc-start.c:314:16 #5 0x428aa9 in _start (./htop+0x428aa9) 0x6060000045b8 is located 0 bytes to the right of 56-byte region [0x606000004580,0x6060000045b8) allocated by thread T0 here: #0 0x4a53f2 in __interceptor_calloc (./htop+0x4a53f2) #1 0x5890ba in xCalloc ./XUtils.c:55:17 #2 0x50a044 in Header_writeBackToSettings ./Header.c:148:34 #3 0x4de861 in Action_runSetup ./Action.c:91:7 #4 0x4de861 in actionSetup ./Action.c:386:4 #5 0x515caf in MainPanel_eventHandler ./MainPanel.c:106:19 #6 0x56a5c1 in ScreenManager_run ./ScreenManager.c:235:19 #7 0x4ee13b in CommandLine_run ./CommandLine.c:364:4 #8 0x4d6fb2 in main ./htop.c:15:11 #9 0x7ff3b8154e49 in __libc_start_main csu/../csu/libc-start.c:314:16
* Update license headers to explicitly say GPLv2+Daniel Lange2021-09-221-1/+1
|
* Header: do not let multi-column meters expand to empty neighborsChristian Göttsche2021-09-181-1/+4
| | | | | | | | | | Extending to right neighbors is intended for text meters with an overlong content, so the whole text is shown if possible. Multi column meters, like the combined memory and swap meter, position its text depending on the given total width; keep the position to the original assigned header slot. Short term resolution for #796
* Header: use upper case floating point suffixChristian Göttsche2021-09-041-6/+6
|
* Reduce variable scopeChristian Göttsche2021-09-041-1/+2
| | | | | Also avoid declaring variables of different type, pointer and array, in the same line.
* IWYU updateChristian Göttsche2021-08-251-0/+2
|
* Tiny cleanup from review commentsDaniel Lange2021-08-231-2/+2
|
* Add option to change Header layoutChristian Göttsche2021-08-221-81/+114
|
* Add assert to improve backtraces on NULL function pointerChristian Göttsche2021-08-101-0/+1
|
* Ensure PCP dynamic metric configuration definition uniquenessNathan Scott2021-07-141-2/+2
| | | | | | | | | | | | | | It can happen that pcp-htop is presented multiple definitions of the same dynamic meter, e.g. if /etc/pcp/htop/meters has a definition matching one in ~/.config/htop/meters - instead of exiting with a duplicate metric error provide more meaningful diagnostics (on close) and also just skip over such entries. System files override home directories which overrides those found below the current working directory. Also fix the derived metric error diagnostic; because this is using CRT_fatalError, which is like perror(3), we must give a meaningful prefix (like program name) at the string end.
* Ensure we do not attempt to add a DynamicMeter via theNathan Scott2021-07-141-8/+12
| | | | | | | htoprc that we didn't find during start up. This just leaves blank sections of the display as @smalinux found. Related to https://github.com/htop-dev/htop/pull/682
* Add a new DynamicMeter class for runtime Meter extensionNathan Scott2021-07-071-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is based on exploratory work by Sohaib Mohamed. The end goal is two-fold - to support addition of Meters we build via configuration files for both the PCP platform and for scripts ( https://github.com/htop-dev/htop/issues/526 ) Here, we focus on generic code and the PCP support. A new class DynamicMeter is introduced - it uses the special case 'param' field handling that previously was used only by the CPUMeter, such that every runtime-configured Meter is given a unique identifier. Unlike with the CPUMeter this is used internally only. When reading/writing to htoprc instead of CPU(N) - where N is an integer param (CPU number) - we use the string name for each meter. For example, if we have a configuration for a DynamicMeter for some Redis metrics, we might read and write "Dynamic(redis)". This identifier is subsequently matched (back) up to the configuration file so we're able to re-create arbitrary user configurations. The PCP platform configuration file format is fairly simple. We expand configs from several directories, including the users homedir alongside htoprc (below htop/meters/) and also /etc/pcp/htop/meters. The format will be described via a new pcp-htop(5) man page, but its basically ini-style and each Meter has one or more metric expressions associated, as well as specifications for labels, color and so on via a dot separated notation for individual metrics within the Meter. A few initial sample configuration files are provided below ./pcp/meters that give the general idea. The PCP "derived" metric specification - see pmRegisterDerived(3) - is used as the syntax for specifying metrics in PCP DynamicMeters.
* Use unsigned types for CPU counts and associated variablesChristian Göttsche2021-03-191-4/+4
|
* Separate data-update and drawing of headerChristian Göttsche2021-03-041-0/+11
|
* Leave less right margin next to long (text) metersDaniel Lange2021-02-021-1/+1
|
* Use typedef names instead of raw struct onesChristian Göttsche2021-01-261-1/+1
|
* Allow meters in text mode to span empty neighbors to the rightChristian Göttsche2021-01-231-6/+42
| | | | Closes: #484
* Mark several non-modified pointer variables constChristian Göttsche2021-01-111-11/+11
|
* Remove unused function Header_readMeterNameChristian Göttsche2020-12-061-15/+0
|
* Update even more snprintfsChristian Göttsche2020-11-281-3/+3
| | | | Use size of actual buffers instead of magic numbers
* Embracing branchesBenny Baumann2020-11-021-2/+7
|
* Spacing around operatorsBenny Baumann2020-11-021-1/+1
|
* Make all required includes explicitBenny Baumann2020-10-181-4/+8
| | | | Information as seen by IWYU 0.12 + clang 9 on Linux
* Rename StringUtils.[ch] to XUtils.[ch]Benny Baumann2020-10-161-1/+1
|
* Mark Object instances constChristian Göttsche2020-10-071-2/+2
|
* Update License consistently to GPLv2 as per COPYING fileDaniel Lange2020-10-051-1/+1
|
* Clean up some code duplication in the header filesHugo Musso Gualandi2020-09-121-2/+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.
* Consolidate repeated macro definitions into one headerNathan Scott2020-09-091-8/+1
| | | | | | | | 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.
* Axe automated header generation.Zev Weiss2020-09-031-15/+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 string overflow warningChristian Göttsche2020-08-251-1/+1
| | | | | | | | | | | | Enough memory is allocated. Header.c: In function ‘Header_readMeterName’: Header.c:157:4: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] 157 | strncpy(name, Meter_name(meter), nameLen); | ^ Header.c:154:18: note: length computed here 154 | int nameLen = strlen(Meter_name(meter)); | ^
* Merge branch 'hishamhm-pull-960'Nathan Scott2020-08-201-5/+5
|\
| * Clean up existing whitespaceDaniel Flanagan2019-10-311-5/+5
| |
* | Restore meter name after used in Header_addMeterByName()wangqr2019-02-121-0/+2
|/ | | | Fix #852
* Security review: check results of snprintf.Hisham Muhammad2017-07-271-3/+3
| | | | | Calls marked with xSnprintf shouldn't fail. Abort program cleanly if any of them does.
* Fix macro Header_forEachColumnExplorer092016-05-071-1/+1
| | | | | | | The (this_) token was not expanded properly, but the bug was not caught because all uses of this macro specifies (this_)=this . Also parenthesize macro tokens to prevent further problems.
* Check for failure in allocations.Hisham2016-02-021-6/+6
|
* fix calloc() callsChristian Hesse2015-09-071-1/+1
| | | | | | | * size_t nmemb (number of elements) first, then size_t size * do not assume char is size 1 but use sizeof() * allocate for char, not pointer to char (found by Michael McConville, fixes #261)
* Rename String to StringUtils.David Hunt2015-08-191-1/+1
| | | | | | | | | Fixes building on case-insensitive filesystems where String.h gets confused with <string.h>. From d734dacea0a10d0465dad4e95b3421511e7da112 Mon Sep 17 00:00:00 2001 From: David Hunt <dhunt@iolanthe.attlocal.net> Date: Sat, 11 Jul 2015 20:56:31 -0500 Subject: [PATCH 1/8] Rename String to StringUtils
* write header length (number of columns) back to configurationChristian Hesse2015-06-121-0/+1
|
* Fix saving of header states, motion in Setup screen.Hisham Muhammad2015-03-161-1/+30
|

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