[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] two more warning-avoidance patches



On Mon, Aug 17, 2009 at 06:49:36PM +0200, Jim Meyering wrote:
> 
> >From 9e99a1c6cb655a56d7f09dabd10a77a3802bf96d Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering redhat com>
> Date: Mon, 17 Aug 2009 18:44:37 +0200
> Subject: [PATCH libguestfs 1/2] avoid compiler warnings about unused vars in generated code
> 
> * src/Makefile.am: Compile protocol.c into a convenience library, so it
> can have its own CFLAGS, and link that with the destination one.
> ---
>  src/Makefile.am |   14 ++++++++++++--
>  1 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index c6006d2..9eb71b9 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -48,6 +48,14 @@ BUILT_SOURCES = \
>    guestfs-actions.c \
>    guestfs-bindtests.c
> 
> +# This convenience library is solely to avoid compiler warnings
> +# in its generated sources.
> +libprotocol_la_SOURCES = \
> +  guestfs_protocol.c \
> +  guestfs_protocol.h
> +
> +libprotocol_la_CFLAGS = -Wall -Wno-unused
> +
>  $(BUILT_SOURCES): stamp-generator
> 
>  CLEANFILES = guestfs_protocol.c guestfs_protocol.h
> @@ -98,13 +106,15 @@ libguestfs_la_LDFLAGS = -version-info $(MAX_PROC_NR):0:$(MAX_PROC_NR)
>  libguestfs_la_SOURCES = \
>  	guestfs.c \
>  	guestfs.h \
> -	guestfs_protocol.c \
> -	guestfs_protocol.h \
>  	guestfs-actions.h \
>  	guestfs-actions.c \
>  	guestfs-bindtests.c \
>  	gettext.h
> 
> +# Make libguestfs include the convenience library.
> +noinst_LTLIBRARIES = libprotocol.la
> +libguestfs_la_LIBADD = libprotocol.la
> +
>  libguestfs_la_CFLAGS = -Wall -DGUESTFS_DEFAULT_PATH='"$(libdir)/guestfs"'
> 
>  if HAVE_RPCGEN
> --
> 1.6.4.378.g88f2f
> 
> 
> >From ab84f9a78034249f37861e00e474018b8f750df2 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering redhat com>
> Date: Mon, 17 Aug 2009 18:47:46 +0200
> Subject: [PATCH libguestfs 2/2] generator.ml: avoid warnings in generated tests.c
> 
> * src/generator.ml: Avoid warnings in generated tests.c, regarding
> print_strings, and in exercising any function that takes a StringList
> or DeviceList parameter.
> (print_strings): Change param type to "char *const *s".
> Declare fully-const initializer for each list-taking function use.
> Cast *List argument to "(char **)".
> ---
>  src/generator.ml |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/generator.ml b/src/generator.ml
> index ad4c0cb..ac01a98 100755
> --- a/src/generator.ml
> +++ b/src/generator.ml
> @@ -5274,7 +5274,7 @@ static void print_error (guestfs_h *g, void *data, const char *msg)
>  }
> 
>  /* FIXME: nearly identical code appears in fish.c */
> -static void print_strings (char const *const *argv)
> +static void print_strings (char *const *argv)
>  {
>    int argc;
> 
> @@ -5869,7 +5869,7 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd =
>                fun i str ->
>                  pr "    const char *%s_%d = \"%s\";\n" n i (c_quote str);
>              ) strs;
> -            pr "    const char *%s[] = {\n" n;
> +            pr "    const char *const %s[] = {\n" n;
>              iteri (
>                fun i _ -> pr "      %s_%d,\n" n i
>              ) strs;
> @@ -5912,7 +5912,7 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd =
>          | FileIn _, arg | FileOut _, arg ->
>              pr ", \"%s\"" (c_quote arg)
>          | StringList n, _ | DeviceList n, _ ->
> -            pr ", %s" n
> +            pr ", (char **) %s" n
>          | Int _, arg ->
>              let i =
>                try int_of_string arg
> @@ -9019,7 +9019,7 @@ and generate_bindtests () =
>  #define safe_malloc guestfs_safe_malloc
> 
>  static void
> -print_strings (char * const* const argv)
> +print_strings (char *const *argv)
>  {
>    int argc;
> 
> --
> 1.6.4.378.g88f2f
> 
> _______________________________________________
> Libguestfs mailing list
> Libguestfs redhat com
> https://www.redhat.com/mailman/listinfo/libguestfs

ACK to both of these.

Note that guestfish also has some generated XDR (fish/rc_protocol.x),
and so will require the same treatment.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]