In "dirty-bitmap.c", the "nbd_extent_callback" compound literals are
not
only too wide, they're also initialized with the same contents. Replace
all three with a common local variable.
The same applies to "structured-read.c", modulo the type being
"nbd_chunk_callback".
Bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=2172516
Signed-off-by: Laszlo Ersek <lersek(a)redhat.com>
---
interop/dirty-bitmap.c | 12 ++++--------
interop/structured-read.c | 15 +++++++--------
2 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/interop/dirty-bitmap.c b/interop/dirty-bitmap.c
index fc32e3352eaf..05f6e9db11ff 100644
--- a/interop/dirty-bitmap.c
+++ b/interop/dirty-bitmap.c
@@ -124,6 +124,7 @@ main (int argc, char *argv[])
struct nbd_handle *nbd;
int64_t exportsize;
struct data data;
+ nbd_extent_callback extent_callback = { .callback = cb, .user_data = &data };
char c;
if (argc < 3) {
@@ -153,17 +154,14 @@ main (int argc, char *argv[])
}
data = (struct data) { .count = 2, };
- if (nbd_block_status (nbd, exportsize, 0,
- (nbd_extent_callback) { .callback = cb, .user_data = &data
},
- 0) == -1) {
+ if (nbd_block_status (nbd, exportsize, 0, extent_callback, 0) == -1) {
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
assert (data.seen_base && data.seen_dirty);
data = (struct data) { .req_one = true, .count = 2, };
- if (nbd_block_status (nbd, exportsize, 0,
- (nbd_extent_callback) { .callback = cb, .user_data = &data
},
+ if (nbd_block_status (nbd, exportsize, 0, extent_callback,
LIBNBD_CMD_FLAG_REQ_ONE) == -1) {
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
@@ -172,9 +170,7 @@ main (int argc, char *argv[])
/* Trigger a failed callback, to prove connection stays up. */
data = (struct data) { .count = 2, .fail = true, };
- if (nbd_block_status (nbd, exportsize, 0,
- (nbd_extent_callback) { .callback = cb, .user_data = &data
},
- 0) != -1) {
+ if (nbd_block_status (nbd, exportsize, 0, extent_callback, 0) != -1) {
fprintf (stderr, "unexpected block status success\n");
exit (EXIT_FAILURE);
}
diff --git a/interop/structured-read.c b/interop/structured-read.c
index c2e99c17b174..84eaab0baacc 100644
--- a/interop/structured-read.c
+++ b/interop/structured-read.c
@@ -106,6 +106,8 @@ main (int argc, char *argv[])
struct nbd_handle *nbd;
int64_t exportsize;
struct data data;
+ nbd_chunk_callback chunk_callback = { .callback = read_cb,
+ .user_data = &data };
char c;
if (argc < 2) {
@@ -141,9 +143,8 @@ main (int argc, char *argv[])
memset (rbuf, 2, sizeof rbuf);
data = (struct data) { .count = 2, };
- if (nbd_pread_structured (nbd, rbuf, sizeof rbuf, 2048,
- (nbd_chunk_callback) { .callback = read_cb, .user_data =
&data },
- 0) == -1) {
+ if (nbd_pread_structured (nbd, rbuf, sizeof rbuf, 2048, chunk_callback, 0) ==
+ -1) {
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
@@ -152,8 +153,7 @@ main (int argc, char *argv[])
/* Repeat with DF flag. */
memset (rbuf, 2, sizeof rbuf);
data = (struct data) { .df = true, .count = 1, };
- if (nbd_pread_structured (nbd, rbuf, sizeof rbuf, 2048,
- (nbd_chunk_callback) { .callback = read_cb, .user_data =
&data },
+ if (nbd_pread_structured (nbd, rbuf, sizeof rbuf, 2048, chunk_callback,
LIBNBD_CMD_FLAG_DF) == -1) {
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
@@ -166,9 +166,8 @@ main (int argc, char *argv[])
*/
memset (rbuf, 2, sizeof rbuf);
data = (struct data) { .count = 2, .fail = true, };
- if (nbd_pread_structured (nbd, rbuf, sizeof rbuf, 2048,
- (nbd_chunk_callback) { .callback = read_cb, .user_data =
&data },
- 0) != -1) {
+ if (nbd_pread_structured (nbd, rbuf, sizeof rbuf, 2048, chunk_callback, 0) !=
+ -1) {
fprintf (stderr, "unexpected pread callback success\n");
exit (EXIT_FAILURE);
}