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

[Xen-changelog] [xen master] libxl: use llabs() instead abs() for int64_t argument



commit 45a348ebaba3f6e0a26455a3ff181a41722943a0
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Tue Aug 2 19:25:42 2016 +0200
Commit:     Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Wed Aug 3 10:46:58 2016 +0100

    libxl: use llabs() instead abs() for int64_t argument
    
    Commit 57f8b13c724023c78fa15a80452d1de3e51a1418 ("libxl: memory size
    in kb requires 64 bit variable") introduced a bug: abs() shouldn't
    be called with an int64_t argument. llabs() is to be used here.
    
    Caught by clang build with error message:
    
    libxl.c:4198:33: error: absolute value function 'abs' given an argument
    of type
        'int64_t' (aka 'long') but has parameter of type 'int' which may cause
        truncation of value [-Werror,-Wabsolute-value]
        if (target_memkb < 0 && abs(target_memkb) > current_target_memkb)
    
    Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
    Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/libxl/libxl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index de8f058..7bd3e8c 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -4195,7 +4195,7 @@ retry_transaction:
     videoram = videoram_s ? atoi(videoram_s) : 0;
 
     if (relative) {
-        if (target_memkb < 0 && abs(target_memkb) > current_target_memkb)
+        if (target_memkb < 0 && llabs(target_memkb) > current_target_memkb)
             new_target_memkb = 0;
         else
             new_target_memkb = current_target_memkb + target_memkb;
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.