Comments (4)
For sure. The code can use a good makeover for more defensive programming and avoiding of overflows. Patches welcome.
from htop.
Having the source compile with the following compiler settings is a good start:
-dP
-pedantic
-Wall
-Wextra
-Werror
-Wunused-parameter
-Wduplicated-cond
-Wduplicated-branches
-Wunreachable-code
-Wshadow # Patches incoming; not much to do though
-Winit-self
-Wrestrict
-Wnull-dereference
-Wpointer-arith
-Wcast-align
-Wfloat-equal
-Wlogical-op
-Wwrite-strings
-Wformat=2
-Wno-error=expansion-to-defined
-Wstrict-overflow=5
-Wconversion # Patches incoming, cf. #78
-Wundef
-Wswitch-default
-Wswitch-enum
-fno-strict-aliasing
from htop.
The suggested set of compiler flags build correctly with both #101 and #102 applied.
from htop.
As I see some patches coming in using the GCC attributes, I had a look at some of my projects and saw, that one feature that could be interesting in the long run, might be buffer access tracking:
// Allow to use the GCC10 access attribute even with older compilers (by ignoring it if unsupported)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 10)
#define HTOP_CHK_R1(x) __attribute__((access(read_only,x)))
#define HTOP_CHK_RW1(x) __attribute__((access(read_write,x)))
#define HTOP_CHK_W1(x) __attribute__((access(write_only,x)))
#define HTOP_CHK_R(x,y) __attribute__((access(read_only,x,y)))
#define HTOP_CHK_RW(x,y) __attribute__((access(read_write,x,y)))
#define HTOP_CHK_W(x,y) __attribute__((access(write_only,x,y)))
#else
#define HTOP_CHK_R1(x)
#define HTOP_CHK_RW1(x)
#define HTOP_CHK_W1(x)
#define HTOP_CHK_R(x,y)
#define HTOP_CHK_RW(x,y)
#define HTOP_CHK_W(x,y)
#endif
Basically what these attributes do (applied to a function declaration) is mark the argument at location x
to contain a pointer to y
items of the type that the argument at index x
points to.
Example:
__attribute__((access(read_only,1,2)))
__attribute__((nonnull(1)))
void foo(const uint8_t* buf, size_t bufsize) {
// …
uint8_t bar = buf[bufsize]; // <- Throws warning
// …
}
Using the nonnull
attribute here also allows to skip the NULL
check, as the compiler ensures this can't be NULL
when this function is called.
from htop.
Related Issues (20)
- Swap utilization not being showed HOT 4
- not showing accurate memory usage (MacOS Ventura) HOT 3
- feature request: add an "available columns" to display count of fds HOT 1
- Can no longer invert sort order when displayed as a tree HOT 9
- Feature: Quick toggle for showing userland process' threads HOT 5
- htop is using much cpu itself HOT 5
- Segmentation fault in 3.3.0 under heavy CPU and memory load on Debian Trixie (testing, rolling release) HOT 4
- HTOP "free mem" value differs from value reported by TOP and FREE HOT 3
- Unexpected HTOP results – RAM usage increases more running termit than konsole HOT 4
- out-of-bounds access in the Header_populateFromSettings function (CVE-2024-37676) HOT 1
- make new color for dirty / writeback cache HOT 1
- Allowing Pause on Search HOT 5
- Insufficient contrast on light background HOT 3
- Distinguish in which disk IO is high HOT 2
- CPU meter is named Avg HOT 6
- Inconsistent spacing HOT 1
- random SEGFAULT HOT 6
- Fractional update intervals do not work
- autofreeze idle timer
- Segmentation fault when toggling threads visibility while paused HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from htop.