This allows removing a needlessly complex and tricky function (I dare you 
understanding what it actually does the first time around) in which we even 
introduced subtle (but luckily invisible for now) bugs over time as it was 
probably not understood properly, and more sensitive to breakage than it ought 
to be.

It also actually improves results, as we unit for bytes, and proper translation 
for the units.

Note that this switches to SI units, which is probably actually better.

We could use `g_format_size_full(..., G_FORMAT_SIZE_IEC_UNITS)` if we wanted to 
keep EIC units though.

---

If it doesn't transpire enough through my rant above, kills 
`utils_make_human_readable_str()` which is more "look, I'm 
clever" than actually neat.  It is utterly non-obvious by having 
conditional format strings with different number of arguments, yet passing the 
same ones to the formatter… and no, it's not simply discarding the last 
one.  Plus, over time types were carelessly changed making things ever more 
shady, yet somehow calling conventions saved us all this time.

Anyway, since GLib 2.30 (old enough for our current requirements) we can use a 
ready-made version that even gives better results.

I actually stumbled on this gem trying to hunt GCC warnings, and it was one of 
those `-Wformat-nonliteral` ones.  This one is easy enough: just nuke it out of 
the sky!
You can view, comment on, or merge this pull request online at:

  https://github.com/geany/geany/pull/3657

-- Commit Summary --

  * Replace utils_make_human_readable_str() with g_format_size()

-- File Changes --

    M src/dialogs.c (2)
    M src/utils.c (49)
    M src/utils.h (3)

-- Patch Links --

https://github.com/geany/geany/pull/3657.patch
https://github.com/geany/geany/pull/3657.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3657
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/pull/3...@github.com>

Reply via email to