qapi block: Elide redundant has_FOO in generated C

The has_FOO for pointer-valued FOO are redundant, except for arrays.
They are also a nuisance to work with.  Recent commit "qapi: Start to
elide redundant has_FOO in generated C" provided the means to elide
them step by step.  This is the step for qapi/block*.json.

Said commit explains the transformation in more detail.

There is one instance of the invariant violation mentioned there:
qcow2_signal_corruption() passes false, "" when node_name is an empty
string.  Take care to pass NULL then.

The previous two commits cleaned up two more.

Additionally, helper bdrv_latency_histogram_stats() loses its output
parameters and returns a value instead.

Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Hanna Reitz <hreitz@redhat.com>
Cc: qemu-block@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20221104160712.3005652-11-armbru@redhat.com>
[Fixes for #ifndef LIBRBD_SUPPORTS_ENCRYPTION and MacOS squashed in]
This commit is contained in:
Markus Armbruster 2022-11-04 17:06:52 +01:00
parent 8461b4d601
commit 54fde4ff06
23 changed files with 173 additions and 281 deletions

View file

@ -2915,15 +2915,15 @@ static ImageInfoList *collect_image_info_list(bool image_opts,
image_opts = false;
if (chain) {
if (info->has_full_backing_filename) {
if (info->full_backing_filename) {
filename = info->full_backing_filename;
} else if (info->has_backing_filename) {
} else if (info->backing_filename) {
error_report("Could not determine absolute backing filename,"
" but backing filename '%s' present",
info->backing_filename);
goto err;
}
if (info->has_backing_filename_format) {
if (info->backing_filename_format) {
fmt = info->backing_filename_format;
}
}
@ -3046,7 +3046,7 @@ static int dump_map_entry(OutputFormat output_format, MapEntry *e,
printf("%#-16"PRIx64"%#-16"PRIx64"%#-16"PRIx64"%s\n",
e->start, e->length,
e->has_offset ? e->offset : 0,
e->has_filename ? e->filename : "");
e->filename ?: "");
}
/* This format ignores the distinction between 0, ZERO and ZERO|DATA.
* Modify the flags here to allow more coalescing.
@ -3127,7 +3127,6 @@ static int get_block_status(BlockDriverState *bs, int64_t offset,
.has_offset = has_offset,
.depth = depth,
.present = !!(ret & BDRV_BLOCK_ALLOCATED),
.has_filename = filename,
.filename = filename,
};
@ -3143,11 +3142,11 @@ static inline bool entry_mergeable(const MapEntry *curr, const MapEntry *next)
curr->data != next->data ||
curr->depth != next->depth ||
curr->present != next->present ||
curr->has_filename != next->has_filename ||
!curr->filename != !next->filename ||
curr->has_offset != next->has_offset) {
return false;
}
if (curr->has_filename && strcmp(curr->filename, next->filename)) {
if (curr->filename && strcmp(curr->filename, next->filename)) {
return false;
}
if (curr->has_offset && curr->offset + curr->length != next->offset) {