diff options
| author | Li RongQing <lirongqing@baidu.com> | 2026-06-30 12:59:52 +0800 |
|---|---|---|
| committer | Michael S. Tsirkin <mst@redhat.com> | 2026-08-19 06:38:45 -0400 |
| commit | ddf8b4388af7afc3fbdc2002c9c109e88fa27ddf (patch) | |
| tree | 8b6bff2db1b38da4b7bfe1cda839189881190c69 | |
| parent | 656662dc53e6431fbfabb5f39103cb940838bf82 (diff) | |
virtio_mem: fix hardcoded 'vm' variable in bbm iteration macros
virtio_mem_bbm_for_each_bb() and virtio_mem_bbm_for_each_bb_rev()
accept a '_vm' parameter to allow callers to pass any variable name
referring to the virtio_mem instance. However, the 'for' loop
initializer and part of the loop condition use the bare name 'vm'
instead of the macro parameter '_vm'.
Fix by replacing all bare 'vm->' references inside the macros with
the '_vm' parameter, and wrap in parentheses following kernel macro
conventions.
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260630045952.2188-1-lirongqing@baidu.com>
| -rw-r--r-- | drivers/virtio/virtio_mem.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c index 11c441501582..82a285c0926d 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -423,14 +423,14 @@ static int virtio_mem_bbm_bb_states_prepare_next_bb(struct virtio_mem *vm) } #define virtio_mem_bbm_for_each_bb(_vm, _bb_id, _state) \ - for (_bb_id = vm->bbm.first_bb_id; \ - _bb_id < vm->bbm.next_bb_id && _vm->bbm.bb_count[_state]; \ + for (_bb_id = (_vm)->bbm.first_bb_id; \ + _bb_id < (_vm)->bbm.next_bb_id && (_vm)->bbm.bb_count[_state]; \ _bb_id++) \ if (virtio_mem_bbm_get_bb_state(_vm, _bb_id) == _state) #define virtio_mem_bbm_for_each_bb_rev(_vm, _bb_id, _state) \ - for (_bb_id = vm->bbm.next_bb_id - 1; \ - _bb_id >= vm->bbm.first_bb_id && _vm->bbm.bb_count[_state]; \ + for (_bb_id = (_vm)->bbm.next_bb_id - 1; \ + _bb_id >= (_vm)->bbm.first_bb_id && (_vm)->bbm.bb_count[_state]; \ _bb_id--) \ if (virtio_mem_bbm_get_bb_state(_vm, _bb_id) == _state) |
