On Wed, Sep 06, 2023 at 11:32:04AM +0200, Denis V. Lunev wrote:
> This patch also drops definition of some locals in main() to avoid
> useless data copy.
>
> Signed-off-by: Denis V. Lunev <[email protected]>
> CC: Eric Blake <[email protected]>
> CC: Vladimir Sementsov-Ogievskiy <[email protected]>
> ---
> qemu-nbd.c | 60 ++++++++++++++++++++++++------------------------------
> 1 file changed, 27 insertions(+), 33 deletions(-)
> @@ -519,7 +519,6 @@ int main(int argc, char **argv)
> const char *bindto = NULL;
> const char *port = NULL;
> char *sockpath = NULL;
> - char *device = NULL;
> QemuOpts *sn_opts = NULL;
> const char *sn_id_or_name = NULL;
> const char *sopt = "hVb:o:p:rsnc:dvk:e:f:tl:x:T:D:AB:L";
> @@ -582,16 +581,16 @@ int main(int argc, char **argv)
> const char *tlshostname = NULL;
> bool imageOpts = false;
> bool writethrough = false; /* Client will flush as needed. */
> - bool verbose = false;
> - bool fork_process = false;
> bool list = false;
> unsigned socket_activation;
> const char *pid_file_name = NULL;
> const char *selinux_label = NULL;
> BlockExportOptions *export_opts;
> -#if HAVE_NBD_DEVICE
> - struct NbdClientOpts opts;
> -#endif
> + struct NbdClientOpts opts = {
> + .fork_process = false,
> + .verbose = false,
> + .device = NULL,
> + };
Could also do 'struct NbdClietnOpts opts = {};' since you happen to be
zero-initializing, but this may not remain the case if more fields get
added to the struct, so I'm fine leaving it as written.
Reviewed-by: Eric Blake <[email protected]>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization: qemu.org | libguestfs.org