[LTP] [PATCH] safe_macros: Fix confusing safe_read() failure output

Petr Vorel pvorel@suse.cz
Thu Jan 9 17:18:51 CET 2025


Hi Cyril, Andrea
> In the case that we read() less bytes than expected in the strict mode
> we used the same tst_brk() as for the case when read() fails. However
> for short reads the errno is in an udefined state and we possibly end up
> with confusing TBROK message. Andrea reported EACESS ernno in the TBROK
nit: s/ernno/errno/

> message on a short read() while developing tests.

Good catch!

Reviewed-by: Petr Vorel <pvorel@suse.cz>

FYI safe_write() also has TERRNO in len_strict.

Kind regards,
Petr

+++ lib/safe_macros.c
@@ -554,7 +554,7 @@ ssize_t safe_write(const char *file, const int lineno, void (cleanup_fn) (void),
 
 		if (len_strict == SAFE_WRITE_ALL) {
 			if ((size_t)rval != nbyte)
-				tst_brkm_(file, lineno, TBROK | TERRNO,
+				tst_brkm_(file, lineno, TBROK,
 					cleanup_fn, "short write(%d,%p,%zu) "
 					"return value %zd",
 					fildes, buf, nbyte, rval);


More information about the ltp mailing list