diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-02-07 13:23:59 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-02-07 13:23:59 -0800 |
| commit | ebbc4ada399c39d4ec25879c9ac8bb3ff3a3360f (patch) | |
| tree | 4bd9223990984e16ac1ab71a60538ff1f5cca63b /draw.c | |
| parent | 7c4eacd1b86b8a5ed8b889066d01e35f2a0f42b4 (diff) | |
Simplified safety check
Diffstat (limited to 'draw.c')
| -rw-r--r-- | draw.c | 6 |
1 files changed, 1 insertions, 5 deletions
@@ -184,13 +184,9 @@ void col_size(entry_t *entry, const char *color, char *buf, int width) int mag = 0; const char* units = "BKMGTPEZY"; double bytes = (double)entry->info.st_size; - while (bytes > 1024) { + while (bytes > 1024 && units[mag+1]) { bytes /= 1024; mag++; - if (!units[mag]) { - sprintf(buf, " ???"); - return; - } } // Add 1 extra digit of precision if it would be nonzero: sprintf(buf, "%5.*f%c ", ((int)(bytes*10.0 + 0.5)%10 >= 1) ? 1 : 0, bytes, units[mag]); |
