summary refs log tree commit diff stats
path: root/util/range.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2016-07-01 13:47:47 +0200
committerMichael S. Tsirkin <mst@redhat.com>2016-07-04 16:49:33 +0300
commita0efbf16604770b9d805bcf210ec29942321134f (patch)
tree46e9cde32a5f519dab0d28f96a87ae74d4e72b4d /util/range.c
parent58e19e6e7914354242a67442d0006f9e31684d1a (diff)
downloadfocaccia-qemu-a0efbf16604770b9d805bcf210ec29942321134f.tar.gz
focaccia-qemu-a0efbf16604770b9d805bcf210ec29942321134f.zip
range: Eliminate direct Range member access
Users of struct Range mess liberally with its members, which makes
refactoring hard.  Create a set of methods, and convert all users to
call them instead of accessing members.  The methods have carefully
worded contracts, and use assertions to check them.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'util/range.c')
-rw-r--r--util/range.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/util/range.c b/util/range.c
index e90c988dbf..e5f2e71142 100644
--- a/util/range.c
+++ b/util/range.c
@@ -46,8 +46,7 @@ GList *range_list_insert(GList *list, Range *data)
 {
     GList *l;
 
-    /* Range lists require no empty ranges */
-    assert(data->begin < data->end || (data->begin && !data->end));
+    assert(!range_is_empty(data));
 
     /* Skip all list elements strictly less than data */
     for (l = list; l && range_compare(l->data, data) < 0; l = l->next) {