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

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

 



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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: pgpW2CpM84pRu.pgp
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]