}
int pakfire_format_size(char* dst, size_t length, double value) {
- const char* units[] = {" ", "k", "M", "G", "T", NULL};
+ const char* units[] = {
+ "%4.0f ",
+ "%4.0fk",
+ "%4.1fM",
+ "%4.1fG",
+ "%4.1fT",
+ NULL
+ };
const char** unit = units;
while (*(unit + 1) && value >= 1024.0) {
unit++;
}
- return snprintf(dst, length, "%.0f%s", round(value), *unit);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ return snprintf(dst, length, *unit, round(value));
+#pragma GCC diagnostic pop
}
#pragma GCC diagnostic push