Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pcp/PCPDynamicColumn.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ void PCPDynamicColumn_writeAtomValue(PCPDynamicColumn* column, RichString* str,
}

if (atomvalue == NULL) {
n = xSnprintf(buffer, sizeof(buffer), "%*.*s ", width, abswidth, "N/A");
n = pmsprintf(buffer, sizeof(buffer), "%*.*s ", width, abswidth, "N/A");
RichString_appendnAscii(str, CRT_colors[PROCESS_SHADOW], buffer, n);
return;
}
Expand All @@ -396,13 +396,13 @@ void PCPDynamicColumn_writeAtomValue(PCPDynamicColumn* column, RichString* str,
value += 5;
else if (strcmp(column->format, "cgroup") == 0 && (dupd2 = CGroup_filterName(value)))
value = dupd2;
n = xSnprintf(buffer, sizeof(buffer), "%*.*s ", width, abswidth, value);
n = pmsprintf(buffer, sizeof(buffer), "%*.*s ", width, abswidth, value);
if (dupd2)
free(dupd2);
} else if (value) {
n = xSnprintf(buffer, sizeof(buffer), "%*.*s ", width, abswidth, value);
n = pmsprintf(buffer, sizeof(buffer), "%*.*s ", width, abswidth, value);
} else {
n = xSnprintf(buffer, sizeof(buffer), "%*.*s ", width, abswidth, "N/A");
n = pmsprintf(buffer, sizeof(buffer), "%*.*s ", width, abswidth, "N/A");
}
if (dupd1)
free(dupd1);
Expand All @@ -413,7 +413,7 @@ void PCPDynamicColumn_writeAtomValue(PCPDynamicColumn* column, RichString* str,
/* deal with any numeric value - first, normalize units to bytes/seconds */
double value;
if (PCPDynamicColumn_normalize(desc, atomvalue, &value) < 0) {
n = xSnprintf(buffer, sizeof(buffer), "%*.*s ", width, abswidth, "no conv");
n = pmsprintf(buffer, sizeof(buffer), "%*.*s ", width, abswidth, "no conv");
RichString_appendnAscii(str, CRT_colors[METER_VALUE_ERROR], buffer, n);
return;
}
Expand All @@ -425,7 +425,7 @@ void PCPDynamicColumn_writeAtomValue(PCPDynamicColumn* column, RichString* str,
return;
}
if (strcmp(column->format, "process") == 0) {
n = xSnprintf(buffer, sizeof(buffer), "%*d ", Row_pidDigits, (int)value);
n = pmsprintf(buffer, sizeof(buffer), "%*d ", Row_pidDigits, (int)value);
RichString_appendnAscii(str, attr, buffer, n);
return;
}
Expand All @@ -434,9 +434,9 @@ void PCPDynamicColumn_writeAtomValue(PCPDynamicColumn* column, RichString* str,
/* width overrides unit suffix and coloring; too complex for a corner case */
if (column->width) {
if (value - (unsigned long long)value > 0) /* display floating point */
n = xSnprintf(buffer, sizeof(buffer), "%*.2f ", width, value);
n = pmsprintf(buffer, sizeof(buffer), "%*.2f ", width, value);
else /* display as integer */
n = xSnprintf(buffer, sizeof(buffer), "%*llu ", width, (unsigned long long)value);
n = pmsprintf(buffer, sizeof(buffer), "%*llu ", width, (unsigned long long)value);
RichString_appendnAscii(str, CRT_colors[PROCESS], buffer, n);
return;
}
Expand Down
34 changes: 17 additions & 17 deletions pcp/PCPDynamicMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,51 +352,51 @@ void PCPDynamicMeter_updateValues(PCPDynamicMeter* this, Meter* meter) {
size_t saved = bytes;
switch (desc->type) {
case PM_TYPE_STRING:
bytes += xSnprintf(buffer + bytes, size - bytes, "%s", atom.cp);
bytes += pmsprintf(buffer + bytes, size - bytes, "%s", atom.cp);
free(atom.cp);
break;
case PM_TYPE_32:
bytes += conv.dimSpace ?
Meter_humanUnit(buffer + bytes, (double) atom.l, size - bytes) :
xSnprintf(buffer + bytes, size - bytes, "%d", atom.l);
pmsprintf(buffer + bytes, size - bytes, "%d", atom.l);
break;
case PM_TYPE_U32:
bytes += conv.dimSpace ?
Meter_humanUnit(buffer + bytes, (double) atom.ul, size - bytes) :
xSnprintf(buffer + bytes, size - bytes, "%u", atom.ul);
pmsprintf(buffer + bytes, size - bytes, "%u", atom.ul);
break;
case PM_TYPE_64:
bytes += conv.dimSpace ?
Meter_humanUnit(buffer + bytes, (double) atom.ll, size - bytes) :
xSnprintf(buffer + bytes, size - bytes, "%lld", (long long) atom.ll);
pmsprintf(buffer + bytes, size - bytes, "%lld", (long long) atom.ll);
break;
case PM_TYPE_U64:
bytes += conv.dimSpace ?
Meter_humanUnit(buffer + bytes, (double) atom.ull, size - bytes) :
xSnprintf(buffer + bytes, size - bytes, "%llu", (unsigned long long) atom.ull);
pmsprintf(buffer + bytes, size - bytes, "%llu", (unsigned long long) atom.ull);
break;
case PM_TYPE_FLOAT:
bytes += conv.dimSpace ?
Meter_humanUnit(buffer + bytes, (double) atom.f, size - bytes) :
xSnprintf(buffer + bytes, size - bytes, "%.2f", (double) atom.f);
pmsprintf(buffer + bytes, size - bytes, "%.2f", (double) atom.f);
break;
case PM_TYPE_DOUBLE:
bytes += conv.dimSpace ?
Meter_humanUnit(buffer + bytes, atom.d, size - bytes) :
xSnprintf(buffer + bytes, size - bytes, "%.2f", atom.d);
pmsprintf(buffer + bytes, size - bytes, "%.2f", atom.d);
break;
default:
break;
}

if (saved != bytes && metric->suffix)
bytes += xSnprintf(buffer + bytes, size - bytes, "%s", metric->suffix);
if (saved != bytes && metric->suffix && bytes < size)
bytes += pmsprintf(buffer + bytes, size - bytes, "%s", metric->suffix);
}

buffer[CLAMP(bytes, 0u, size - 1)] = '\0';

if (!bytes)
xSnprintf(buffer, size, "no data");
pmsprintf(buffer, size, "no data");
}

void PCPDynamicMeter_display(PCPDynamicMeter* this, ATTR_UNUSED const Meter* meter, RichString* out) {
Expand Down Expand Up @@ -433,38 +433,38 @@ void PCPDynamicMeter_display(PCPDynamicMeter* this, ATTR_UNUSED const Meter* met
int len = 0;
switch (desc->type) {
case PM_TYPE_STRING:
len = xSnprintf(buffer, sizeof(buffer), "%s", atom.cp);
len = pmsprintf(buffer, sizeof(buffer), "%s", atom.cp);
free(atom.cp);
break;
case PM_TYPE_32:
len = conv.dimSpace ?
Meter_humanUnit(buffer, (double) atom.l, sizeof(buffer)) :
xSnprintf(buffer, sizeof(buffer), "%d", atom.l);
pmsprintf(buffer, sizeof(buffer), "%d", atom.l);
break;
case PM_TYPE_U32:
len = conv.dimSpace ?
Meter_humanUnit(buffer, (double) atom.ul, sizeof(buffer)) :
xSnprintf(buffer, sizeof(buffer), "%u", atom.ul);
pmsprintf(buffer, sizeof(buffer), "%u", atom.ul);
break;
case PM_TYPE_64:
len = conv.dimSpace ?
Meter_humanUnit(buffer, (double) atom.ll, sizeof(buffer)) :
xSnprintf(buffer, sizeof(buffer), "%lld", (long long) atom.ll);
pmsprintf(buffer, sizeof(buffer), "%lld", (long long) atom.ll);
break;
case PM_TYPE_U64:
len = conv.dimSpace ?
Meter_humanUnit(buffer, (double) atom.ull, sizeof(buffer)) :
xSnprintf(buffer, sizeof(buffer), "%llu", (unsigned long long) atom.ull);
pmsprintf(buffer, sizeof(buffer), "%llu", (unsigned long long) atom.ull);
break;
case PM_TYPE_FLOAT:
len = conv.dimSpace ?
Meter_humanUnit(buffer, (double) atom.f, sizeof(buffer)) :
xSnprintf(buffer, sizeof(buffer), "%.2f", (double) atom.f);
pmsprintf(buffer, sizeof(buffer), "%.2f", (double) atom.f);
break;
case PM_TYPE_DOUBLE:
len = conv.dimSpace ?
Meter_humanUnit(buffer, atom.d, sizeof(buffer)) :
xSnprintf(buffer, sizeof(buffer), "%.2f", atom.d);
pmsprintf(buffer, sizeof(buffer), "%.2f", atom.d);
break;
default:
break;
Expand Down
6 changes: 3 additions & 3 deletions pcp/PCPDynamicScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static PCPDynamicColumn* PCPDynamicScreen_lookupMetric(PCPDynamicScreen* screen,

/* not an existing column in this screen - create it and add to the list */
column = xCalloc(1, sizeof(PCPDynamicColumn));
xSnprintf(column->super.name, sizeof(column->super.name), "%s:%s", screen->super.name, name);
pmsprintf(column->super.name, sizeof(column->super.name), "%s:%s", screen->super.name, name);
column->super.table = &screen->table->super;
column->metricName = metricName;
column->super.enabled = true;
Expand Down Expand Up @@ -409,9 +409,9 @@ void PCPDynamicScreens_addAvailableColumns(Panel* availableColumns, Hashtable* s
const char* text = column->super.description ? column->super.description : column->super.caption;
char description[256];
if (text)
xSnprintf(description, sizeof(description), "%s - %s", title, text);
pmsprintf(description, sizeof(description), "%s - %s", title, text);
else
xSnprintf(description, sizeof(description), "%s", title);
pmsprintf(description, sizeof(description), "%s", title);
Panel_add(availableColumns, (Object*) ListItem_new(description, j));
}
}
Loading