aboutgitcodebugslistschat
path: root/doc
diff options
context:
space:
mode:
authorLaurent Vivier <lvivier@redhat.com>2025-05-13 11:41:00 +0200
committerStefano Brivio <sbrivio@redhat.com>2025-05-14 17:51:32 +0200
commita6b9832e495be636bcccf25e0aebdeb564addf06 (patch)
tree164ed18eeaa36bba538017aba6833c24fd3d9246 /doc
parent570e7b4454f2f879180ae3ca13dedd759aff5243 (diff)
downloadpasst-a6b9832e495be636bcccf25e0aebdeb564addf06.tar
passt-a6b9832e495be636bcccf25e0aebdeb564addf06.tar.gz
passt-a6b9832e495be636bcccf25e0aebdeb564addf06.tar.bz2
passt-a6b9832e495be636bcccf25e0aebdeb564addf06.tar.lz
passt-a6b9832e495be636bcccf25e0aebdeb564addf06.tar.xz
passt-a6b9832e495be636bcccf25e0aebdeb564addf06.tar.zst
passt-a6b9832e495be636bcccf25e0aebdeb564addf06.zip
virtio: Fix Clang warning (bugprone-sizeof-expression, cert-arr39-c)
In `virtqueue_read_indirect_desc()`, the pointer arithmetic involving `desc` is intentional. We add the length in bytes (`read_len`) divided by the size of `struct vring_desc` to `desc`, which is an array of `struct vring_desc`. This correctly calculates the offset in terms of the number of `struct vring_desc` elements. Clang issues the following warning due to this explicit scaling: virtio.c:238:8: error: suspicious usage of 'sizeof(...)' in pointer arithmetic; this scaled value will be scaled again by the '+=' operator [bugprone-sizeof-expression,cert-arr39-c,-Werror] 238 | desc += read_len / sizeof(struct vring_desc); | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~ virtio.c:238:8: note: '+=' in pointer arithmetic internally scales with 'sizeof(struct vring_desc)' == 16 This behavior is intended, so the warning can be considered a false positive in this context. The code correctly advances the pointer by the desired number of descriptor entries. Signed-off-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'doc')
0 files changed, 0 insertions, 0 deletions