Unique IDs considered harmful

…at least when there’s no hint about the exact arguments you’re supposed to use.

Guess what parameters should you pass for sprintf(buf, _("memo_li_kb"), ...)?

  1. Nothing
  2. 0
  3. (float)0.0
  4. (long long)0
  5. None of the above

Would it help if I told you valgrind is reporting Conditional jump or move depends on uninitialised value(s) if you use 2)?

As it happens the format string in this case is %lld kB but since the compiler never sees the format string (only the unique ID) it has no way of warning you when the argument type doesn’t match the format (warning: long long int format, different type arg (arg 2)). In fact all the “help” you get from the compiler is constant stream of false warnings (warning: too many arguments for format)

Now, repeat the exercise for unique IDs sfil_li_size_100B_10kB and sfil_li_size_10kB_100kB. You can probably guess the valid range in both cases, but see if it helps you 🙂

As an added twist after the format string bug was fixed the dialog in which it was shown was truncating the strings it was supposed to be showing. Earlier the string would be something like 4611910937274744832 kB because of the few uninitialised bytes, which is pretty much longer than the “correct” 0 kB.

Fix one bug and another one shows up. What else is new?