libxl: use llabs() instead abs() for int64_t argument
PATCH 1/1 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.
--- tools/libxl/libxl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl.c +1 -1
@@ -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;
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 3 lines · Juergen Gross
Commit
57f8b13c724023c78fa15a80452d1de3e51a1418("libxl: memory size in kb requires 64 bit variable") introduced a bug:abs()shouldn't be called with anint64_targument.llabs()is to be used here.
Possibly worth identifying that this was caught by a clang build, citing:
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)
^
Otherwise, LGTM.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 5 lines · Andrew Cooper
Quoted 3 lines · Juergen Gross
Commit
57f8b13c724023c78fa15a80452d1de3e51a1418("libxl: memory size in kb requires 64 bit variable") introduced a bug:abs()shouldn't be called with anint64_targument.llabs()is to be used here.
Quoted 8 lines
Possibly worth identifying that this was caught by a clang build, citing:
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)
^
Juergen, I can fix up the commit message for you, if you don't object to Andrew's suggestion.
---
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)
---
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 15 lines · Wei Liu
Quoted 5 lines · Andrew Cooper
Quoted 3 lines · Juergen Gross
Commit
57f8b13c724023c78fa15a80452d1de3e51a1418("libxl: memory size in kb requires 64 bit variable") introduced a bug:abs()shouldn't be called with anint64_targument.llabs()is to be used here.Quoted 8 lines
Possibly worth identifying that this was caught by a clang build, citing:
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)
^
Quoted 2 lines
Juergen, I can fix up the commit message for you, if you don't object to Andrew's suggestion.
No, I don't object.
Thanks,
Juergen
Quoted 8 lines
---
Commit57f8b13c724023c78fa15a80452d1de3e51a1418("libxl: memory size in kb requires 64 bit variable") introduced a bug:abs()shouldn't be called with anint64_targument.llabs()is to be used here.Caught by clang build with error message:
Quoted 9 lines
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)
---Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 16 lines · Juergen Gross
Quoted 15 lines · Wei Liu
Quoted 13 lines · Andrew Cooper
Quoted 3 lines · Juergen Gross
Commit
57f8b13c724023c78fa15a80452d1de3e51a1418("libxl: memory size in kb requires 64 bit variable") introduced a bug:abs()shouldn't be called with anint64_targument.llabs()is to be used here.Possibly worth identifying that this was caught by a clang build, citing:
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)
^
Quoted 5 lines
Quoted 2 lines
Juergen, I can fix up the commit message for you, if you don't object to Andrew's suggestion.
No, I don't object.
Thanks. I will make the adjustment while committing.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel