Jim Meyering
2009-Aug-17 18:29 UTC
[Libguestfs] [PATCH libguestfs] generator.ml: do not emit unused print_*_list functions
I see the following warnings: cmds.c:934:13: warning: 'print_int_bool_list' defined but not used cmds.c:1093:13: warning: 'print_stat_list' defined but not used cmds.c:1124:13: warning: 'print_statvfs_list' defined but not used cmds.c:1171:13: warning: 'print_version_list' defined but not used This patch makes it so we don't emit the unused definitions:>From ff307d5e14b33fbbf97c411a97905127021b09fc Mon Sep 17 00:00:00 2001From: Jim Meyering <meyering at redhat.com> Date: Mon, 17 Aug 2009 20:28:34 +0200 Subject: [PATCH libguestfs] generator.ml: do not emit unused print_*_list functions * src/generator.ml (emit_print_list_function): New function. Emit a function definition only if it will be used. --- src/generator.ml | 36 ++++++++++++++++++++++++------------ 1 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/generator.ml b/src/generator.ml index ac01a98..03dc52b 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -6063,6 +6063,21 @@ and generate_fish_cmds () pr "}\n"; pr "\n"; + let emit_print_list_function typ + pr "static void print_%s_list (struct guestfs_%s_list *%ss)\n" + typ typ typ; + pr "{\n"; + pr " int i;\n"; + pr "\n"; + pr " for (i = 0; i < %ss->len; ++i) {\n" typ; + pr " printf (\"[%%d] = {\\n\", i);\n"; + pr " print_%s_indent (&%ss->val[i], \" \");\n" typ typ; + pr " printf (\"}\\n\");\n"; + pr " }\n"; + pr "}\n"; + pr "\n"; + in + (* print_* functions *) List.iter ( fun (typ, cols) -> @@ -6119,20 +6134,17 @@ and generate_fish_cmds () pr " print_%s_indent (%s, \"\");\n" typ typ; pr "}\n"; pr "\n"; - pr "static void print_%s_list (struct guestfs_%s_list *%ss)\n" - typ typ typ; - pr "{\n"; - pr " int i;\n"; - pr "\n"; - pr " for (i = 0; i < %ss->len; ++i) {\n" typ; - pr " printf (\"[%%d] = {\\n\", i);\n"; - pr " print_%s_indent (&%ss->val[i], \" \");\n" typ typ; - pr " printf (\"}\\n\");\n"; - pr " }\n"; - pr "}\n"; - pr "\n"; ) structs; + (* Emit a put_TYPE_list function definition only if that function is used. *) + List.iter ( + function + | typ, (RStructListOnly | RStructAndList) -> + (* generate the function for typ *) + emit_print_list_function typ + | typ, _ -> () (* empty *) + ) rstructs_used; + (* run_<action> actions *) List.iter ( fun (name, style, _, flags, _, _, _) -> -- 1.6.4.378.g88f2f
Jim Meyering
2009-Aug-17 18:32 UTC
[Libguestfs] [PATCH libguestfs] generator.ml: do not emit unused print_*_list functions
Jim Meyering wrote:> I see the following warnings: > > cmds.c:934:13: warning: 'print_int_bool_list' defined but not used > cmds.c:1093:13: warning: 'print_stat_list' defined but not used > cmds.c:1124:13: warning: 'print_statvfs_list' defined but not used > cmds.c:1171:13: warning: 'print_version_list' defined but not used > > This patch makes it so we don't emit the unused definitions:...> Subject: [PATCH libguestfs] generator.ml: do not emit unused print_*_list functions...> + (* Emit a put_TYPE_list function definition only if that function is used. *)Oops. that should be print_TYPE_list. I've just amended my local copy of that change.
Richard W.M. Jones
2009-Aug-18 08:00 UTC
[Libguestfs] [PATCH libguestfs] generator.ml: do not emit unused print_*_list functions
On Mon, Aug 17, 2009 at 08:29:13PM +0200, Jim Meyering wrote:> I see the following warnings: > > cmds.c:934:13: warning: 'print_int_bool_list' defined but not used > cmds.c:1093:13: warning: 'print_stat_list' defined but not used > cmds.c:1124:13: warning: 'print_statvfs_list' defined but not used > cmds.c:1171:13: warning: 'print_version_list' defined but not used > > This patch makes it so we don't emit the unused definitions:Looks good, ACK. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://et.redhat.com/~rjones/libguestfs/ See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
Reasonably Related Threads
- [PATCH libguestfs] generator.ml: do not emit unused print_* functions
- [PATCH] Fix various -Wformat problems.
- [PATCH v2] Fix various -Wformat problems.
- [PATCH 1/3] src: generate code for printing contents of structs
- [PATCH 3/3] src: print contents of structs and struct lists on tracing