qemu-e2k/scripts
Michael Roth fc13d93726 qapi: zero-initialize all QMP command parameters
In general QMP command parameter values are specified by consumers of the
QMP/HMP interface, but in the case of optional parameters these values may
be left uninitialized.

It is considered a bug for code to make use of optional parameters that have
not been flagged as being present by the marshalling code (via corresponding
has_<parameter> parameter), however our marshalling code will still pass
these uninitialized values on to the corresponding QMP function (to then
be ignored). Some compilers (clang in particular) consider this unsafe
however, and generate warnings as a result. As reported by Peter Maydell:

  This is something clang's -fsanitize=undefined spotted. The
  code generated by qapi-commands.py in qmp-marshal.c for
  qmp_marshal_* functions where there are some optional
  arguments looks like this:

      bool has_force = false;
      bool force;

      mi = qmp_input_visitor_new_strict(QOBJECT(args));
      v = qmp_input_get_visitor(mi);
      visit_type_str(v, &device, "device", errp);
      visit_start_optional(v, &has_force, "force", errp);
      if (has_force) {
          visit_type_bool(v, &force, "force", errp);
      }
      visit_end_optional(v, errp);
      qmp_input_visitor_cleanup(mi);

      if (error_is_set(errp)) {
          goto out;
      }
      qmp_eject(device, has_force, force, errp);

  In the case where has_force is false, we never initialize
  force, but then we use it by passing it to qmp_eject.
  I imagine we don't then actually use the value, but clang
  complains in particular for 'bool' variables because the value
  that ends up being loaded from memory for 'force' is not either
  0 or 1 (being uninitialized stack contents).

Fix this by initializing all QMP command parameters to {0} in the
marshalling code prior to passing them on to the QMP functions.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-21 09:25:31 -04:00
..
kvm
qemu-guest-agent
qmp
tracetool trace: [tracetool] Minimize the amount of per-backend code 2014-05-07 19:07:18 +02:00
acpi_extract_preprocess.py
acpi_extract.py
analyse-9p-simpletrace.py
check-qerror.sh
checkpatch.pl
cleanup-trace-events.pl
coverity-model.c scripts: add sample model file for Coverity Scan 2014-04-18 10:33:36 +04:00
create_config
disas-objdump.pl
dump-guest-memory.py
extract-vsssdk-headers
feature_to_c.sh
get_maintainer.pl
gtester-cat
hxtool
make_device_config.sh
make-release make-release: Record SeaBIOS version 2014-03-31 15:02:04 +01:00
ordereddict.py
qapi-commands.py qapi: zero-initialize all QMP command parameters 2014-05-21 09:25:31 -04:00
qapi-types.py qapi: Use an explicit input file 2014-05-08 14:19:58 -04:00
qapi-visit.py qapi: Replace uncommon use of the error API by the common one 2014-05-15 14:00:46 -04:00
qapi.py scripts/qapi.py: Avoid syntax not supported by Python 2.4 2014-05-21 09:04:03 -04:00
qemu-binfmt-conf.sh scripts/qemu-binfmt-conf.sh: Add AArch64 registration 2014-03-17 16:31:53 +00:00
qemu-gdb.py
qtest
refresh-pxe-roms.sh
signrom.py
simpletrace.py trace: [tracetool] Minimize the amount of per-backend code 2014-05-07 19:07:18 +02:00
switch-timer-api
texi2pod.pl
tracetool.py
update-acpi.sh
update-linux-headers.sh