xaizek / d2if (License: GPLv2+) (since 2018-12-07)
Simple dzen2 input formatter, which is supposed to not waste CPU time for nothing and provides a number of builtin "widgets" for displaying system information.
Commit c93bc86b5fba7a16ef66a5dad862ef02e97e04c6

Fix integer overflow in Memory field impl
Weird that I didn't notice this before.
Author: xaizek
Author date (UTC): 2024-01-01 15:08
Committer name: xaizek
Committer date (UTC): 2024-01-01 15:08
Parent(s): cd1b3eaad50e62376819a6e6b51e0134350c3b07
Signing key: 99DC5E4DB05F6BE2
Tree: b5807aec3e0ef779d1254f824fa8589da77a4b67
File Lines added Lines deleted
src/Memory.cpp 3 2
File src/Memory.cpp changed (mode: 100644) (index cab13f3..8d01270)
20 20 #include <unistd.h> #include <unistd.h>
21 21
22 22 #include <cassert> #include <cassert>
23 #include <cstdint>
23 24
24 25 #include <fstream> #include <fstream>
25 26 #include <limits> #include <limits>
 
... ... int Memory::getMemoryUsage() const
61 62 return (-1); return (-1);
62 63 } }
63 64
64 int total, free, avail, buffers, cached;
65 std::uint64_t total, free, avail, buffers, cached;
65 66
66 67 meminfo.ignore(std::numeric_limits<std::streamsize>::max(), ':') >> total; meminfo.ignore(std::numeric_limits<std::streamsize>::max(), ':') >> total;
67 68 meminfo.ignore(std::numeric_limits<std::streamsize>::max(), ':') >> free; meminfo.ignore(std::numeric_limits<std::streamsize>::max(), ':') >> free;
 
... ... int Memory::getMemoryUsage() const
71 72
72 73 meminfo.close(); meminfo.close();
73 74
74 const int usage {
75 const std::uint64_t usage {
75 76 100 - ((free + buffers + cached)*100)/total 100 - ((free + buffers + cached)*100)/total
76 77 }; };
77 78
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/d2if

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/d2if

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master