[PATCH 0/3] KVM: selftests: Delete three pieces of dead library code

From: Gokul K

Date: Fri Sep 18 2026 - 07:50:05 EST


Three unused things in the selftest library, found by asking the linker
rather than by reading: build the selftests, then look for global symbols
in lib/ that no object refers to, and check each survivor against the
whole source tree by hand.

1/3 sparsebit_copy() and sparsebit_num_set(), neither called
2/3 the declaration of vcpu_set_cpuid_maxphyaddr(), which has no
definition anywhere
3/3 guest_snprintf(), a varargs wrapper nobody calls

Each is independent and they can be taken in any order.

A note on what is deliberately *not* here, because the same scan turns it
up and the obvious next step is wrong. sparsebit.c still exports nine more
functions that no caller outside the file uses - sparsebit_all_set(),
sparsebit_is_clear(), sparsebit_validate_internal() and friends. They are
not dead: they are called from inside sparsebit.c, mostly from the
assertions in sparsebit_validate_internal() and from asserts in live
functions, so deleting them would not build. Making them static and
dropping their declarations is a defensible follow-up, but it is a change
of intent about what the library exposes rather than a removal of dead
code, so it does not belong in this series.

No functional change intended. Built with and without -Wextra, and a
sample of twelve x86 selftests gives identical results before and after;
kvm_binary_stats_test and the rest still pass. The two that fail here fail
identically without the series, because this host's kernel is older than
the tree.

Gokul K (3):
KVM: selftests: Delete the unused sparsebit copy and count helpers
KVM: selftests: Delete the declaration of vcpu_set_cpuid_maxphyaddr()
KVM: selftests: Delete the unused guest_snprintf()

tools/testing/selftests/kvm/include/sparsebit.h | 2 -
tools/testing/selftests/kvm/include/test_util.h | 1 -
.../testing/selftests/kvm/include/x86/processor.h | 1 -
tools/testing/selftests/kvm/lib/guest_sprintf.c | 12 -----
tools/testing/selftests/kvm/lib/sparsebit.c | 63 +---------------------
5 files changed, 1 insertion(+), 78 deletions(-)

--
2.51.0