vl: simplify code for main()
v2 cover vl: simplify code for main()
In "vl.c", at least, we can simplify the code below, so can let readers read professional C code (especially for new readers, which often start reading code at main function).
- Remove useless 'continue' in main().
- Eliminate a superfluous local variable in main().
--- vl.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
PATCH v2 1/2 vl: Remove useless 'continue'
"This if else has no code between it and the end of the enclosing while loop. This makes this continue redundant."
--- vl.c | 1 - 1 file changed, 1 deletion(-)
vl.c +0 -1
@@ -3034,7 +3034,6 @@ int main(int argc, char **argv, char **envp)if (argv[optind][0 ] !='-' ) {/* disk image */ optind++; -continue ; }else {const QEMUOption *popt;
Signature · 1 line
1.7.9.5
PATCH v2 2/2 vl: Eliminate a superfluous local variable
In reply to Chen GangCODING_STYLE frowns upon mixing declarations and statements. main() has such a declaration. Clean up by eliminating the variable.
--- vl.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
vl.c +9 -9
@@ -4368,15 +4368,15 @@ int main(int argc, char **argv, char **envp)qdev_machine_init (); -QEMUMachineInitArgs args = { .machine = machine, - .ram_size = ram_size, - .boot_order = boot_order, - .kernel_filename = kernel_filename, - .kernel_cmdline = kernel_cmdline, - .initrd_filename = initrd_filename, - .cpu_model = cpu_model }; - - current_machine->init_args = args; + current_machine->init_args = (QEMUMachineInitArgs ) { + .machine = machine, + .ram_size = ram_size, + .boot_order = boot_order, + .kernel_filename = kernel_filename, + .kernel_cmdline = kernel_cmdline, + .initrd_filename = initrd_filename, + .cpu_model = cpu_model }; + machine->init (¤t_machine->init_args);audio_init ();
Signature · 1 line
1.7.9.5
Quoted 9 lines · Chen Gang
In "
vl.c", at least, we can simplify the code below, so can let readers read professional C code (especially for new readers, which often start reading code at main function).- Remove useless 'continue' in
main().- Eliminate a superfluous local variable in
main().Signed-off-by Chen Gang <[email protected]>
Michael Tokarev
AppliedQuoted 7 lines · Chen Gang
In "
vl.c", at least, we can simplify the code below, so can let readers read professional C code (especially for new readers, which often start reading code at main function).- Remove useless 'continue' in
main().- Eliminate a superfluous local variable in
main().
Applied to -trivial, thank you!
/mjt