diff options
author | Jim Meyering <meyering@redhat.com> | 2009-08-28 13:53:36 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-08-28 13:53:36 +0200 |
commit | ba5842c1147f4463fce7f613618938fd5b9a1c1a (patch) | |
tree | 7c55deb5b2a33b6244fe1df1a7ec53760cfb8a30 | |
parent | 23740528cd2d75a236aae1fb5d073e8be2e5a295 (diff) | |
download | libguestfs-ba5842c1147f4463fce7f613618938fd5b9a1c1a.tar.gz libguestfs-ba5842c1147f4463fce7f613618938fd5b9a1c1a.tar.xz libguestfs-ba5842c1147f4463fce7f613618938fd5b9a1c1a.zip |
generator.ml: avoid defined-but-not-used warnings in guestfs_c_actions.c
* src/generator.ml (emit_ocaml_copy_list_function): New function.
Emit a function definition only if it will be used.
-rwxr-xr-x | src/generator.ml | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/src/generator.ml b/src/generator.ml index fa7d240e..569e1a13 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -6692,6 +6692,29 @@ copy_table (char * const * argv) "; (* Struct copy functions. *) + + let emit_ocaml_copy_list_function typ = + pr "static CAMLprim value\n"; + pr "copy_%s_list (const struct guestfs_%s_list *%ss)\n" typ typ typ; + pr "{\n"; + pr " CAMLparam0 ();\n"; + pr " CAMLlocal2 (rv, v);\n"; + pr " unsigned int i;\n"; + pr "\n"; + pr " if (%ss->len == 0)\n" typ; + pr " CAMLreturn (Atom (0));\n"; + pr " else {\n"; + pr " rv = caml_alloc (%ss->len, 0);\n" typ; + pr " for (i = 0; i < %ss->len; ++i) {\n" typ; + pr " v = copy_%s (&%ss->val[i]);\n" typ typ; + pr " caml_modify (&Field (rv, i), v);\n"; + pr " }\n"; + pr " CAMLreturn (rv);\n"; + pr " }\n"; + pr "}\n"; + pr "\n"; + in + List.iter ( fun (typ, cols) -> let has_optpercent_col = @@ -6738,29 +6761,17 @@ copy_table (char * const * argv) pr " CAMLreturn (rv);\n"; pr "}\n"; pr "\n"; - - pr "static CAMLprim value\n"; - pr "copy_%s_list (const struct guestfs_%s_list *%ss)\n" - typ typ typ; - pr "{\n"; - pr " CAMLparam0 ();\n"; - pr " CAMLlocal2 (rv, v);\n"; - pr " int i;\n"; - pr "\n"; - pr " if (%ss->len == 0)\n" typ; - pr " CAMLreturn (Atom (0));\n"; - pr " else {\n"; - pr " rv = caml_alloc (%ss->len, 0);\n" typ; - pr " for (i = 0; i < %ss->len; ++i) {\n" typ; - pr " v = copy_%s (&%ss->val[i]);\n" typ typ; - pr " caml_modify (&Field (rv, i), v);\n"; - pr " }\n"; - pr " CAMLreturn (rv);\n"; - pr " }\n"; - pr "}\n"; - pr "\n"; ) structs; + (* Emit a copy_TYPE_list function definition only if that function is used. *) + List.iter ( + function + | typ, (RStructListOnly | RStructAndList) -> + (* generate the function for typ *) + emit_ocaml_copy_list_function typ + | typ, _ -> () (* empty *) + ) rstructs_used; + (* The wrappers. *) List.iter ( fun (name, style, _, _, _, _, _) -> |