diff options
| author | Mole Shang <135e2@135e2.dev> | 2023-08-06 14:08:47 +0800 | 
|---|---|---|
| committer | Mole Shang <135e2@135e2.dev> | 2023-08-07 15:54:31 +0800 | 
| commit | fcbaf0c1a807f7c77baf84972810d9b0229bfaf7 (patch) | |
| tree | 9ffb01d3eca0957d1aaad92bf8127bfc9063cc00 | |
| parent | e164824b802f9190055d338446a2d8a251efabe1 (diff) | |
| download | hinata-fcbaf0c1a807f7c77baf84972810d9b0229bfaf7.tar.gz hinata-fcbaf0c1a807f7c77baf84972810d9b0229bfaf7.tar.bz2 hinata-fcbaf0c1a807f7c77baf84972810d9b0229bfaf7.zip | |
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
| -rw-r--r-- | src/ui.c | 5 | 
1 files changed, 3 insertions, 2 deletions
| @@ -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 | 
