Re: [PATCH] selftests: kvm: Fix transposed calloc() arguments in the uffd helper

From: Sean Christopherson

Date: Fri Sep 11 2026 - 12:11:45 EST


On Fri, Sep 04, 2026, Chaithanya Lagisetty wrote:
> uffd_setup_demand_paging() passes the element size as the first argument
> to calloc() and the element count as the second:
>
> uffd_desc->pipefds = calloc(sizeof(int), num_readers);
>
> calloc() expects the number of elements first and the size of each element
> second. The product, and therefore the allocation size, is the same either
> way, so this is not a functional change, but the arguments are misleading
> and GCC 14 diagnoses them with -Wcalloc-transposed-args, which is enabled
> by -Wextra.

Heh, the calloc() implementation provided by tools/include/nolibc/stdlib.h gets
this wrong. But KVM selftests don't use nolibc, i.e. that's someone else's problem
to deal with.