xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libxl: use llabs() instead abs() for int64_t argument
@ 2016-08-02 17:25 Juergen Gross
  2016-08-02 17:28 ` Andrew Cooper
  0 siblings, 1 reply; 5+ messages in thread
From: Juergen Gross @ 2016-08-02 17:25 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, wei.liu2, ian.jackson, andrew.cooper3

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.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 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;
-- 
2.6.6


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] libxl: use llabs() instead abs() for int64_t argument
  2016-08-02 17:25 [PATCH] libxl: use llabs() instead abs() for int64_t argument Juergen Gross
@ 2016-08-02 17:28 ` Andrew Cooper
  2016-08-03  9:13   ` Wei Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2016-08-02 17:28 UTC (permalink / raw)
  To: Juergen Gross, xen-devel; +Cc: wei.liu2, ian.jackson


[-- Attachment #1.1: Type: text/plain, Size: 667 bytes --]

On 02/08/16 18:25, Juergen Gross wrote:
> 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.

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

[-- Attachment #1.2: Type: text/html, Size: 1685 bytes --]

[-- Attachment #2: Type: text/plain, Size: 127 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libxl: use llabs() instead abs() for int64_t argument
  2016-08-02 17:28 ` Andrew Cooper
@ 2016-08-03  9:13   ` Wei Liu
  2016-08-03  9:27     ` Juergen Gross
  0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2016-08-03  9:13 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Juergen Gross, wei.liu2, ian.jackson, xen-devel

On Tue, Aug 02, 2016 at 06:28:37PM +0100, Andrew Cooper wrote:
> On 02/08/16 18:25, Juergen Gross wrote:
> > 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.
> 
> 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
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libxl: use llabs() instead abs() for int64_t argument
  2016-08-03  9:13   ` Wei Liu
@ 2016-08-03  9:27     ` Juergen Gross
  2016-08-03  9:48       ` Wei Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Juergen Gross @ 2016-08-03  9:27 UTC (permalink / raw)
  To: Wei Liu, Andrew Cooper; +Cc: ian.jackson, xen-devel

On 03/08/16 11:13, Wei Liu wrote:
> On Tue, Aug 02, 2016 at 06:28:37PM +0100, Andrew Cooper wrote:
>> On 02/08/16 18:25, Juergen Gross wrote:
>>> 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.
>>
>> 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.

No, I don't object.


Thanks,

Juergen

> 
> ---
> 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
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libxl: use llabs() instead abs() for int64_t argument
  2016-08-03  9:27     ` Juergen Gross
@ 2016-08-03  9:48       ` Wei Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2016-08-03  9:48 UTC (permalink / raw)
  To: Juergen Gross; +Cc: Andrew Cooper, Wei Liu, ian.jackson, xen-devel

On Wed, Aug 03, 2016 at 11:27:04AM +0200, Juergen Gross wrote:
> On 03/08/16 11:13, Wei Liu wrote:
> > On Tue, Aug 02, 2016 at 06:28:37PM +0100, Andrew Cooper wrote:
> >> On 02/08/16 18:25, Juergen Gross wrote:
> >>> 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.
> >>
> >> 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.
> 
> No, I don't object.
> 

Thanks. I will make the adjustment while committing.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-08-03  9:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-02 17:25 [PATCH] libxl: use llabs() instead abs() for int64_t argument Juergen Gross
2016-08-02 17:28 ` Andrew Cooper
2016-08-03  9:13   ` Wei Liu
2016-08-03  9:27     ` Juergen Gross
2016-08-03  9:48       ` Wei Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).