All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] openposix/pthread_cancel/3-1: Move sleep loop into separate function
@ 2021-08-02 16:30 Petr Vorel
  2021-08-02 16:54 ` Jan Stancek
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2021-08-02 16:30 UTC (permalink / raw)
  To: ltp

to fix warning:
pthread_cancel/3-1.c:40:13: warning: variable ?waited_for_cancel_ms? might be clobbered by ?longjmp? or ?vfork? [-Wclobbered]
   40 |         int waited_for_cancel_ms = 0;

Suggested-by: Martin Doucha <mdoucha@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 .../conformance/interfaces/pthread_cancel/3-1.c  | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cancel/3-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cancel/3-1.c
index 3527d57fd..90500b371 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cancel/3-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cancel/3-1.c
@@ -35,19 +35,25 @@ static void cleanup_func(PTS_ATTRIBUTE_UNUSED void *unused)
 	} while (after_cancel == 0 && thread_sleep_time < TIMEOUT_MS);
 }
 
-static void *thread_func(PTS_ATTRIBUTE_UNUSED void *unused)
+static void sleep_loop(void)
 {
 	int waited_for_cancel_ms = 0;
 	struct timespec cancel_wait_ts = {0, SLEEP_MS*1000000};
 
-	SAFE_PFUNC(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL));
-	pthread_cleanup_push(cleanup_func, NULL);
-
-	SAFE_FUNC(sem_post(&sem));
 	while (waited_for_cancel_ms < TIMEOUT_MS) {
 		nanosleep(&cancel_wait_ts, NULL);
 		waited_for_cancel_ms += SLEEP_MS;
 	}
+}
+
+static void *thread_func(PTS_ATTRIBUTE_UNUSED void *unused)
+{
+	SAFE_PFUNC(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL));
+	pthread_cleanup_push(cleanup_func, NULL);
+
+	SAFE_FUNC(sem_post(&sem));
+
+	sleep_loop();
 
 	/* shouldn't be reached */
 	printf("Error: cancel never arrived\n");
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [LTP] [PATCH 1/1] openposix/pthread_cancel/3-1: Move sleep loop into separate function
  2021-08-02 16:30 [LTP] [PATCH 1/1] openposix/pthread_cancel/3-1: Move sleep loop into separate function Petr Vorel
@ 2021-08-02 16:54 ` Jan Stancek
  2021-08-02 17:43   ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek @ 2021-08-02 16:54 UTC (permalink / raw)
  To: ltp

On Mon, Aug 2, 2021 at 6:30 PM Petr Vorel <pvorel@suse.cz> wrote:

> to fix warning:
> pthread_cancel/3-1.c:40:13: warning: variable ?waited_for_cancel_ms? might
> be clobbered by ?longjmp? or ?vfork? [-Wclobbered]
>    40 |         int waited_for_cancel_ms = 0;
>
> Suggested-by: Martin Doucha <mdoucha@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
>

 Acked-by: Jan Stancek <jstancek@redhat.com>

---
>  .../conformance/interfaces/pthread_cancel/3-1.c  | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git
> a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cancel/3-1.c
> b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cancel/3-1.c
> index 3527d57fd..90500b371 100644
> ---
> a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cancel/3-1.c
> +++
> b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cancel/3-1.c
> @@ -35,19 +35,25 @@ static void cleanup_func(PTS_ATTRIBUTE_UNUSED void
> *unused)
>         } while (after_cancel == 0 && thread_sleep_time < TIMEOUT_MS);
>  }
>
> -static void *thread_func(PTS_ATTRIBUTE_UNUSED void *unused)
> +static void sleep_loop(void)
>  {
>         int waited_for_cancel_ms = 0;
>         struct timespec cancel_wait_ts = {0, SLEEP_MS*1000000};
>
> -       SAFE_PFUNC(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,
> NULL));
> -       pthread_cleanup_push(cleanup_func, NULL);
> -
> -       SAFE_FUNC(sem_post(&sem));
>         while (waited_for_cancel_ms < TIMEOUT_MS) {
>                 nanosleep(&cancel_wait_ts, NULL);
>                 waited_for_cancel_ms += SLEEP_MS;
>         }
> +}
> +
> +static void *thread_func(PTS_ATTRIBUTE_UNUSED void *unused)
> +{
> +       SAFE_PFUNC(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,
> NULL));
> +       pthread_cleanup_push(cleanup_func, NULL);
> +
> +       SAFE_FUNC(sem_post(&sem));
> +
> +       sleep_loop();
>
>         /* shouldn't be reached */
>         printf("Error: cancel never arrived\n");
> --
> 2.32.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210802/45239f35/attachment.htm>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [LTP] [PATCH 1/1] openposix/pthread_cancel/3-1: Move sleep loop into separate function
  2021-08-02 16:54 ` Jan Stancek
@ 2021-08-02 17:43   ` Petr Vorel
  0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2021-08-02 17:43 UTC (permalink / raw)
  To: ltp

Hi Jan,

> On Mon, Aug 2, 2021 at 6:30 PM Petr Vorel <pvorel@suse.cz> wrote:

> > to fix warning:
> > pthread_cancel/3-1.c:40:13: warning: variable ?waited_for_cancel_ms? might
> > be clobbered by ?longjmp? or ?vfork? [-Wclobbered]
> >    40 |         int waited_for_cancel_ms = 0;

> > Suggested-by: Martin Doucha <mdoucha@suse.cz>
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>


>  Acked-by: Jan Stancek <jstancek@redhat.com>
Thanks a lot, merged!

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-02 17:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02 16:30 [LTP] [PATCH 1/1] openposix/pthread_cancel/3-1: Move sleep loop into separate function Petr Vorel
2021-08-02 16:54 ` Jan Stancek
2021-08-02 17:43   ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.