qemu-cr16/scripts
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
..
ci scripts/ci: modify gitlab runner deb setup 2025-10-29 14:12:43 +00:00
coccinelle system/physmem: Remove legacy cpu_physical_memory_rw() 2025-10-07 05:03:56 +02:00
codeconverter audio: move audio.h under include/qemu/ 2025-10-30 22:56:51 +04:00
coverage
coverity-scan scripts/coverity-scan/COMPONENTS.md: Add a 'plugins' category 2025-09-02 17:57:05 +02:00
kvm target/i386: enumerate VMX nested-exception support 2024-06-08 10:33:38 +02:00
lib/kdoc scripts/kernel-doc: tweak for QEMU coding standards 2025-08-30 16:37:23 +01:00
modules
oss-fuzz treewide: remove unnessary "coding" header 2025-10-01 11:22:07 -04:00
performance scripts/: spelling fixes 2023-09-08 13:08:52 +03:00
qapi qapi/command: Avoid generating unused qmp_marshal_output_T() 2025-11-04 13:34:20 +01:00
qemu-guest-agent scripts/qemu-guest-agent/fsfreeze-hook: improve script description 2025-10-30 14:51:44 +02:00
qemugdb treewide: remove unnessary "coding" header 2025-10-01 11:22:07 -04:00
qmp
rust rust: fix path to rust_root_crate.sh 2025-10-09 09:48:35 +02:00
simplebench scripts/: spelling fixes 2023-09-08 13:08:52 +03:00
tracetool tracetool/syslog: add Rust support 2025-10-01 11:22:07 -04:00
analyse-9p-simpletrace.py
analyse-locks-simpletrace.py treewide: remove unnessary "coding" header 2025-10-01 11:22:07 -04:00
analyze-inclusions include/system: Move exec/memory.h to system/memory.h 2025-04-23 14:08:21 -07:00
analyze-migration.py migration: Add MIG_CMD_SWITCHOVER_START and its load handler 2025-03-06 06:47:33 +01:00
archive-source.sh subprojects: add glib-sys-rs 2025-10-03 15:14:48 +02:00
arm_processor_error.py scripts/ghes_inject: add a script to generate GHES error inject 2025-10-05 08:17:08 -04:00
block-coroutine-wrapper.py block-coroutine-wrapper: use qemu_get_current_aio_context() 2023-12-21 22:49:28 +01:00
check_sparse.py
checkpatch.pl scripts/checkpatch: Avoid recommending legacy qemu_bh_new_guarded() 2025-10-06 10:12:01 -04:00
clean-header-guards.pl
clean-includes include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
clean_functional_cache.py tests: Evict stale files in the functional download cache after a while 2025-10-16 17:44:32 +02:00
cleanup-trace-events.pl
cocci-macro-file.h win32: remove usage of attribute gcc_struct 2025-01-17 10:45:13 +00:00
compare-machine-types.py scripts: add script to compare compatibility properties 2024-04-25 10:12:48 +02:00
cpu-x86-uarch-abi.py scripts: drop comment about autogenerated CPU API file 2024-02-09 12:48:07 +00:00
decodetree.py decodetree: Infer argument set before inferring format 2025-07-25 10:31:45 +01:00
device-crash-test scripts: replace FSF postal address with licenses URL 2025-06-26 00:42:37 +02:00
disas-objdump.pl
dump-guest-memory.py
entitlement.sh
extract-vsssdk-headers
feature_to_c.py gdbstub: Add members to identify registers to GDBFeature 2024-02-28 09:10:11 +00:00
fix-multiline-comments.sh
get-wraps-from-cargo-registry.py scripts: add script to help distros use global Rust packages 2025-07-25 14:51:05 +02:00
get_maintainer.pl scripts/get_maintainer.pl: don't print parentheses 2023-10-17 15:20:53 +02:00
ghes_inject.py scripts/ghes_inject: add a script to generate GHES error inject 2025-10-05 08:17:08 -04:00
git-submodule.sh scripts/git-submodule.sh: Don't rely on non-POSIX 'read' behaviour 2023-07-25 10:56:51 +01:00
git.orderfile
hxtool
kernel-doc.py scripts: Import Python kerneldoc from Linux kernel 2025-08-30 16:37:23 +01:00
make-config-poison.sh
make-release subprojects: add attrs crate 2025-09-22 17:17:18 +02:00
meson-buildoptions.py scripts: clean up meson-buildoptions.py 2025-10-28 12:39:59 +01:00
meson-buildoptions.sh * i386: fix migration issues in 10.1 2025-10-09 07:59:01 -07:00
meson.build
minikconf.py scripts/minikconf.py: s/Error/KconfigParserError 2025-08-20 22:47:54 +02:00
modinfo-collect.py treewide: remove unnessary "coding" header 2025-10-01 11:22:07 -04:00
modinfo-generate.py treewide: remove unnessary "coding" header 2025-10-01 11:22:07 -04:00
mtest2make.py tests/qtest: add TIMEOUT_MULTIPLIER 2024-12-12 10:25:38 -03:00
nsis.py Fix objdump output parser in "nsis.py" 2025-04-13 13:45:41 +03:00
probe-gdb-support.py treewide: remove unnessary "coding" header 2025-10-01 11:22:07 -04:00
python_qmp_updater.py scripts: add python_qmp_updater.py 2023-10-12 14:21:44 -04:00
qapi-gen.py
qcow2-to-stdout.py scripts/qcow2-to-stdout.py: Add script to write qcow2 images to stdout 2025-03-13 17:57:23 +01:00
qemu-binfmt-conf.sh binfmt: Add --ignore-family option 2025-03-04 15:42:54 +10:00
qemu-gdb.py scripts/qemu-gdb: Always do full stack dump for python errors 2025-02-06 13:59:00 +01:00
qemu-plugin-symbols.py treewide: remove unnessary "coding" header 2025-10-01 11:22:07 -04:00
qemu-stamp.py
qemu-trace-stap scripts: improve error from qemu-trace-stap on missing 'stap' 2025-02-12 10:03:18 -05:00
qemu-version.sh
qmp_helper.py scripts/ghes_inject: add a script to generate GHES error inject 2025-10-05 08:17:08 -04:00
qom-cast-macro-clean-cocci-gen.py licenses: Remove SPDX tags not being license identifier for Linaro 2025-01-30 13:01:22 +03:00
rdma-migration-helper.sh qtest/migration/rdma: Add test for rdma migration with ipv6 2025-05-20 11:26:32 -04:00
refresh-pxe-roms.sh
render_block_graph.py python/qemu: rename command() to cmd() 2023-10-12 14:21:43 -04:00
replay-dump.py treewide: remove unnessary "coding" header 2025-10-01 11:22:07 -04:00
rust-to-clang-target-test.sh configure: set the bindgen cross target 2025-09-30 19:33:25 +04:00
rust-to-clang-target.sh configure: set the bindgen cross target 2025-09-30 19:33:25 +04:00
shaderinclude.py
signrom.py
simpletrace.py simpletrace: added simplified Analyzer2 class 2023-09-26 12:28:51 -04:00
symlink-install-tree.py scripts/symlink-install-tree.py: Fix MESONINTROSPECT parsing 2024-10-29 15:04:46 +00:00
tracetool.py treewide: remove unnessary "coding" header 2025-10-01 11:22:07 -04:00
u2f-setup-gen.py
undefsym.py
update-linux-headers.sh * i386: fix migration issues in 10.1 2025-10-09 07:59:01 -07:00
update-mips-syscall-args.sh
update-syscalltbl.sh linux-user,loongarch: move to syscalltbl file 2024-09-22 09:30:18 +02:00
userfaultfd-wrlat.py tests, scripts: Don't import print_function from __future__ 2025-09-16 17:31:53 +01:00
vmstate-static-checker.py scripts/vmstate-static-checker.py: Add new hpet entry for num_timers 2025-05-20 11:26:32 -04:00
xen-detect.c
xml-preprocess-test.py
xml-preprocess.py scripts/xml-preprocess: Make sure this script is invoked via the right Python 2023-10-12 00:37:39 +03:00