[libvirt] [PATCH] Comment out variables/functions that are unused.

Martin Kletzander mkletzan at redhat.com
Mon Feb 16 09:16:01 UTC 2015


On Fri, Feb 13, 2015 at 08:18:53PM +0000, Gary R Hook wrote:
>    Avoids complaints when the compiler is configured to "warn-unused".
>
>    A few files contain unnecessary code that results in the compiler
>    erroring out when -Wunused* options are used. Comment out the code
>    until such time as it is needed.
>
>
>---
> src/libxl/libxl_conf.c   | 2 ++
> tests/virnetsockettest.c | 8 ++++++--
> 2 files changed, 8 insertions(+), 2 deletions(-)
>
>diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
>index 0555b91..f8db4d2 100644
>--- a/src/libxl/libxl_conf.c
>+++ b/src/libxl/libxl_conf.c
>@@ -305,7 +305,9 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps)
>     regmatch_t subs[4];
>     char *saveptr = NULL;
>     size_t i;
>+/*
>     virArch hostarch = caps->host.arch;
>+*/
>

How come you see this unused?  It is used about 100 lines later being
compared to VIR_ARCH_X86_64.

>     struct guest_arch guest_archs[32];
>     int nr_guest_archs = 0;
>diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
>index 5d91f26..988ab43 100644
>--- a/tests/virnetsockettest.c
>+++ b/tests/virnetsockettest.c
>@@ -333,9 +333,10 @@ static int testSocketUNIXAddrs(const void *data ATTRIBUTE_UNUSED)
>     return ret;
> }
>
>+/*
> static int testSocketCommandNormal(const void *data ATTRIBUTE_UNUSED)
> {
>-    virNetSocketPtr csock = NULL; /* Client socket */
>+    virNetSocketPtr csock = NULL; / * Client socket * /

Ugly, guess what happens if someone was about uncomment the function.
If you used #if 0 around the function it'd be way easier, or I might
even consider removing that function, BUT...

>     char buf[100];
>     size_t i;
>     int ret = -1;
>@@ -360,10 +361,12 @@ static int testSocketCommandNormal(const void *data ATTRIBUTE_UNUSED)
>     virObjectUnref(csock);
>     return ret;
> }
>+*/
>
>+/*
> static int testSocketCommandFail(const void *data ATTRIBUTE_UNUSED)
> {
>-    virNetSocketPtr csock = NULL; /* Client socket */
>+    virNetSocketPtr csock = NULL; / * Client socket * /
>     char buf[100];
>     int ret = -1;
>     virCommandPtr cmd = virCommandNewArgList("/bin/cat", "/dev/does-not-exist", NULL);
>@@ -383,6 +386,7 @@ static int testSocketCommandFail(const void *data ATTRIBUTE_UNUSED)
>     virObjectUnref(csock);
>     return ret;
> }
>+*/
>

.. both of these functions *are* used in the file.  At least
everywhere else than on win32 platforms.  If that's the problem, then
it should be in #ifndef WIN32 the same way as the tests using it are.

> struct testSSHData {
>     const char *nodename;
>--
>1.9.1
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150216/dbc612db/attachment-0001.sig>


More information about the libvir-list mailing list