xemu/softmmu
Philippe Mathieu-Daudé 077195187b hw/nvram/fw_cfg: Let fw_cfg_add_from_generator() return boolean value
Commits b6d7e9b66f..a43770df5d simplified the error propagation.
Similarly to commit 6fd5bef10b "qom: Make functions taking Error**
return bool, not void", let fw_cfg_add_from_generator() return a
boolean value, not void.
This allow to simplify parse_fw_cfg() and fixes the error handling
issue reported by Coverity (CID 1430396):

  In parse_fw_cfg():

    Variable assigned once to a constant guards dead code.

    Local variable local_err is assigned only once, to a constant
    value, making it effectively constant throughout its scope.
    If this is not the intent, examine the logic to see if there
    is a missing assignment that would make local_err not remain
    constant.

It's the call of fw_cfg_add_from_generator():

        Error *local_err = NULL;

        fw_cfg_add_from_generator(fw_cfg, name, gen_id, errp);
        if (local_err) {
            error_propagate(errp, local_err);
            return -1;
        }
        return 0;

If it fails, parse_fw_cfg() sets an error and returns 0, which is
wrong. Harmless, because the only caller passes &error_fatal.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Fixes: Coverity CID 1430396: 'Constant' variable guards dead code (DEADCODE)
Fixes: 6552d87c48 ("softmmu/vl: Let -fw_cfg option take a 'gen_id' argument")
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200721131911.27380-3-philmd@redhat.com>
2020-07-21 16:47:54 +02:00
..
Makefile.objs cpu-throttle: new module, extracted from cpus.c 2020-07-10 18:04:49 -04:00
arch_init.c 8bit AVR port from Michael Rolnik. 2020-07-11 19:27:59 +01:00
balloon.c softmmu: move softmmu only files from root 2020-07-10 18:02:24 -04:00
cpu-throttle.c cpu-throttle: new module, extracted from cpus.c 2020-07-10 18:04:49 -04:00
cpus.c cpu-throttle: new module, extracted from cpus.c 2020-07-10 18:04:49 -04:00
ioport.c softmmu: move softmmu only files from root 2020-07-10 18:02:24 -04:00
main.c softmmu: split off vl.c:main() into main.c 2020-02-22 08:26:47 +00:00
memory.c softmmu: move softmmu only files from root 2020-07-10 18:02:24 -04:00
memory_mapping.c softmmu: move softmmu only files from root 2020-07-10 18:02:24 -04:00
qtest.c softmmu: move softmmu only files from root 2020-07-10 18:02:24 -04:00
vl.c hw/nvram/fw_cfg: Let fw_cfg_add_from_generator() return boolean value 2020-07-21 16:47:54 +02:00