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

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

 



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

Attachment: signature.asc
Description: Digital 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]