Re: [PATCH v4] selftests/mm: ksm-functional-tests: fix partial write handling

From: Mike Rapoport

Date: Mon May 04 2026 - 06:02:56 EST


On Mon, May 04, 2026 at 01:43:13PM +0530, Vineet Agarwal wrote:
> Update write() checks to properly detect and handle partial writes.
>
> Previously, the write() calls used <= 0 to detect failure. This
> condition is never true for partial writes (ret > 0 but ret < len),
> so partial writes were silently treated as success.
>
> Fix this by verifying that write() returns the full expected length
> and treating any mismatch as failure.
>
> Signed-off-by: Vineet Agarwal <agarwal.vineet2006@xxxxxxxxx>

Acked-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>

>
> Changes in v4:
> - Simplify write() checks as suggested by Mike Rapoport
> - Remove temporary variables and use direct comparisons
> - Use a single len variable
> ---
> .../selftests/mm/ksm_functional_tests.c | 19 +++++++++++--------
> 1 file changed, 11 insertions(+), 8 deletions(-)

--
Sincerely yours,
Mike.