[LTP] [PATCH v2] mtest06/mmap1: rewrite to newlib

Jan Stancek jstancek@redhat.com
Tue Nov 27 09:54:42 CET 2018


----- Original Message -----
> On Mon, Nov 26, 2018 at 4:21 PM Jan Stancek <jstancek@redhat.com> wrote:
> 
> > +static void sig_handler(int signal, siginfo_t *info,
> > +       LTP_ATTRIBUTE_UNUSED void *ut)
> > +{
> > +       int ar_m, ar_u;
> > +
> > +       switch (signal) {
> > +       case SIGSEGV:
> > +               /* if we hit SIGSEGV between map/unmap, something is wrong
> > */
> > +               ar_u = tst_atomic_load(&unmapcnt);
> > +               ar_m = tst_atomic_load(&mapcnt);
> > +               if (was_area_mapped(br_map, br_unmap, ar_m, ar_u)) {
> > +                       tst_res(TFAIL, "got sigsegv while mapped");
> > +                       _exit(TFAIL);
> 
> why not use tst_brk() here?

Because it calls exit(), which is not advised to do in signal handler.
(doc/test-writing-guidelines.txt, line 841)

> 
> > +               }
> > +
> > +               mapped_sigsegv_count++;
> > +               longjmp(jmpbuf, 1);
> > +               break;
> > +       default:
> > +               tst_res(TFAIL, "Unexpected signal - %d, addr: %p,
> > exiting\n",
> > +                       signal, info->si_addr);
> > +               _exit(TBROK);
> 
> tst_brk() ?
> 
> > +       }
> > +}
> > +
> > +void *map_write_unmap(void *ptr)
> > +{
> > +       long *args = ptr;
> > +       void *tmp;
> 
> remove tmp pointer?

It introduces warning in safe_munmap(), because map_address is volatile.
That is why I kept 'tmp'.

> 
> Beside these tiny issues, patch v2 looks good to me.
> 
> Reviewed-by: Li Wang <liwang@redhat.com>

Thanks,
Jan

> 
> --
> Regards,
> Li Wang
> 


More information about the ltp mailing list