Linux Test Project
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Tudor Cretu <tudor.cretu@arm.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 1/4] lib: Fix initialization of recursive mutex
Date: Wed, 17 Aug 2022 16:13:59 +0200	[thread overview]
Message-ID: <Yvz3p3AD1YHDKdPh@yuki> (raw)
In-Reply-To: <20220817133946.234985-2-tudor.cretu@arm.com>

Hi!
> Signed-off-by: Tudor Cretu <tudor.cretu@arm.com>
> ---
>  lib/tst_res.c | 25 +++++++++++++++++--------
>  1 file changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/tst_res.c b/lib/tst_res.c
> index 8d86b48a4..2f66ec40c 100644
> --- a/lib/tst_res.c
> +++ b/lib/tst_res.c
> @@ -82,17 +82,27 @@ void *TST_RET_PTR;
>  	assert(strlen(buf) > 0);		\
>  } while (0)
>  
> -#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
> -# ifdef __ANDROID__
> -#  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
> -	PTHREAD_RECURSIVE_MUTEX_INITIALIZER
> -# else
> -/* MUSL: http://www.openwall.com/lists/musl/2017/02/20/5 */
> -#  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP  { {PTHREAD_MUTEX_RECURSIVE} }
> -# endif
> +#if !defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) && defined(__ANDROID__)
> +#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER
>  #endif
>  
> +#ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
>  static pthread_mutex_t tmutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
> +#else
> +/* MUSL: http://www.openwall.com/lists/musl/2017/02/20/5 */

I would have put this URL to the commit message instead, otherwise the
change looks good.

> +static pthread_mutex_t tmutex;
> +
> +__attribute__((constructor))
> +static void init_tmutex(void)
> +{
> +	pthread_mutexattr_t mutattr = {0};
> +
> +	pthread_mutexattr_init(&mutattr);
> +	pthread_mutexattr_settype(&mutattr, PTHREAD_MUTEX_RECURSIVE);
> +	pthread_mutex_init(&tmutex, &mutattr);
> +	pthread_mutexattr_destroy(&mutattr);
> +}
> +#endif
>  
>  static void check_env(void);
>  static void tst_condense(int tnum, int ttype, const char *tmesg);
> -- 
> 2.25.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2022-08-17 14:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 13:39 [LTP] [PATCH 0/4] syscalls: Fix various syscalls tests when compiled with Musl Tudor Cretu
2022-08-17 13:39 ` [LTP] [PATCH 1/4] lib: Fix initialization of recursive mutex Tudor Cretu
2022-08-17 14:13   ` Cyril Hrubis [this message]
2022-08-17 13:39 ` [LTP] [PATCH 2/4] syscalls/mprotect01: Invoke the syscall directly instead of the libc wrapper Tudor Cretu
2022-08-17 14:29   ` Cyril Hrubis
2022-08-17 13:39 ` [LTP] [PATCH 3/4] syscalls/prctl04: Allow rt_sigprocmask in the syscall filter Tudor Cretu
2022-08-17 14:42   ` Cyril Hrubis
2022-08-17 13:39 ` [LTP] [PATCH 4/4] syscalls/statfs: Avoid dereferencing invalid buf in libc Tudor Cretu
2022-08-17 14:40   ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yvz3p3AD1YHDKdPh@yuki \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=tudor.cretu@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox