Tell the compiler that string_format is a printf-style function
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2022-12-17 12:45:26 +01:00
parent 16e00bada0
commit 16954695dd
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 3 additions and 3 deletions

View File

@ -16,4 +16,4 @@ usize pure_cstyle_format(const char* format, pure_callback_t callback, void* arg
usize vstring_format(char* buf, usize max, const char* format, va_list ap);
// Convenience function which outputs into a fixed-size buffer (not unlike snprintf)
usize string_format(char* buf, usize max, const char* format, ...);
usize string_format(char* buf, usize max, const char* format, ...) _format(3, 4);

View File

@ -6,7 +6,7 @@
usize to_dynamic_unit_cstr(usize value, char* buffer, usize max)
{
if (value < 1024) { return string_format(buffer, max, "%u bytes", value); }
if (value < 1024) { return string_format(buffer, max, "%zu bytes", value); }
const char* unit_prefixes = "KMGTPE";
while (value > (1024 * 1024))
@ -15,7 +15,7 @@ usize to_dynamic_unit_cstr(usize value, char* buffer, usize max)
unit_prefixes++;
}
return string_format(buffer, max, "%u.%u %ciB", value / 1024, (value % 1024) / 103, *unit_prefixes);
return string_format(buffer, max, "%zu.%zu %ciB", value / 1024, (value % 1024) / 103, *unit_prefixes);
}
Result<OwnedStringView> to_dynamic_unit(usize value)