[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 08/12] qemu/range: add range_list_contains() function
From: |
Sven Schnelle |
Subject: |
[PATCH v3 08/12] qemu/range: add range_list_contains() function |
Date: |
Fri, 1 Mar 2024 18:46:05 +0100 |
Add a small inline function to match an address against
a list of ranges.
Signed-off-by: Sven Schnelle <svens@stackframe.org>
---
include/qemu/range.h | 12 ++++++++++++
util/log.c | 10 +---------
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/include/qemu/range.h b/include/qemu/range.h
index 4ff9799d89..7ef9b3d5fb 100644
--- a/include/qemu/range.h
+++ b/include/qemu/range.h
@@ -57,6 +57,18 @@ static inline bool range_contains(const Range *range,
uint64_t val)
return val >= range->lob && val <= range->upb;
}
+static inline bool range_list_contains(GList *ranges, uint64_t val)
+{
+ GList *p;
+
+ for (p = g_list_first(ranges); p; p = g_list_next(p)) {
+ if (range_contains(p->data, val)) {
+ return true;
+ }
+ }
+ return false;
+}
+
/* Initialize @range to the empty range */
static inline void range_make_empty(Range *range)
{
diff --git a/util/log.c b/util/log.c
index 90897ef0f9..032110d700 100644
--- a/util/log.c
+++ b/util/log.c
@@ -368,18 +368,10 @@ bool qemu_set_log_filename_flags(const char *name, int
flags, Error **errp)
*/
bool qemu_log_in_addr_range(uint64_t addr)
{
- GList *p;
-
if (!debug_regions) {
return true;
}
-
- for (p = g_list_first(debug_regions); p; p = g_list_next(p)) {
- if (range_contains(p->data, addr)) {
- return true;
- }
- }
- return false;
+ return range_list_contains(debug_regions, addr);
}
void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp)
--
2.43.2
[PATCH v3 06/12] util/range: split up range_list_from_string(), Sven Schnelle, 2024/03/01
[PATCH v3 05/12] util/range: use append_new_range() in range_list_from_string(), Sven Schnelle, 2024/03/01
[PATCH v3 02/12] util/log: make qemu_set_dfilter_ranges() take a GList, Sven Schnelle, 2024/03/01
[PATCH v3 03/12] util/range: move range_list_from_string() to range.c, Sven Schnelle, 2024/03/01
[PATCH v3 07/12] util/range: make range_list_from_string() accept a single number, Sven Schnelle, 2024/03/01
[PATCH v3 08/12] qemu/range: add range_list_contains() function,
Sven Schnelle <=
[PATCH v3 04/12] util/range: add range_list_free(), Sven Schnelle, 2024/03/01
[PATCH v3 10/12] plugins: add range list API, Sven Schnelle, 2024/03/01
[PATCH v3 12/12] plugins/execlog: add data address match, Sven Schnelle, 2024/03/01
[PATCH v3 09/12] plugins: add API to print errors, Sven Schnelle, 2024/03/01
[PATCH v3 11/12] plugins/execlog: use range list api, Sven Schnelle, 2024/03/01