[LTP] [PATCH v3] Migrating the libhugetlbfs/testcases/truncate.c test
Shirisha ganta
shirisha@linux.ibm.com
Thu Mar 21 08:03:31 CET 2024
On Tue, 2023-11-28 at 12:22 +0100, Petr Vorel wrote:
> Hi,
>
> ...
> > +static void sigbus_handler(int signum)
> > +{
> > + test_pass = 1;
> > + siglongjmp(sig_escape, 17);
> What 17 stands for? Is there any constant which could be used? Or can
> you define
> something (the name of the constant would be self-describing).
The value 17 is often chosen as a non-zero return value for sigsetjmp
because it is unlikely to be a valid return value from a normal
function. By using a non-zero value, you can distinguish between a
direct return from sigsetjmp (where the return value is 0) and a return
after a siglongjmp (where the return value is non-zero).
By using a non-zero value (like 17), you can differentiate between
normal function returns and jumps due to exceptional conditions. he
specific value chosen (such as 17) can vary based on the programmer’s
preference or the context of the application. Some developers might use
other non-zero values, but 17 has become a convention due to its
uniqueness and readability.
> > +}
> > +
> > +static void run_test(void)
> > +{
> > + void *p;
> > + volatile unsigned int *q;
> > +
> > + sigbus_count = 0;
> > + test_pass = 0;
> > + int err;
> > +
> > + p = SAFE_MMAP(NULL, hpage_size, PROT_READ|PROT_WRITE,
> > MAP_SHARED,
> > + fd, 0);
> > + q = p;
> > + *q = 0;
> > + err = ftruncate(fd, 0);
> > + if (err)
> > + tst_res(TFAIL, "ftruncate failed");
> We have SAFE_FTRUNCATE(), error check is not needed.
Will take care of this in V4
>
> Kind regards,
> Petr
More information about the ltp
mailing list