qemu-cr16/docs
Markus Armbruster 5bd89761a4 qapi/command: Avoid generating unused qmp_marshal_output_T()
qmp_marshal_output_T() is only ever called by qmp_marshal_C() for a
command C that returns type T.

We've always generated it as a static function on demand, i.e. when we
generate a call.

Since we split up monolithic generated code into modules (commit
252dc3105f "qapi: Generate separate .h, .c for each module"), we do
this per module.  As noted in the commit message, this can result in
identical (static) qmp_marshal_output_T() in several modules.  Was
deemed not worth avoiding.

A bit later, we added 'if' conditionals to the schema language (merge
commit 5dafaf4fbc).

When a conditional definition uses a type, then its condition must
imply the type's condition.  We made this the user's responsibility.
Hasn't been an issue in practice.

However, the sharing of qmp_marshal_output_T() among commands
complicates matters.  To avoid both undefined function errors and
unused function warnings, qmp_marshal_output_T() must be defined
exactly when it's used.  It is used when any of the qmp_marshal_C()
calling it is defined, i.e. when any C's condition holds.

The generator uses T's condition instead.  To avoid both error and
warning, T's condition must be the conjunction of all C's conditions.

Unfortunately, this can be impossible:

* Conditional command returning a builtin type

  A builtin type cannot be conditional.  This is noted in a FIXME
  comment.

* Commands in multiple modules where the conjunction differs between
  modules

  An instance of this came up recently.  we have unconditional
  commands returning HumanReadableText.  If we add a conditional one
  to a module that does not have unconditional ones, compilation fails
  with "defined but not used".  If we make HumanReadableText
  conditional to fix this module, we break the others.

Instead of complicating the code to compute the conjunction, simplify
it: generate the output marshaling code right into qmp_marshal_C().

This duplicates it when multiple commands return the same type.  The
impact on code size is negligible: qemu-system-x86_64's text segment
grows by 1448 bytes.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20250804130602.903904-1-armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
[Commit message typos fixed]
2025-11-04 13:34:20 +01:00
..
_templates
about Audio clean-ups 2025-11-01 10:51:32 +01:00
config vl: recognize audiodev groups in configuration files 2023-09-22 17:35:11 +02:00
devel qapi/command: Avoid generating unused qmp_marshal_output_T() 2025-11-04 13:34:20 +01:00
interop docs/interop/firmware: Add riscv64 to FirmwareArchitecture 2025-10-02 15:08:36 +10:00
specs hw/nvme: connect SPDM over NVMe Security Send/Recv 2025-10-30 07:07:14 +01:00
sphinx scripts/kerneldoc: Switch to the Python kernel-doc script 2025-08-30 16:37:23 +01:00
sphinx-static treewide: remove unnessary "coding" header 2025-10-01 11:22:07 -04:00
spin treewide: fix paths for relocated files in comments 2025-07-02 18:26:27 +02:00
system target-arm queue: 2025-11-01 10:52:48 +01:00
tools qemu-img info: Add cache mode option 2025-10-29 12:10:10 +01:00
user linux-user: Drop deprecated -p option 2025-08-30 07:00:20 +10:00
block-replication.txt
bypass-iommu.txt
COLO-FT.txt chardev: finalize 'reconnect' deprecation 2024-10-28 14:37:25 +08:00
colo-proxy.txt colo: examples: remove mentions of script= and (wrong) downscript= 2024-01-30 21:20:20 +03:00
conf.py treewide: remove unnessary "coding" header 2025-10-01 11:22:07 -04:00
defs.rst.inc
glossary.rst docs: Add mshv to documentation 2025-10-09 09:48:31 +02:00
igd-assign.txt vfio/igd: Require host VGA decode for legacy mode 2025-07-28 17:52:34 +02:00
image-fuzzer.txt
index.rst docs: add a glossary 2025-01-17 10:45:54 +00:00
memory-hotplug.txt
meson.build 9p: remove 'proxy' filesystem backend driver 2024-10-03 19:33:25 +02:00
multi-thread-compression.txt docs tests: Fix use of migrate_set_parameter 2023-09-08 13:08:52 +03:00
multiseat.txt
nvdimm.txt
pci_expander_bridge.txt docs, tests: do not specify scsi=off 2024-06-05 11:00:56 +02:00
pcie.txt docs/pcie.txt: Replace ioh3420 with pcie-root-port 2023-01-28 06:21:30 -05:00
pcie_pci_bridge.txt
pcie_sriov.txt pcie_sriov: Fix broken MMIO accesses from SR-IOV VFs 2025-10-05 09:01:08 -04:00
qcow2-cache.txt docs/interop: convert text files to restructuredText 2025-05-29 17:45:10 +01:00
qdev-device-use.txt docs: Update mentions of removed '-soundhw' command line option 2025-10-22 08:55:28 +02:00
qemu-option-trace.rst.inc
qemupciserial.inf
rdma.txt docs tests: Fix use of migrate_set_parameter 2023-09-08 13:08:52 +03:00
requirements.txt docs: Bump sphinx to 6.2.1 2025-07-16 17:02:46 +02:00
spice-port-fqdn.txt
throttle.txt
xbzrle.txt
xen-save-devices-state.txt