The generated code had:
...
done_no_free:
return;
}
There was no possible code between the label and the return statement,
so both the label and the return statement are redundant. The
instances of ‘goto done_no_free’ can simply be replaced by ‘return’.
The only small complication is that there is a label just before this
which contains some optional code. So we might have ended up with
generated code looking like:
done:
// if there was no optional code, this would be empty
}
which provokes a parse error in C. Therefore I had to add a semicolon
after the ‘done:’ label. This will be removed in a subsequent commit,
so it's just to make the current commit bisectable.
---
generator/daemon.ml | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/generator/daemon.ml b/generator/daemon.ml
index 9453d1256..83c0ad24c 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -284,7 +284,7 @@ let generate_daemon_stubs actions () =
if is_filein then
pr " cancel_receive ();\n";
pr " reply_with_unavailable_feature (\"%s\");\n" group;
- pr " goto done_no_free;\n";
+ pr " return;\n";
pr " }\n";
pr "\n"
| None -> ()
@@ -302,14 +302,14 @@ let generate_daemon_stubs actions () =
if is_filein then
pr " cancel_receive ();\n";
pr " reply_with_error (\"unknown option in optional arguments
bitmask (this can happen if a program is compiled against a newer version of libguestfs,
then run against an older version of the daemon)\");\n";
- pr " goto done_no_free;\n";
+ pr " return;\n";
pr " }\n";
) else (
pr " if (optargs_bitmask != 0) {\n";
if is_filein then
pr " cancel_receive ();\n";
pr " reply_with_error (\"header optargs_bitmask field must be passed
as 0 for calls that don't take optional arguments\");\n";
- pr " goto done_no_free;\n";
+ pr " return;\n";
pr " }\n";
);
pr "\n";
@@ -499,15 +499,13 @@ let generate_daemon_stubs actions () =
);
(* Free the args. *)
- pr "done:\n";
+ pr "done: ;\n";
(match args_passed_to_daemon with
| [] -> ()
| _ ->
pr " xdr_free ((xdrproc_t) xdr_guestfs_%s_args, (char *)
&args);\n"
name
);
- pr "done_no_free:\n";
- pr " return;\n";
pr "}\n\n";
) (actions |> daemon_functions |> sort)
--
2.12.0