Christian Göttsche
4e2b9f0965
Avoid shadowing warnings
6 years ago
Daniel Flanagan
dd33444f7e
Clean up existing whitespace
6 years ago
smattie
1886117c72
Linux: fixes sysfs battery discovery
7 years ago
Hisham Muhammad
b064d501ae
linux/Battery.c: make sure fd is always closed
...
Detected by Coverity:
https://scan8.coverity.com/reports.htm#v13252/p10402/fileInstanceId=22093957&defectInstanceId=7543348&mergedDefectId=174180
8 years ago
Jan Chren (rindeal)
b0588d90ff
parseBatInfo: check `line` for NULL before passing it to String_getToken()
8 years ago
Hisham Muhammad
09e241fb12
Security review: check results of snprintf.
...
Calls marked with xSnprintf shouldn't fail.
Abort program cleanly if any of them does.
9 years ago
Hisham Muhammad
f205f7004c
Use regular readdir since readdir_r is deprecated and newer GCC complains.
9 years ago
Hisham
bb8dec1582
Cap battery at 100%.
...
Apparently invalid results can be returned by buggy drivers in old laptops,
as reported by @thukydides . See #596 .
9 years ago
Explorer09
bf35921abb
Optimize Strings_startWith()
...
Use strncmp() combined with a strlen() will give better performance
than a strstr in worst case. Especially when the match prefix is a
constant and not a variable.
While we are at it, replace the match() function in linux/Battery.c,
which uses a naive algorithm, with a macro that does better job by
utilizing Strings_startWith().
$ gcc --version | head -n 1
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
$ uname -m
x86_64
$ size htop.old htop.new
text data bss dec hex filename
137929 15112 3776 156817 26491 htop.old
137784 15104 3776 156664 263f8 htop.new
Signed-off-by: Kang-Che Sung <explorer09 @ gmail.com>
10 years ago
Hisham Muhammad
0fa03322a9
Dynamically adjust the size of line reads
...
* Dynamically adjust the size of line reads.
* Remove some more uses of fgets with arbitrary sizes.
* Fix reading of lines and width of n column.
Fixes #514 .
10 years ago
Hisham
b54d2dde40
Check for failure in allocations.
10 years ago
David Hunt
5e602f18d5
Rename String to StringUtils.
...
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
11 years ago
Hisham Muhammad
50000d808e
Silence warnings reported in #70 .
11 years ago
Hisham Muhammad
c2108e5a48
Another mega-patch for the refactoring process.
...
Kinda runs, but functionality from the original main loop
is still missing. Patience.
11 years ago
Hisham Muhammad
430c7c9a9b
Move platform-dependent parts of Linux battery meter.
11 years ago
Hisham Muhammad
9eec37c432
More sanity checks.
12 years ago
Hisham Muhammad
50b701258d
Make static analyzers happy.
12 years ago
Hisham Muhammad
814ce89b45
Oops, fix use of memset.
12 years ago
Hisham Muhammad
659251c501
Fix array limit.
12 years ago
Hisham Muhammad
2fdebf6a29
Remove useless test.
12 years ago
Hisham Muhammad
b1564c2be9
Refactor and fix resource leaks.
12 years ago
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!)
12 years ago
Hisham Muhammad
00b324bfc1
Changes in object model: separate class objects to store vtable. Also, nicer UTF-8 display of big numbers.
13 years ago
Hisham Muhammad
58676d7001
minor style cleanups
14 years ago
Hisham Muhammad
45f7a4fc8d
Remove old memory debugging routines. We have Valgrind nowadays.
14 years ago
Hisham Muhammad
84281bdc44
major header cleanup
14 years ago
Hisham Muhammad
d1b1cbc757
cleanups and fixes, thanks to cppcheck and gcc -Wextra
15 years ago
Hisham Muhammad
300caa076e
Tempus fugit.
15 years ago
Hisham Muhammad
3fcbcbfda6
Improve battery meter support (thanks to Richard W.) Closes #3063541 .
16 years ago
Hisham Muhammad
a600d5a6e9
Tempus fugit.
16 years ago
Hisham Muhammad
02a30bfecd
warning fixes
16 years ago
Hisham Muhammad
c9e59b4a33
minor tweaks by David Weber
16 years ago
Hisham Muhammad
1371ee28a7
don't use unbounded operations
17 years ago
Hisham Muhammad
20bb68824d
updated battery meter code from Ian Hands, slightly tweaked
17 years ago
Hisham Muhammad
11931f1bc8
ACPI Battery meter
...
contributed by Ian Hands
18 years ago