[libvirt] [PATCH] Fix compiler warnings in test code

# HG changeset patch # User john.levon@sun.com # Date 1229399267 28800 # Node ID 1b81ac255ad765ab782829e7fe0a55dc7bab72ab # Parent ee6ccfc062f49f514d7ae8924d5a596b18441fee Fix compiler warnings in test code Signed-off-by: John Levon <john.levon@sun.com> diff --git a/src/test.c b/src/test.c --- a/src/test.c +++ b/src/test.c @@ -1299,7 +1299,7 @@ static unsigned long testGetMaxMemory(vi static unsigned long testGetMaxMemory(virDomainPtr domain) { testConnPtr privconn = domain->conn->privateData; virDomainObjPtr privdom; - unsigned long ret = -1; + unsigned long ret = (unsigned long)-1; testDriverLock(privconn); privdom = virDomainFindByName(&privconn->domains, diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c --- a/tests/nodeinfotest.c +++ b/tests/nodeinfotest.c @@ -9,6 +9,16 @@ #include "internal.h" #include "nodeinfo.h" #include "util.h" + +#ifndef __linux__ + +static int +mymain(int argc, char **argv) +{ + exit (77); /* means 'test skipped' for automake */ +} + +#else static char *progname; static char *abs_srcdir; @@ -78,9 +88,6 @@ mymain(int argc, char **argv) "nodeinfo-6", }; char cwd[PATH_MAX]; -#ifndef __linux__ - exit (77); /* means 'test skipped' for automake */ -#endif abs_srcdir = getenv("abs_srcdir"); if (!abs_srcdir) @@ -102,4 +109,7 @@ mymain(int argc, char **argv) return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); } +#endif /* __linux__ */ + VIRT_TEST_MAIN(mymain) +

john.levon@sun.com wrote:
# HG changeset patch # User john.levon@sun.com # Date 1229399267 28800 # Node ID 1b81ac255ad765ab782829e7fe0a55dc7bab72ab # Parent ee6ccfc062f49f514d7ae8924d5a596b18441fee Fix compiler warnings in test code
I suppose the latter was a warning from Sun's cc about code after the "exit(77)" being unreachable. ACK.
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c ... -#ifndef __linux__ - exit (77); /* means 'test skipped' for automake */ -#endif
abs_srcdir = getenv("abs_srcdir"); if (!abs_srcdir) @@ -102,4 +109,7 @@ mymain(int argc, char **argv) return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); } ...

On Tue, Dec 16, 2008 at 06:51:14PM -0800, john.levon@sun.com wrote:
# HG changeset patch # User john.levon@sun.com # Date 1229399267 28800 # Node ID 1b81ac255ad765ab782829e7fe0a55dc7bab72ab # Parent ee6ccfc062f49f514d7ae8924d5a596b18441fee Fix compiler warnings in test code
Signed-off-by: John Levon <john.levon@sun.com>
diff --git a/src/test.c b/src/test.c --- a/src/test.c +++ b/src/test.c @@ -1299,7 +1299,7 @@ static unsigned long testGetMaxMemory(vi static unsigned long testGetMaxMemory(virDomainPtr domain) { testConnPtr privconn = domain->conn->privateData; virDomainObjPtr privdom; - unsigned long ret = -1; + unsigned long ret = (unsigned long)-1;
The original code was actually bogus. It should have been initialized to '0' as the error return value, rather than the current '-1'. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Wed, Dec 17, 2008 at 03:17:35PM +0000, Daniel P. Berrange wrote:
On Tue, Dec 16, 2008 at 06:51:14PM -0800, john.levon@sun.com wrote:
# HG changeset patch # User john.levon@sun.com # Date 1229399267 28800 # Node ID 1b81ac255ad765ab782829e7fe0a55dc7bab72ab # Parent ee6ccfc062f49f514d7ae8924d5a596b18441fee Fix compiler warnings in test code
Signed-off-by: John Levon <john.levon@sun.com>
diff --git a/src/test.c b/src/test.c --- a/src/test.c +++ b/src/test.c @@ -1299,7 +1299,7 @@ static unsigned long testGetMaxMemory(vi static unsigned long testGetMaxMemory(virDomainPtr domain) { testConnPtr privconn = domain->conn->privateData; virDomainObjPtr privdom; - unsigned long ret = -1; + unsigned long ret = (unsigned long)-1;
The original code was actually bogus. It should have been initialized to '0' as the error return value, rather than the current '-1'.
I've committed your patch, with this additional change Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (4)
-
Daniel P. Berrange
-
Jim Meyering
-
John Levon
-
john.levon@sun.com