[LTP] [PATCH v2] msync04.c: Use direct IO to verify the data is stored on disk

Petr Vorel pvorel@suse.cz
Mon Jun 17 14:13:05 CEST 2024


> Hi!
> > > +static void verify_mmaped(void)
> > > +{
> > > +	char *buffer = SAFE_MEMALIGN(getpagesize(), getpagesize());
> > > +
> > > +	tst_res(TINFO, "Haven't seen dirty bit so we check content of file instead");
> > > +	test_fd = SAFE_OPEN("msync04/testfile", O_RDONLY | O_DIRECT);
> > If this fails we have memory leak, because free() is not run.

> > > +	SAFE_READ(0, test_fd, buffer, getpagesize());
> > Also here. Maybe create buf as static and have conditional free() also at the
> > cleanup?

> If these fail we exit the test, which frees memory anyways...

Thanks for correcting me.  I always forget the basis that exit() frees the
memory (unlike return 0 and unless overwritten). And we call exit() in
tst_brk().

Kind regards,
Petr


More information about the ltp mailing list