* [PATCH] tools/libs/light: correct bitmap operations
@ 2020-11-06 14:05 Juergen Gross
2020-11-06 14:35 ` Jan Beulich
2020-11-06 15:57 ` Wei Liu
0 siblings, 2 replies; 6+ messages in thread
From: Juergen Gross @ 2020-11-06 14:05 UTC (permalink / raw)
To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu, Anthony PERARD
Libxl bitmap operations for single bits (test, set, reset) take the bit
number as a signed integer without testing the value to be larger than
0.
Correct that by adding the appropriate tests.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
tools/libs/light/libxl_utils.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/libs/light/libxl_utils.c b/tools/libs/light/libxl_utils.c
index b039143b8a..4699c4a0a3 100644
--- a/tools/libs/light/libxl_utils.c
+++ b/tools/libs/light/libxl_utils.c
@@ -688,21 +688,21 @@ int libxl_bitmap_is_empty(const libxl_bitmap *bitmap)
int libxl_bitmap_test(const libxl_bitmap *bitmap, int bit)
{
- if (bit >= bitmap->size * 8)
+ if (bit >= bitmap->size * 8 || bit < 0)
return 0;
return (bitmap->map[bit / 8] & (1 << (bit & 7))) ? 1 : 0;
}
void libxl_bitmap_set(libxl_bitmap *bitmap, int bit)
{
- if (bit >= bitmap->size * 8)
+ if (bit >= bitmap->size * 8 || bit < 0)
return;
bitmap->map[bit / 8] |= 1 << (bit & 7);
}
void libxl_bitmap_reset(libxl_bitmap *bitmap, int bit)
{
- if (bit >= bitmap->size * 8)
+ if (bit >= bitmap->size * 8 || bit < 0)
return;
bitmap->map[bit / 8] &= ~(1 << (bit & 7));
}
--
2.26.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] tools/libs/light: correct bitmap operations
2020-11-06 14:05 [PATCH] tools/libs/light: correct bitmap operations Juergen Gross
@ 2020-11-06 14:35 ` Jan Beulich
2020-11-06 14:36 ` Jürgen Groß
2020-11-06 14:37 ` Andrew Cooper
2020-11-06 15:57 ` Wei Liu
1 sibling, 2 replies; 6+ messages in thread
From: Jan Beulich @ 2020-11-06 14:35 UTC (permalink / raw)
To: Juergen Gross; +Cc: Ian Jackson, Wei Liu, Anthony PERARD, xen-devel
On 06.11.2020 15:05, Juergen Gross wrote:
> Libxl bitmap operations for single bits (test, set, reset) take the bit
> number as a signed integer without testing the value to be larger than
> 0.
>
> Correct that by adding the appropriate tests.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>
Wouldn't it be better to convert the parameter types to unsigned int?
Jan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tools/libs/light: correct bitmap operations
2020-11-06 14:35 ` Jan Beulich
@ 2020-11-06 14:36 ` Jürgen Groß
2020-11-06 15:45 ` Jan Beulich
2020-11-06 14:37 ` Andrew Cooper
1 sibling, 1 reply; 6+ messages in thread
From: Jürgen Groß @ 2020-11-06 14:36 UTC (permalink / raw)
To: Jan Beulich; +Cc: Ian Jackson, Wei Liu, Anthony PERARD, xen-devel
On 06.11.20 15:35, Jan Beulich wrote:
> On 06.11.2020 15:05, Juergen Gross wrote:
>> Libxl bitmap operations for single bits (test, set, reset) take the bit
>> number as a signed integer without testing the value to be larger than
>> 0.
>>
>> Correct that by adding the appropriate tests.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>
> Wouldn't it be better to convert the parameter types to unsigned int?
Those are official library interfaces. Can we just change them?
Juergen
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tools/libs/light: correct bitmap operations
2020-11-06 14:35 ` Jan Beulich
2020-11-06 14:36 ` Jürgen Groß
@ 2020-11-06 14:37 ` Andrew Cooper
1 sibling, 0 replies; 6+ messages in thread
From: Andrew Cooper @ 2020-11-06 14:37 UTC (permalink / raw)
To: Jan Beulich, Juergen Gross
Cc: Ian Jackson, Wei Liu, Anthony PERARD, xen-devel
On 06/11/2020 14:35, Jan Beulich wrote:
> On 06.11.2020 15:05, Juergen Gross wrote:
>> Libxl bitmap operations for single bits (test, set, reset) take the bit
>> number as a signed integer without testing the value to be larger than
>> 0.
>>
>> Correct that by adding the appropriate tests.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
> Wouldn't it be better to convert the parameter types to unsigned int?
Yes, except their in the API, so immutable.
(whether they should be in the API is a different question...)
~Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tools/libs/light: correct bitmap operations
2020-11-06 14:36 ` Jürgen Groß
@ 2020-11-06 15:45 ` Jan Beulich
0 siblings, 0 replies; 6+ messages in thread
From: Jan Beulich @ 2020-11-06 15:45 UTC (permalink / raw)
To: Jürgen Groß; +Cc: Ian Jackson, Wei Liu, Anthony PERARD, xen-devel
On 06.11.2020 15:36, Jürgen Groß wrote:
> On 06.11.20 15:35, Jan Beulich wrote:
>> On 06.11.2020 15:05, Juergen Gross wrote:
>>> Libxl bitmap operations for single bits (test, set, reset) take the bit
>>> number as a signed integer without testing the value to be larger than
>>> 0.
>>>
>>> Correct that by adding the appropriate tests.
>>>
>>> Signed-off-by: Juergen Gross <jgross@suse.com>
>>
>> Wouldn't it be better to convert the parameter types to unsigned int?
>
> Those are official library interfaces. Can we just change them?
Oh, I didn't expect such helpers to be available to users of the
library.
Jan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tools/libs/light: correct bitmap operations
2020-11-06 14:05 [PATCH] tools/libs/light: correct bitmap operations Juergen Gross
2020-11-06 14:35 ` Jan Beulich
@ 2020-11-06 15:57 ` Wei Liu
1 sibling, 0 replies; 6+ messages in thread
From: Wei Liu @ 2020-11-06 15:57 UTC (permalink / raw)
To: Juergen Gross; +Cc: xen-devel, Ian Jackson, Wei Liu, Anthony PERARD
On Fri, Nov 06, 2020 at 03:05:04PM +0100, Juergen Gross wrote:
> Libxl bitmap operations for single bits (test, set, reset) take the bit
> number as a signed integer without testing the value to be larger than
> 0.
>
> Correct that by adding the appropriate tests.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-11-06 15:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-06 14:05 [PATCH] tools/libs/light: correct bitmap operations Juergen Gross
2020-11-06 14:35 ` Jan Beulich
2020-11-06 14:36 ` Jürgen Groß
2020-11-06 15:45 ` Jan Beulich
2020-11-06 14:37 ` Andrew Cooper
2020-11-06 15:57 ` Wei Liu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.