Skip to contentSkip to conversation

rangeset: make inquiry functions tolerate NULL inputs

PATCH In review Jan Beulich 3 participants 5 messages Aug 17, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rangeset: make inquiry functions tolerate NULL inputs

Rather than special casing the ->iomem_caps check in x86's get_page_from_l1e() for the dom_xen case, let's be more tolerant in general, along the lines of rangeset_is_empty(): A never allocated rangeset can't possibly contain or overlap any range.

xen/common/rangeset.c +6 -0
@@ -256,6 +256,9 @@ bool_t rangeset_contains_range(
 
     ASSERT(s <= e);
 
+    if ( !r )
+        return false;
+
     read_lock(&r->lock);
     x = find_range(r, s);
     contains = (x && (x->e >= e));
@@ -272,6 +275,9 @@ bool_t rangeset_overlaps_range(
 
     ASSERT(s <= e);
 
+    if ( !r )
+        return false;
+
     read_lock(&r->lock);
     x = find_range(r, e);
     overlaps = (x && (s <= x->e));

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jan Beulich

Rather than special casing the ->iomem_caps check in x86's get_page_from_l1e() for the dom_xen case, let's be more tolerant in general, along the lines of rangeset_is_empty(): A never allocated rangeset can't possibly contain or overlap any range.

LGTM:

As said in the commit message, this is done to avoid an extra check in get_page_from_l1e I assume, so should the extra check also be dropped here?

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 17.08.18 at 11:29, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich

Rather than special casing the ->iomem_caps check in x86's get_page_from_l1e() for the dom_xen case, let's be more tolerant in general, along the lines of rangeset_is_empty(): A never allocated rangeset can't possibly contain or overlap any range.

Quoted 6 lines
Quoted 2 lines

LGTM:

Thanks.

Quoted 3 lines

As said in the commit message, this is done to avoid an extra check in get_page_from_l1e I assume, so should the extra check also be dropped here?

I'm afraid I don't understand: I indeed mean to avoid adding a NULL check in get_page_from_l1e(). But what check are you thinking of that could be dropped? Or in other words, what is "here" in your reply?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 9 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 17.08.18 at 11:29, <[email protected]> wrote:

As said in the commit message, this is done to avoid an extra check in get_page_from_l1e I assume, so should the extra check also be dropped here?

I'm afraid I don't understand: I indeed mean to avoid adding a NULL check in get_page_from_l1e(). But what check are you thinking of that could be dropped? Or in other words, what is "here" in your reply?

Oh, I understand now, this is to prevent adding a check, not to remove a check that's already in the code.

'here' meant the patch, since I wrongly assumed that this was to remove a check that was already in the code base.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 1/1
#4 lore raw
In reply to Jan Beulich
Quoted 7 lines · Jan Beulich

Rather than special casing the ->iomem_caps check in x86's get_page_from_l1e() for the dom_xen case, let's be more tolerant in general, along the lines of rangeset_is_empty(): A never allocated rangeset can't possibly contain or overlap any range.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel