Skip to content

Commit

Permalink
Cast to 'double' explicitly on Meter_humanUnit() calls
Browse files Browse the repository at this point in the history
Signed-off-by: Kang-Che Sung <[email protected]>
  • Loading branch information
Explorer09 committed Nov 1, 2023
1 parent 9e14997 commit d31cbf7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions DiskIOMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static void DiskIOMeter_updateValues(Meter* this) {
} else {
diff = 0;
}
Meter_humanUnit(cached_read_diff_str, diff, sizeof(cached_read_diff_str));
Meter_humanUnit(cached_read_diff_str, (double)diff, sizeof(cached_read_diff_str));
cached_read_total = data.totalBytesRead;

if (data.totalBytesWritten > cached_write_total) {
Expand All @@ -80,7 +80,7 @@ static void DiskIOMeter_updateValues(Meter* this) {
} else {
diff = 0;
}
Meter_humanUnit(cached_write_diff_str, diff, sizeof(cached_write_diff_str));
Meter_humanUnit(cached_write_diff_str, (double)diff, sizeof(cached_write_diff_str));
cached_write_total = data.totalBytesWritten;

if (data.totalMsTimeSpend > cached_msTimeSpend_total) {
Expand Down
2 changes: 1 addition & 1 deletion linux/HugePageMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void HugePageMeter_updateValues(Meter* this) {
}
}

written = Meter_humanUnit(buffer, usedTotal, size);
written = Meter_humanUnit(buffer, (double)usedTotal, size);
METER_BUFFER_CHECK(buffer, size, written);

METER_BUFFER_APPEND_CHR(buffer, size, '/');
Expand Down
16 changes: 8 additions & 8 deletions pcp/PCPDynamicMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,22 +351,22 @@ void PCPDynamicMeter_updateValues(PCPDynamicMeter* this, Meter* meter) {
break;
case PM_TYPE_32:
bytes += conv.dimSpace ?
Meter_humanUnit(buffer + bytes, atom.l, size - bytes) :
Meter_humanUnit(buffer + bytes, (double)atom.l, size - bytes) :
xSnprintf(buffer + bytes, size - bytes, "%d", atom.l);
break;
case PM_TYPE_U32:
bytes += conv.dimSpace ?
Meter_humanUnit(buffer + bytes, atom.ul, size - bytes) :
Meter_humanUnit(buffer + bytes, (double)atom.ul, size - bytes) :
xSnprintf(buffer + bytes, size - bytes, "%u", atom.ul);
break;
case PM_TYPE_64:
bytes += conv.dimSpace ?
Meter_humanUnit(buffer + bytes, atom.ll, size - bytes) :
Meter_humanUnit(buffer + bytes, (double)atom.ll, size - bytes) :
xSnprintf(buffer + bytes, size - bytes, "%lld", (long long) atom.ll);
break;
case PM_TYPE_U64:
bytes += conv.dimSpace ?
Meter_humanUnit(buffer + bytes, atom.ull, size - bytes) :
Meter_humanUnit(buffer + bytes, (double)atom.ull, size - bytes) :
xSnprintf(buffer + bytes, size - bytes, "%llu", (unsigned long long) atom.ull);
break;
case PM_TYPE_FLOAT:
Expand Down Expand Up @@ -427,22 +427,22 @@ void PCPDynamicMeter_display(PCPDynamicMeter* this, ATTR_UNUSED const Meter* met
break;
case PM_TYPE_32:
len = conv.dimSpace ?
Meter_humanUnit(buffer, atom.l, sizeof(buffer)) :
Meter_humanUnit(buffer, (double)atom.l, sizeof(buffer)) :
xSnprintf(buffer, sizeof(buffer), "%d", atom.l);
break;
case PM_TYPE_U32:
len = conv.dimSpace ?
Meter_humanUnit(buffer, atom.ul, sizeof(buffer)) :
Meter_humanUnit(buffer, (double)atom.ul, sizeof(buffer)) :
xSnprintf(buffer, sizeof(buffer), "%u", atom.ul);
break;
case PM_TYPE_64:
len = conv.dimSpace ?
Meter_humanUnit(buffer, atom.ll, sizeof(buffer)) :
Meter_humanUnit(buffer, (double)atom.ll, sizeof(buffer)) :
xSnprintf(buffer, sizeof(buffer), "%lld", (long long) atom.ll);
break;
case PM_TYPE_U64:
len = conv.dimSpace ?
Meter_humanUnit(buffer, atom.ull, sizeof(buffer)) :
Meter_humanUnit(buffer, (double)atom.ull, sizeof(buffer)) :
xSnprintf(buffer, sizeof(buffer), "%llu", (unsigned long long) atom.ull);
break;
case PM_TYPE_FLOAT:
Expand Down

0 comments on commit d31cbf7

Please sign in to comment.