[libvirt] [PATCH] tests: command: Fix build on ppc64/aarch64

Martin Kletzander mkletzan at redhat.com
Thu Jul 14 06:30:59 UTC 2016


On Wed, Jul 13, 2016 at 07:20:26PM +0200, Andrea Bolognani wrote:
>Commit ca10bb040fcf introduced a new test that fails to build
>on at least some architectures:
>
>  commandtest.c: In function 'test25':
>  commandtest.c:1121:5: error: comparison is always true due to
>                        limited range of data type [-Werror=type-limits]
>    if (rv >= 0) {
>    ^
>
>Change the type of 'rv' from char to int, which is the proper
>return type for virCommandExec() anyway.
>---
>Posting this to the list so that Michal/others can chime in.
>
>Using int instead of char seems completely safe here, and in
>fact should probably have been the right choice from the start.
>
>On the other hand, I would expect this kind of error if we were
>using unsigned char, not plain char... By the way, changing it
>to signed char is another way to get the code to compile again
>on ppc64/aarch64.
>

Souns about right to me.  The byte sent over the pipe is usually just
char because we simply don't need anything else, but this time around
there's an exception from what I remember from the rest of the code and
that is that the value is used as an integer later on (other times we
just throw it away or check if it's 0 or 1).  So ACK.

> tests/commandtest.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/tests/commandtest.c b/tests/commandtest.c
>index 2b77b9b..7bf5447 100644
>--- a/tests/commandtest.c
>+++ b/tests/commandtest.c
>@@ -1068,7 +1068,7 @@ static int test25(const void *unused ATTRIBUTE_UNUSED)
> {
>     int ret = -1;
>     int pipeFD[2] = { -1, -1};
>-    char rv = 0;
>+    int rv = 0;
>     ssize_t tries = 100;
>     pid_t pid;
>
>--
>2.7.4
>
>--
>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: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160714/aef0bb52/attachment-0001.sig>


More information about the libvir-list mailing list