mirror of https://github.com/xzeldon/htop.git
Resolve conversion from int to unsigned and back
This commit is contained in:
parent
ba1549f99b
commit
1e9b184367
7
Meter.c
7
Meter.c
|
@ -51,7 +51,7 @@ Meter* Meter_new(const struct ProcessList_* pl, int param, const MeterClass* typ
|
||||||
int Meter_humanUnit(char* buffer, unsigned long int value, int size) {
|
int Meter_humanUnit(char* buffer, unsigned long int value, int size) {
|
||||||
const char* prefix = "KMGTPEZY";
|
const char* prefix = "KMGTPEZY";
|
||||||
unsigned long int powi = 1;
|
unsigned long int powi = 1;
|
||||||
unsigned int written, powj = 1, precision = 2;
|
unsigned int powj = 1, precision = 2;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (value / 1024 < powi)
|
if (value / 1024 < powi)
|
||||||
|
@ -73,10 +73,7 @@ int Meter_humanUnit(char* buffer, unsigned long int value, int size) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
written = snprintf(buffer, size, "%.*f%c",
|
return snprintf(buffer, size, "%.*f%c", precision, (double) value / powi, *prefix);
|
||||||
precision, (double) value / powi, *prefix);
|
|
||||||
|
|
||||||
return written;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Meter_delete(Object* cast) {
|
void Meter_delete(Object* cast) {
|
||||||
|
|
Loading…
Reference in New Issue