qemu-e2k/docs/devel
Markus Armbruster 44ea9d9be3 qapi: Start to elide redundant has_FOO in generated C
In QAPI, absent optional members are distinct from any present value.
We thus represent an optional schema member FOO as two C members: a
FOO with the member's type, and a bool has_FOO.  Likewise for function
arguments.

However, has_FOO is actually redundant for a pointer-valued FOO, which
can be null only when has_FOO is false, i.e. has_FOO == !!FOO.  Except
for arrays, where we a null FOO can also be a present empty array.

The redundant has_FOO are a nuisance to work with.  Improve the
generator to elide them.  Uses of has_FOO need to be replaced as
follows.

Tests of has_FOO become the equivalent comparison of FOO with null.
For brevity, this is commonly done by implicit conversion to bool.

Assignments to has_FOO get dropped.

Likewise for arguments to has_FOO parameters.

Beware: code may violate the invariant has_FOO == !!FOO before the
transformation, and get away with it.  The above transformation can
then break things.  Two cases:

* Absent: if code ignores FOO entirely when !has_FOO (except for
  freeing it if necessary), even non-null / uninitialized FOO works.
  Such code is known to exist.

* Present: if code ignores FOO entirely when has_FOO, even null FOO
  works.  Such code should not exist.

In both cases, replacing tests of has_FOO by FOO reverts their sense.
We have to fix the value of FOO then.

To facilitate review of the necessary updates to handwritten code, add
means to opt out of this change, and opt out for all QAPI schema
modules where the change requires updates to handwritten code.  The
next few commits will remove these opt-outs in reviewable chunks, then
drop the means to opt out.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20221104160712.3005652-5-armbru@redhat.com>
2022-12-13 18:31:37 +01:00
..
acpi-bits.rst acpi/tests/avocado/bits: some misc fixes 2022-11-17 09:58:22 +01:00
atomics.rst qemu/atomic.h: rename atomic_ to qatomic_ 2020-09-23 16:07:44 +01:00
bitops.rst docs: Create bitops.rst as example of kernel-docs 2019-12-17 19:36:57 +01:00
blkdebug.txt docs/: fix some comment spelling errors 2020-09-17 20:37:13 +02:00
blkverify.txt meson: link emulators without Makefile.target 2020-08-21 06:30:40 -04:00
block-coroutine-wrapper.rst scripts: add block-coroutine-wrapper.py 2020-10-05 10:59:06 +01:00
build-system.rst configure: improve error for ucontext coroutine backend 2022-09-01 07:42:37 +02:00
ci-definitions.rst.inc tests/acceptance: rename tests acceptance to tests avocado 2021-11-08 17:00:22 +01:00
ci-jobs.rst.inc docs/devel: clean-up the CI links in the docs 2022-06-01 18:55:04 +01:00
ci-runners.rst.inc docs: name included files ".rst.inc" 2021-10-01 19:04:45 +02:00
ci.rst docs/devel: clean-up the CI links in the docs 2022-06-01 18:55:04 +01:00
clocks.rst clock: Provide builtin multiplier/divider 2021-09-01 11:08:19 +01:00
code-of-conduct.rst docs/devel: add a maintainers section to development process 2022-11-22 09:49:07 +00:00
conflict-resolution.rst docs: Add a QEMU Code of Conduct and Conflict Resolution Policy document 2021-04-01 13:21:02 +02:00
control-flow-integrity.rst Fix typo in CFI build documentation 2021-05-02 17:24:50 +02:00
decodetree.rst decodetree: Extend argument set syntax to allow types 2021-05-01 11:45:35 -07:00
ebpf_rss.rst docs/devel/ebpf_rss.rst: Format literals correctly 2021-08-02 11:42:38 +01:00
fuzzing.rst ui/cocoa: Run qemu_init in the main thread 2022-09-23 14:36:33 +02:00
index-api.rst docs/devel: drop :hidden: and :includehidden: tags 2022-04-20 16:04:20 +01:00
index-build.rst acpi/tests/avocado/bits/doc: add a doc file to describe the acpi bits test 2022-11-02 06:56:32 -04:00
index-internals.rst docs/devel: start documenting writing VirtIO devices 2022-05-16 04:38:40 -04:00
index-process.rst docs/devel: add a maintainers section to development process 2022-11-22 09:49:07 +00:00
index-tcg.rst docs: convert docs/devel/replay page to rst 2022-06-06 09:26:53 +02:00
index.rst docs/devel: drop :hidden: and :includehidden: tags 2022-04-20 16:04:20 +01:00
kconfig.rst * More Meson conversions (0.59.x now required rather than suggested) 2022-02-21 17:24:05 +00:00
loads-stores.rst Replace TARGET_WORDS_BIGENDIAN 2022-04-06 10:50:37 +02:00
lockcnt.txt docs: fix references to docs/devel/atomics.rst 2021-06-02 06:51:09 +02:00
maintainers.rst docs/devel: add a maintainers section to development process 2022-11-22 09:49:07 +00:00
memory.rst docs/devel: add some clarifying text for aliases 2022-01-18 12:56:29 +01:00
migration.rst migration: Remove load_state_old and minimum_version_id_old 2022-03-02 18:20:45 +00:00
modules.rst docs: Spell QEMU all caps 2021-11-19 10:16:58 +01:00
multi-process.rst docs: Render binary names as monospaced text 2021-11-22 15:02:38 +01:00
multi-thread-tcg.rst docs: Spell QEMU all caps 2021-11-19 10:16:58 +01:00
multiple-iothreads.txt block: remove bdrv_try_set_aio_context and replace it with bdrv_try_change_aio_context 2022-10-27 20:14:11 +02:00
qapi-code-gen.rst qapi: Start to elide redundant has_FOO in generated C 2022-12-13 18:31:37 +01:00
qgraph.rst Fix some typos in documentation (found by codespell) 2021-11-22 15:02:38 +01:00
qom.rst misc: fix commonly doubled up words 2022-08-01 11:58:02 +02:00
qtest.rst tests: move libqtest.h back under qtest/ 2022-05-03 15:16:51 +04:00
rcu.txt Docs/RCU: Correct sample code of qatomic_rcu_set 2021-01-12 12:38:03 +01:00
replay.rst docs: move replay docs to docs/system/replay.rst 2022-06-06 09:26:54 +02:00
reset.rst hw/core/resettable: fix reset level counting 2022-10-27 10:27:23 +01:00
s390-dasd-ipl.rst docs: rstfy s390 dasd ipl documentation 2020-02-26 18:57:07 +01:00
secure-coding-practices.rst docs/secure-coding-practices: Describe how to use 'null-co' block driver 2021-06-02 14:29:14 +02:00
stable-process.rst docs: Fix botched rST conversion of 'submitting-a-patch.rst' 2021-11-22 15:02:38 +01:00
style.rst doc/style: CLang -> Clang 2022-04-21 17:03:51 +04:00
submitting-a-patch.rst docs/devel: try and improve the language around patch review 2022-11-22 09:52:23 +00:00
submitting-a-pull-request.rst docs/devel: add a maintainers section to development process 2022-11-22 09:49:07 +00:00
tcg-icount.rst tcg: Drop gen_io_end() 2021-09-08 11:09:45 +01:00
tcg-plugins.rst docs/devel: document the test plugins 2022-10-06 11:53:40 +01:00
tcg.rst docs/devel: Explain in more detail the TB chaining mechanisms 2021-06-13 17:42:40 -07:00
testing.rst Fix some typos in documentation and comments 2022-11-05 20:35:45 +01:00
tracing.rst docs: trace-events-all is installed without renaming 2022-04-21 17:03:51 +04:00
trivial-patches.rst docs: Fix botched rST conversion of 'submitting-a-patch.rst' 2021-11-22 15:02:38 +01:00
ui.rst docs: Spell QEMU all caps 2021-11-19 10:16:58 +01:00
vfio-migration.rst docs/devel: Add VFIO device migration documentation 2021-06-18 08:38:04 -06:00
virtio-backends.rst docs/devel: start documenting writing VirtIO devices 2022-05-16 04:38:40 -04:00
virtio-migration.txt
writing-monitor-commands.rst qapi: Start to elide redundant has_FOO in generated C 2022-12-13 18:31:37 +01:00