On a Thursday in 2025, Jiri Denemark via Devel wrote:
From: Jiri Denemark <jdenemar@redhat.com>
The only thing that can fail inside virCPUDefFilterFeatures is VIR_DELETE_ELEMENT_INPLACE macro. The macro just calls virDeleteElementsN, which reports a warning when all elements to be removed are not within the array bounds and returns -1. The function succeeds otherwise. But since VIR_DELETE_ELEMENT_INPLACE sets the number of elements to be removed to 1 and we call it with i < cpu->nfeatures, the safety check in virDeleteElementsN will never fail. And even if we theoretically called it with wrong arguments, it just wouldn't do anything.
Thus we can safely assume VIR_DELETE_ELEMENT_INPLACE always succeeds in virCPUDefFilterFeatures and avoid reporting any errors to simplify callers.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/conf/cpu_conf.c | 9 ++++----- src/conf/cpu_conf.h | 2 +- src/qemu/qemu_capabilities.c | 15 ++++++--------- src/qemu/qemu_domain.c | 3 +-- src/qemu/qemu_process.c | 5 ++--- 5 files changed, 14 insertions(+), 20 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano