From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9894 invoked from network); 26 Jun 2020 06:20:51 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 26 Jun 2020 06:20:51 -0000 Received: (qmail 21817 invoked by uid 550); 26 Jun 2020 06:20:49 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 26499 invoked from network); 26 Jun 2020 04:33:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gsat.us; s=default; t=1593146021; bh=98CeWrOqAGLbxavmhiHZLjZjWzIP865dWXBP8mJKm/0=; h=Subject:To:References:From:Date:In-Reply-To; b=TAYQ0bIXky6froUxS/lPJsk7GbYq5DdHvDgL6IeOQYtfCHua9QOoRIQHqR8XEPoDN pPTgVsK465hWwwz94frHXwVnbMToYFhx/QjLpIjwlTCJ1d4fS4q2xYlMQ1qColZ4vw 9MavEKgBWSvAz5BFRSdE6mIOVqXQXoRXRXzOMmrE= To: Khem Raj , musl@lists.openwall.com, Daniel Santos References: <20200624232008.4093-1-daniel.santos@pobox.com> <39be4d66-963c-4e06-e685-37a8396d10c3@gmail.com> From: Daniel Santos Message-ID: Date: Thu, 25 Jun 2020 23:31:32 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: <39be4d66-963c-4e06-e685-37a8396d10c3@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US Subject: Re: [musl] [PATCH] Fix signed compare warning On 6/25/20 10:58 AM, Khem Raj wrote: > > On 6/24/20 4:20 PM, Daniel Santos wrote: >> Signed-off-by: Daniel Santos >> --- >> src/thread/__timedwait.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/src/thread/__timedwait.c b/src/thread/__timedwait.c >> index 666093be..9829b93e 100644 >> --- a/src/thread/__timedwait.c >> +++ b/src/thread/__timedwait.c >> @@ -38,7 +38,7 @@ int __timedwait_cp(volatile int *addr, int val, >> if (priv) priv = FUTEX_PRIVATE; >> >> if (at) { >> - if (at->tv_nsec >= 1000000000UL) return EINVAL; >> + if ((unsigned long)at->tv_nsec >= 1000000000UL) return EINVAL; >> if (__clock_gettime(clk, &to)) return EINVAL; >> to.tv_sec = at->tv_sec - to.tv_sec; >> if ((to.tv_nsec = at->tv_nsec - to.tv_nsec) < 0) { >> > may be use < 0 || >= 1000000000L and avoid the cast. > there is a similar issue in src/thread/pthread_cond_timedwait.c as well Thank you for that.  I'll resubmit changing both instances. In this case, the POSIX spec requires nt_nsec to be a long ( https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html ).  Either way, a good optimizer should convert this into an unsigned compare.  My early years in 6502 assembly sort-of shapes my thinking, as I try to write higher level code as similarly to the assembly I presume the compiler will emit.  But if the project has a strong preference to avoid casts, I can change it. Thanks! Daniel