[PATCH] Fix tst-timer{2,4}
Jakub Jelinek
jakub@redhat.com
Wed Aug 11 21:19:00 GMT 2004
Hi!
These two testcases segfault if timer_create fails, which is IMHO not a good
thing. Using a timer_t after timer_create failed is also a bad example, so
we should avoid that.
2004-08-11 Jakub Jelinek <jakub@redhat.com>
* rt/tst-timer2.c (do_test): If timer_create fails, just continue.
* rt/tst-timer4.c (do_test): If one of the timer_create calls fails,
return 1 immediately.
--- libc/rt/tst-timer2.c.jj 2004-04-13 10:42:54.000000000 +0200
+++ libc/rt/tst-timer2.c 2004-08-11 23:02:39.938193370 +0200
@@ -40,7 +40,10 @@ do_test (void)
printf ("cnt = %d\n", i);
if (timer_create (CLOCK_REALTIME, &sigev, &timerId) < 0)
- perror ("timer_create");
+ {
+ perror ("timer_create");
+ continue;
+ }
res = timer_settime (timerId, 0, &itval, NULL);
if (res < 0)
--- libc/rt/tst-timer4.c.jj 2004-04-21 10:06:06.000000000 +0200
+++ libc/rt/tst-timer4.c 2004-08-11 23:08:57.886378961 +0200
@@ -206,7 +206,7 @@ do_test (void)
if (timer_create (CLOCK_REALTIME, &ev, &timer_none) != 0)
{
printf ("*** timer_create for timer_none failed: %m\n");
- result = 1;
+ return 1;
}
struct sigaction sa = { .sa_sigaction = sig1_handler,
@@ -223,7 +223,7 @@ do_test (void)
if (timer_create (CLOCK_REALTIME, &ev, &timer_sig1) != 0)
{
printf ("*** timer_create for timer_sig1 failed: %m\n");
- result = 1;
+ return 1;
}
memset (&ev, 0x33, sizeof (ev));
@@ -233,7 +233,7 @@ do_test (void)
if (timer_create (CLOCK_REALTIME, &ev, &timer_sig2) != 0)
{
printf ("*** timer_create for timer_sig2 failed: %m\n");
- result = 1;
+ return 1;
}
memset (&ev, 0x44, sizeof (ev));
@@ -244,7 +244,7 @@ do_test (void)
if (timer_create (CLOCK_REALTIME, &ev, &timer_thr1) != 0)
{
printf ("*** timer_create for timer_thr1 failed: %m\n");
- result = 1;
+ return 1;
}
pthread_attr_t nattr;
@@ -263,7 +263,7 @@ do_test (void)
if (timer_create (CLOCK_REALTIME, &ev, &timer_thr2) != 0)
{
printf ("*** timer_create for timer_thr2 failed: %m\n");
- result = 1;
+ return 1;
}
int ret = timer_getoverrun (timer_thr1);
Jakub
More information about the Libc-hacker
mailing list