From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by sourceware.org (Postfix) with ESMTPS id 56E503857C47 for ; Mon, 17 Aug 2020 12:04:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 56E503857C47 Received: by mail-pj1-x1043.google.com with SMTP id ep8so7596024pjb.3 for ; Mon, 17 Aug 2020 05:04:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=RKrYyRrEhn2ZJnPCwKtkYhtXzqrI/P3UcJ9vxUpIaHU=; b=kpWQUhKMepgD7uo4KGBIbx/wZw65YVWVBWK6OPuwGtrGh4bmsZo0i4VwYuwjcGITMe 7uDmPu0Fi+6yQWtRNSyT3PGeamA9d4yBJjPJjSL5bqEw80LPLpmV4tLGKpYY3uqAi4Xe q9ahQNVEwNYAtJowjnJrEqanhYABp/SetI6mDZBF5aLAAtCb4XLZjxrMf5zSFXMYzJmE QZYIF4N4eC5XmLP+ppKy2IJD6J5nD2qm8U414am2lMexMvGPAICS06pPaUhFui8/23FW h7hGZf7FpzQhrxdMu6jBICLQuepore/3eqERO/IuYxRQIsMQ7VINZaRq27JFjHoS+qHt hhnw== X-Gm-Message-State: AOAM531Lj/7i8VoqaSWj5EsVQ6+vvgemlhI8eXg9gQUxsPw7sYbplVOD rVt5KQ/7zlPCAOcoe98HiFWXl6Y+xZuJWg== X-Google-Smtp-Source: ABdhPJy628VKZFp5dizB3K1/1OzIB78qAWgTBI27znh5WkR/WJItDUV8VJlgFi4jOLcJ9+jtrWGanw== X-Received: by 2002:a17:902:ba8f:: with SMTP id k15mr11259404pls.79.1597665888432; Mon, 17 Aug 2020 05:04:48 -0700 (PDT) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id v10sm19432432pff.192.2020.08.17.05.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2020 05:04:47 -0700 (PDT) Received: by gnu-cfl-2.localdomain (Postfix, from userid 1000) id 6F0ED1A0221; Mon, 17 Aug 2020 05:04:46 -0700 (PDT) Date: Mon, 17 Aug 2020 05:04:46 -0700 From: "H.J. Lu" To: Andreas Schwab Cc: Lukasz Majewski , Joseph Myers , Paul Eggert , Adhemerval Zanella , Florian Weimer , GNU C Library , Stepan Golosunov , Alistair Francis Subject: Re: [PATCH] nptl: Handle NULL abstime [BZ #26394] Message-ID: <20200817120446.GA2418158@gmail.com> References: <20200812102205.14816-1-lukma@denx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Aug 2020 12:04:50 -0000 On Mon, Aug 17, 2020 at 12:22:16PM +0200, Andreas Schwab wrote: > On Aug 15 2020, H.J. Lu wrote: > > > From fa1f97680fca290a378c449f2b63682ee348fd2c Mon Sep 17 00:00:00 2001 > > From: "H.J. Lu" > > Date: Sat, 15 Aug 2020 11:06:35 -0700 > > Subject: [PATCH] nptl: Handle NULL abstime [BZ #26394] > > > > Since abstime passed to pthread_{clock|timed}join_np may be NULL, convert > > to 64 bit abstime only if abstime isn't NULL. > > --- > > nptl/pthread_clockjoin.c | 12 +++++++++--- > > nptl/pthread_timedjoin.c | 10 +++++++--- > > 2 files changed, 16 insertions(+), 6 deletions(-) > > > > diff --git a/nptl/pthread_clockjoin.c b/nptl/pthread_clockjoin.c > > index 3cd780f688..0d780d6f4b 100644 > > --- a/nptl/pthread_clockjoin.c > > +++ b/nptl/pthread_clockjoin.c > > @@ -34,9 +34,15 @@ int > > __pthread_clockjoin_np (pthread_t threadid, void **thread_return, > > clockid_t clockid, const struct timespec *abstime) > > { > > - struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime); > > - > > - return __pthread_clockjoin_np64 (threadid, thread_return, clockid, &ts64); > > + if (abstime) > > (abstime != NULL) > > > + { > > + struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime); > > + return __pthread_clockjoin_np64 (threadid, thread_return, clockid, > > + &ts64); > > + } > > + else > > + return __pthread_clockjoin_np64 (threadid, thread_return, clockid, > > + NULL); > > } > > #endif > > weak_alias (__pthread_clockjoin_np, pthread_clockjoin_np) > > diff --git a/nptl/pthread_timedjoin.c b/nptl/pthread_timedjoin.c > > index 6164ae7060..a7b3cb35d2 100644 > > --- a/nptl/pthread_timedjoin.c > > +++ b/nptl/pthread_timedjoin.c > > @@ -34,9 +34,13 @@ int > > __pthread_timedjoin_np (pthread_t threadid, void **thread_return, > > const struct timespec *abstime) > > { > > - struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime); > > - > > - return __pthread_timedjoin_np64 (threadid, thread_return, &ts64); > > + if (abstime) > > (abstime != NULL) > > > + { > > + struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime); > > + return __pthread_timedjoin_np64 (threadid, thread_return, &ts64); > > + } > > + else > > + return __pthread_timedjoin_np64 (threadid, thread_return, NULL); > > } > > #endif > > weak_alias (__pthread_timedjoin_np, pthread_timedjoin_np) > > Andreas. > Here is the updated patch I am checking in. H.J. --- Since abstime passed to pthread_{clock|timed}join_np may be NULL, convert to 64 bit abstime only if abstime isn't NULL. --- nptl/pthread_clockjoin.c | 12 +++++++++--- nptl/pthread_timedjoin.c | 10 +++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/nptl/pthread_clockjoin.c b/nptl/pthread_clockjoin.c index 3cd780f688..0baba1e83d 100644 --- a/nptl/pthread_clockjoin.c +++ b/nptl/pthread_clockjoin.c @@ -34,9 +34,15 @@ int __pthread_clockjoin_np (pthread_t threadid, void **thread_return, clockid_t clockid, const struct timespec *abstime) { - struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime); - - return __pthread_clockjoin_np64 (threadid, thread_return, clockid, &ts64); + if (abstime != NULL) + { + struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime); + return __pthread_clockjoin_np64 (threadid, thread_return, clockid, + &ts64); + } + else + return __pthread_clockjoin_np64 (threadid, thread_return, clockid, + NULL); } #endif weak_alias (__pthread_clockjoin_np, pthread_clockjoin_np) diff --git a/nptl/pthread_timedjoin.c b/nptl/pthread_timedjoin.c index 6164ae7060..6ade58853c 100644 --- a/nptl/pthread_timedjoin.c +++ b/nptl/pthread_timedjoin.c @@ -34,9 +34,13 @@ int __pthread_timedjoin_np (pthread_t threadid, void **thread_return, const struct timespec *abstime) { - struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime); - - return __pthread_timedjoin_np64 (threadid, thread_return, &ts64); + if (abstime != NULL) + { + struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime); + return __pthread_timedjoin_np64 (threadid, thread_return, &ts64); + } + else + return __pthread_timedjoin_np64 (threadid, thread_return, NULL); } #endif weak_alias (__pthread_timedjoin_np, pthread_timedjoin_np) -- 2.26.2