From fcbaf0c1a807f7c77baf84972810d9b0229bfaf7 Mon Sep 17 00:00:00 2001 From: Mole Shang <135e2@135e2.dev> Date: Sun, 6 Aug 2023 14:08:47 +0800 Subject: ui: correct stat types' print format - Use libcurl's builtin macro CURL_FORMAT_CURL_OFF_T to correctly print status. - Cast pct to unsigned char as it should always <= 100 --- src/ui.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/ui.c') diff --git a/src/ui.c b/src/ui.c index 0692954..ff6f565 100644 --- a/src/ui.c +++ b/src/ui.c @@ -26,8 +26,9 @@ void load_ui(struct ui_struct *ui) { poll_status(ui->stat); if (ui->stat->total) { pct = (ui->stat->cur) * 100 / (ui->stat->total); - sprintf(status_string, "%lu/%lu, %lu%%", ui->stat->cur, ui->stat->total, - pct); + sprintf(status_string, + "%" CURL_FORMAT_CURL_OFF_T "/%" CURL_FORMAT_CURL_OFF_T ", %hhu%%", + ui->stat->cur, ui->stat->total, (unsigned char)pct); } if (ui->stat->is_done) { (ui->stat->total) = 0; // To prevent nuklear further updating status_string -- cgit v1.2.3