On 6/19/25 14:20, Philippe Mathieu-Daudé wrote:
@@ -756,7 +756,9 @@ static void sbsa_ref_init(MachineState *machine)
      sms->smp_cpus = smp_cpus;
      if (machine->ram_size > sbsa_ref_memmap[SBSA_MEM].size) {
-        error_report("sbsa-ref: cannot model more than %dGB RAM", RAMLIMIT_GB);
+        g_autofree char *size_str = size_to_str(RAMLIMIT_BYTES);
+
+        error_report("sbsa-ref: cannot model more than %s of RAM", size_str);
          exit(1);

Not a bug bug, but autofree has no effect because the block doesn't end before the call to exit.

Right. Isn't it better to use g_autofree as a general code pattern?


It's a case of "this doesn't do what you think it does", which is bad form.

If you are actually interested in freeing the string to avoid a false positive during leak analysis, wrap the two lines in another block:


    if (...) {
        {
            g_autofree ...
            error_report(...)
        }
        exit(1);
    }


r~

Reply via email to